Fix warnings

Semi-fix bug #6 (does not work if the zipfile was loaded from a directory)


git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1439 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
coppro
2010-03-04 01:46:04 +00:00
parent cf91f9c43b
commit 85854b1bd2
31 changed files with 93 additions and 71 deletions
+4 -4
View File
@@ -33,12 +33,12 @@
template <typename Key, typename Value>
class IndexMap : private vector<Value> {
public:
using typename vector<Value>::iterator;
using typename vector<Value>::const_iterator;
using typename vector<Value>::reference;
using typename vector<Value>::const_reference;
using vector<Value>::empty;
using vector<Value>::size;
using vector<Value>::iterator;
using vector<Value>::const_iterator;
using vector<Value>::reference;
using vector<Value>::const_reference;
using vector<Value>::begin;
using vector<Value>::end;
using vector<Value>::clear;
+4
View File
@@ -340,6 +340,7 @@ void Package::loadZipStream() {
}
void Package::openDirectory() {
zipfile = false;
openSubdir(wxEmptyString);
}
@@ -367,6 +368,7 @@ void Package::openSubdir(const String& name) {
}
void Package::openZipfile() {
zipfile = true;
// close old streams
delete fileStream; fileStream = nullptr;
delete zipStream; zipStream = nullptr;
@@ -380,6 +382,7 @@ void Package::openZipfile() {
}
void Package::saveToDirectory(const String& saveAs, bool remove_unused, bool is_copy) {
zipfile = false;
// write to a directory
VCSP vcs = getVCS();
FOR_EACH(f, files) {
@@ -411,6 +414,7 @@ void Package::saveToDirectory(const String& saveAs, bool remove_unused, bool is_
}
void Package::saveToZipfile(const String& saveAs, bool remove_unused, bool is_copy) {
zipfile = true;
// create a temporary zip file name
String tempFile = saveAs + _(".tmp");
wxRemoveFile(tempFile);
+23 -8
View File
@@ -121,14 +121,8 @@ class Package : public IntrusivePtrVirtualBase {
// --------------------------------------------------- : Managing the inside of the package : Reader/writer
template <typename T>
void readFile(const String& file, T& obj) {
Reader reader(openIn(file), dynamic_cast<Packaged*>(this), absoluteFilename() + _("/") + file);
try {
reader.handle_greedy(obj);
} catch (const ParseError& err) {
throw FileParseError(err.what(), absoluteFilename() + _("/") + file); // more detailed message
}
}
void readFile(const String& file, T& obj);
template <typename T>
T readFile(const String& file) {
T obj;
@@ -146,6 +140,9 @@ class Package : public IntrusivePtrVirtualBase {
// TODO: I dislike putting this here very much. There ought to be a better way.
virtual VCSP getVCS() { return new_intrusive<VCS>(); }
/// true if this is a zip file, false if a directory (updated on open/save)
bool isZipfile() { return zipfile; }
// --------------------------------------------------- : Private stuff
private:
@@ -165,6 +162,10 @@ class Package : public IntrusivePtrVirtualBase {
String filename;
/// Last modified time
DateTime modified;
/// Zipfile flag
bool zipfile;
public:
/// Information on files in the package
/** Note: must be public for DECLARE_TYPEOF to work */
@@ -278,5 +279,19 @@ intrusive_ptr<T> open_package(const String& filename) {
return package;
}
// ----------------------------------------------------------------------------- : readFile definition
// This is here because it uses dynamic_cast and must be to a complete type.
template <typename T>
inline void Package::readFile(const String& file, T& obj)
{
Reader reader(openIn(file), dynamic_cast<Packaged*>(this), absoluteFilename() + _("/") + file);
try {
reader.handle_greedy(obj);
} catch (const ParseError& err) {
throw FileParseError(err.what(), absoluteFilename() + _("/") + file); // more detailed message
}
}
// ----------------------------------------------------------------------------- : EOF
#endif