mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
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
This commit is contained in:
parent
9ae356550e
commit
6fccd83fac
1 changed files with 2 additions and 3 deletions
|
|
@ -149,11 +149,10 @@ rename (const path & from_path, const path & to_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX character encoding.
|
||||||
void
|
void
|
||||||
copy_file(const path & from_path, const path & to_path)
|
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::ifstream in(from_path.to_string().c_str());
|
||||||
std::ofstream out(to_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();
|
out << in.rdbuf();
|
||||||
|
|
||||||
if (!in || !out) {
|
if (!in || !out) {
|
||||||
|
remove (to_path);
|
||||||
throw filesystem_error(string_compose(_("Could not copy existing file %1 to %2"),
|
throw filesystem_error(string_compose(_("Could not copy existing file %1 to %2"),
|
||||||
from_path.to_string(), to_path.to_string()));
|
from_path.to_string(), to_path.to_string()));
|
||||||
remove (to_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue