Changeset 462 for trunk/lib/utility.cc


Ignore:
Timestamp:
Aug 21, 2007, 12:34:37 PM (14 years ago)
Author:
Jari Häkkinen
Message:

Merged patch release 0.6.2 to the trunk. Delta 0.6.2 - 0.6.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/utility.cc

    r439 r462  
    22
    33/*
    4   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2007 Peter Johansson
     4  Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    65
    76  This file is part of svndigest, http://trac.thep.lu.se/trac/svndigest
     
    6160
    6261
     62  void copy_file(const std::string& source, const std::string& target)
     63  {
     64    std::ofstream o(target.c_str());
     65    std::ifstream i(source.c_str());
     66    while (i.good()) {
     67      char ch=i.get();
     68      if (i.good())
     69        o.put(ch);
     70      if (!o.good())
     71        throw std::runtime_error(std::string("copy_file: ") +
     72                                 "writing target file failed '" + target + "'");
     73    }
     74    if (!i.eof() && (i.bad() || i.fail()))  // fail on everything except eof
     75      throw std::runtime_error(std::string("copy_file: ") +
     76                               "error reading source file '" + source + "'");
     77    i.close(); o.close();
     78  }
     79
     80
    6381  std::string file_name(const std::string& full_path)
    6482  {
Note: See TracChangeset for help on using the changeset viewer.