[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src filesystem.cpp
From: |
Yann Dirson |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src filesystem.cpp |
Date: |
Sat, 19 Feb 2005 19:31:50 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Yann Dirson <address@hidden> 05/02/20 00:31:50
Modified files:
src : filesystem.cpp
Log message:
allow to call filesystem_init several times - have to destroy
the_collection first, since zipios collections cannot be emptied
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/filesystem.cpp.diff?tr1=1.59&tr2=1.60&r1=text&r2=text
Patches:
Index: wesnoth/src/filesystem.cpp
diff -u wesnoth/src/filesystem.cpp:1.59 wesnoth/src/filesystem.cpp:1.60
--- wesnoth/src/filesystem.cpp:1.59 Fri Jan 28 23:38:52 2005
+++ wesnoth/src/filesystem.cpp Sun Feb 20 00:31:49 2005
@@ -1,4 +1,4 @@
-/* $Id: filesystem.cpp,v 1.59 2005/01/28 23:38:52 ydirson Exp $ */
+/* $Id: filesystem.cpp,v 1.60 2005/02/20 00:31:49 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -75,7 +75,7 @@
#include "zipios++/xcoll.hpp"
namespace {
- xzipios::XCColl the_collection;
+ xzipios::XCColl* the_collection = NULL;
void register_zipdir(const std::string directory) {
// look for zip files
@@ -88,7 +88,7 @@
if ((fname.size() > suffix.size()) &&
(0 == fname.compare(fname.size() -
suffix.size(), suffix.size(), suffix))) {
zipios::ZipFile zip(game_config::path +
"/" + fname);
- the_collection.addCollection(zip);
+ the_collection->addCollection(zip);
LOG_G << "zip collection " << fname <<
" has " << zip.size() << "
elements\n";
}
@@ -103,18 +103,25 @@
bool filesystem_init()
{
#ifdef USE_ZIPIOS
+ if (the_collection != NULL) {
+ // this is a re-read, cleanup first !
+ free (the_collection);
+ }
+
+ the_collection = new xzipios::XCColl;
+
if (!get_user_data_dir().empty()) {
LOG_G << "looking at user dir " << get_user_data_dir() << "\n";
zipios::DirectoryCollection dir(get_user_data_dir());
LOG_G << "user collection has " << dir.size() << " elements\n";
- the_collection.addCollection(dir);
+ the_collection->addCollection(dir);
register_zipdir(get_user_data_dir());
}
if (!game_config::path.empty()) {
LOG_G << "looking at system dir " << game_config::path << "\n";
zipios::DirectoryCollection dir(game_config::path);
LOG_G << "system collection has " << dir.size() << "
elements\n";
- the_collection.addCollection(dir);
+ the_collection->addCollection(dir);
register_zipdir(game_config::path);
}
#endif
@@ -137,8 +144,8 @@
FILE_NAME_MODE mode)
{
#ifdef USE_ZIPIOS
- if (the_collection.hasSubdir(directory)) {
- the_collection.childrenOf(directory, files, dirs);
+ if (the_collection->hasSubdir(directory)) {
+ the_collection->childrenOf(directory, files, dirs);
}
else
#endif
@@ -453,9 +460,9 @@
LOG_G << "Reading " << fname << "\n";
#ifdef USE_ZIPIOS
if(!fname.empty() && fname[0] != '/') {
- zipios::ConstEntryPointer p = the_collection.getEntry(fname);
+ zipios::ConstEntryPointer p = the_collection->getEntry(fname);
if (p != 0) {
- std::istream* s = the_collection.getInputStream(p);
+ std::istream* s = the_collection->getInputStream(p);
if (s != NULL) {
std::string contents = read_stream(*s);
delete s;
@@ -549,7 +556,7 @@
{
#ifdef USE_ZIPIOS
if(!fname.empty() && fname[0] != '/') {
- return the_collection.hasSubdir(fname);
+ return the_collection->hasSubdir(fname);
}
#else
@@ -565,7 +572,7 @@
bool file_exists(const std::string& name)
{
#ifdef USE_ZIPIOS
- if (the_collection.getEntry(name))
+ if (the_collection->getEntry(name))
return true;
#endif
std::ifstream file(name.c_str());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src filesystem.cpp,
Yann Dirson <=