- Path::mkpath(copy.src.subpath(0, copy.src.size()-1), 0755);
- unlink(copy.dest.str().c_str());
- ifstream in(copy.src.str().c_str());
- ofstream out(copy.dest.str().c_str());
+ const FileTarget &source = target.get_source();
+ const FS::Path &src_path = source.get_path();
+ const FS::Path &dst_path = target.get_path();
+ FS::mkpath(FS::dirname(dst_path), 0755);
+
+ // Remove old file. Not doing this would cause Bad Stuff when installing libraries.
+ if(FS::exists(dst_path))
+ {
+ try
+ {
+ unlink(dst_path);
+ }
+ catch(const exception &e)
+ {
+ IO::print(IO::cerr, "%s\n", e.what());
+ status = Task::ERROR;
+ return;
+ }
+ }
+
+ try
+ {
+ IO::File in(src_path.str());
+ IO::File out(dst_path.str(), IO::M_WRITE);