summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-09-09 10:05:16 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-09-09 10:05:16 +0000
commit6fccd83facd35f0600362e8980c6f309f151e89b (patch)
treeda4f2db32f85fda271c0e219aca3092fe984cb37 /libs
parent9ae356550e54a0f5d3a2bf6c35ef7174f8c0d7b1 (diff)
If sys::copy_file fails, try and remove the target file before throwing an exception
git-svn-id: svn://localhost/ardour2/trunk@2435 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/filesystem.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/libs/pbd/filesystem.cc b/libs/pbd/filesystem.cc
index f527c9a473..84d18cfcd2 100644
--- a/libs/pbd/filesystem.cc
+++ b/libs/pbd/filesystem.cc
@@ -149,11 +149,10 @@ rename (const path & from_path, const path & to_path)
}
}
+// XXX character encoding.
void
copy_file(const path & from_path, const path & to_path)
{
- // this implementation could use mucho memory
- // for big files.
std::ifstream in(from_path.to_string().c_str());
std::ofstream out(to_path.to_string().c_str());
@@ -165,9 +164,9 @@ copy_file(const path & from_path, const path & to_path)
out << in.rdbuf();
if (!in || !out) {
+ remove (to_path);
throw filesystem_error(string_compose(_("Could not copy existing file %1 to %2"),
from_path.to_string(), to_path.to_string()));
- remove (to_path);
}
}