Changeset 456 for branches/0.6-stable/lib/utility.cc
- Timestamp:
- Aug 21, 2007, 9:56:06 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.6-stable/lib/utility.cc
r430 r456 61 61 62 62 63 void copy_file(const std::string& source, const std::string& target) 64 { 65 std::ofstream o(target.c_str()); 66 std::ifstream i(source.c_str()); 67 while (i.good()) { 68 char ch=i.get(); 69 if (i.good()) 70 o.put(ch); 71 if (!o.good()) 72 throw std::runtime_error(std::string("copy_file: ") + 73 "writing target file failed '" + target + "'"); 74 } 75 if (!i.eof() && (i.bad() || i.fail())) // fail on everything except eof 76 throw std::runtime_error(std::string("copy_file: ") + 77 "error reading source file '" + source + "'"); 78 i.close(); o.close(); 79 } 80 81 63 82 std::string file_name(const std::string& full_path) 64 83 {
Note: See TracChangeset
for help on using the changeset viewer.