fix "referencing nonexistant file" bug

improve internal error message
This commit is contained in:
GenevensiS
2025-07-15 02:30:11 +02:00
parent 0e4c91b940
commit 70e44474a5
7 changed files with 97 additions and 62 deletions
+7 -4
View File
@@ -12,6 +12,7 @@
#include <util/error.hpp>
#include <script/to_value.hpp> // for reflection
#include <script/profiler.hpp> // for PROFILER
#include <data/set.hpp>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include <wx/dir.h>
@@ -19,7 +20,7 @@
// ----------------------------------------------------------------------------- : Package : outside
IMPLEMENT_DYNAMIC_ARG(Package*, writing_package, nullptr);
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
Package::Package()
: zipStream (nullptr)
@@ -97,7 +98,8 @@ void Package::save(bool remove_unused) {
saveAs(filename, remove_unused);
}
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
// type of package
if (wxDirExists(name) || as_directory) {
saveToDirectory(name, remove_unused, false);
@@ -109,7 +111,8 @@ void Package::saveAs(const String& name, bool remove_unused, bool as_directory)
reopen();
}
void Package::saveCopy(const String& name) {
void Package::saveCopy(const String& name) {
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
saveToZipfile(name, true, true);
clearKeepFlag();
}
@@ -298,7 +301,7 @@ LocalFileName 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"));
if (it == files.end()) throw InternalError(_("Referencing an inexistant file!"));
it->second.keep = true;
}