- Support for Zip Filesystem. It is now possible to zip the entire Res folder ("store" method preferred, zip so that the root of the zip has ai, player, etc...) in one single file for read only. Write access is done in another folder (hardcoded to be User/ for now, can be updated depending on platforms, etc...
-- zipFS has several limitations... --- in a general way, seekg doesn't work... so getting a file's size needs to be done through JFileSystem. --- getLine on files open with zipFS doesn't work so great. Not sure if it is a normal issue because files are open in binary or not... JFileSystem therefore offers a "readIntoString" function that needs to be used instead of the usual "getline" technique. However getLine can then be used on a stream connected to the string. -- tested on Windows and PSP, I also made sure android still works, but haven't tested zip support on Android. -- I tried to maintain backwards compatibility, but this might break on some platforms, if I broke some platforms and you can't find a way to fix them, please contact me and we'll figure something out -- This removes wagic::ifstream. I didn't reimplement the securities that were involved in this, apologies for that. Might be useful to reimplement such securities in JFileSystem -- I haven't tested options/profiles in a deep way, it is possible I broke that.
This commit is contained in:
@@ -29,46 +29,6 @@
|
||||
|
||||
#include "DebugRoutines.h"
|
||||
|
||||
// enable this define to collect statistics on how many times an ifstream is created for a given file.
|
||||
//#define TRACK_FILE_USAGE_STATS
|
||||
|
||||
namespace wagic
|
||||
{
|
||||
|
||||
#ifdef TRACK_FILE_USAGE_STATS
|
||||
class ifstream : public std::ifstream
|
||||
{
|
||||
public:
|
||||
explicit ifstream(const char *inFilename, ios_base::openmode inMode = ios_base::in) :
|
||||
std::ifstream(inFilename, inMode)
|
||||
{
|
||||
sFileMap[std::string(inFilename)] += 1;
|
||||
DebugTrace("ifstream opened on file: " << inFilename);
|
||||
}
|
||||
|
||||
static void Dump()
|
||||
{
|
||||
DebugTrace("-------------------");
|
||||
DebugTrace("File Usage Statistics" << std::endl);
|
||||
std::map<std::string, int>::const_iterator iter = sFileMap.begin();
|
||||
for (; iter != sFileMap.end(); ++iter)
|
||||
{
|
||||
DebugTrace(iter->first << " -- " << iter->second);
|
||||
}
|
||||
|
||||
DebugTrace("End File Usage Statistics");
|
||||
DebugTrace("-------------------");
|
||||
}
|
||||
|
||||
private:
|
||||
static std::map<std::string, int> sFileMap;
|
||||
};
|
||||
|
||||
#else
|
||||
typedef std::ifstream ifstream;
|
||||
#endif
|
||||
|
||||
} //namespace wagic
|
||||
|
||||
using std::string;
|
||||
|
||||
@@ -105,7 +65,6 @@ unsigned long hash_djb2(const char *str);
|
||||
|
||||
int loadRandValues(string s);
|
||||
int filesize(const char * filename);
|
||||
int fileExists(const char * filename);
|
||||
int WRand();
|
||||
|
||||
#ifdef LINUX
|
||||
@@ -135,6 +94,9 @@ u32 ramAvailable(void);
|
||||
#define MAKEDIR(name) mkdir(name, 0777)
|
||||
#endif
|
||||
|
||||
bool FileExists(const string& strFilename);
|
||||
bool fileExists(const char * filename);
|
||||
bool FileExists(const string & filename);
|
||||
|
||||
std::string buildFilePath(const vector<string> & folders, const string & filename);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user