mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
implemented clipboard handling for cards
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@83 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -18,6 +18,9 @@ DECLARE_TYPEOF(Package::FileInfos);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Package : outside
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, writing_package, nullptr);
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
|
||||
|
||||
Package::Package()
|
||||
: zipStream (nullptr)
|
||||
, fileStream(nullptr)
|
||||
@@ -219,6 +222,13 @@ String Package::newFileName(const String& prefix, const String& suffix) {
|
||||
}
|
||||
}
|
||||
|
||||
void Package::referenceFile(const String& file) {
|
||||
if (file.empty()) return;
|
||||
FileInfos::iterator it = files.find(file);
|
||||
if (it == files.end()) throw InternalError(_("referencing a nonexistant file"));
|
||||
it->second.keep = true;
|
||||
}
|
||||
|
||||
String Package::absoluteName(const String& file) {
|
||||
assert(wxThread::IsMain());
|
||||
FileInfos::iterator it = files.find(toStandardName(file));
|
||||
@@ -236,6 +246,21 @@ String Package::absoluteName(const String& file) {
|
||||
return filename+_("\1")+file;
|
||||
}
|
||||
}
|
||||
// Open a file that is in some package
|
||||
InputStreamP Package::openAbsoluteFile(const String& name) {
|
||||
size_t pos = name.find_first_of(_('\1'));
|
||||
if (pos == String::npos) {
|
||||
// temp or dir file
|
||||
shared_ptr<wxFileInputStream> f = new_shared1<wxFileInputStream>(name);
|
||||
if (!f->IsOk()) throw FileNotFoundError(_("<unknown>"), name);
|
||||
return f;
|
||||
} else {
|
||||
// packaged file, always in zip format
|
||||
Package p;
|
||||
p.open(name.substr(0, pos));
|
||||
return p.openIn( name.substr(pos + 1));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Package : private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user