Use LocalFileName class for file names inside a package.

This commit is contained in:
Twan van Laarhoven
2020-04-29 23:57:36 +02:00
parent f92c09e87a
commit a1d54f36fc
19 changed files with 143 additions and 93 deletions
+2 -20
View File
@@ -354,26 +354,8 @@ template <> void Reader::handle(Vector2D& vec) {
}
}
template <> void Reader::handle(FileName& f) {
if (clipboard_package()) {
String str = getValue();
if (!str.empty()) {
// copy file into current package
try {
String packaged_name = clipboard_package()->newFileName(_("image"),_("")); // a new unique name in the package, assume it's an image
auto out_stream = clipboard_package()->openOut(packaged_name);
auto in_stream = Package::openAbsoluteFile(str);
out_stream->Write(*in_stream); // copy
f.assign(packaged_name);
} catch (Error const&) {
// ignore errors
}
} else {
f.assign(str);
}
} else {
handle(static_cast<String&>(f));
}
template <> void Reader::handle(LocalFileName& f) {
f = LocalFileName::fromReadString(this->getValue());
}
// ----------------------------------------------------------------------------- : EnumReader