| 34 | } |
| 35 | |
| 36 | void File::copy(String const& source, String const& target) { |
| 37 | auto sourceFile = File::open(source, IOMode::Read); |
| 38 | auto targetFile = File::open(target, IOMode::ReadWrite); |
| 39 | |
| 40 | targetFile->resize(0); |
| 41 | |
| 42 | char buf[1024]; |
| 43 | while (!sourceFile->atEnd()) { |
| 44 | size_t r = sourceFile->read(buf, 1024); |
| 45 | targetFile->writeFull(buf, r); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | FilePtr File::open(const String& filename, IOMode mode) { |
| 50 | auto file = make_shared<File>(filename); |