- 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:
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
CastRestrictions * clone() const
|
||||
{
|
||||
return NEW CastRestrictions(*this);
|
||||
return NEW CastRestrictions(*this);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void DoTransition(int trans, int tostate, float dur = -1, bool animonly = false);
|
||||
void DoAnimation(int trans, float dur = -1);
|
||||
static hgeParticleSystem * Particles[6];
|
||||
static int HasMusic;
|
||||
static bool HasMusic;
|
||||
static string systemError;
|
||||
static JMusic* music;
|
||||
static string currentMusicFile;
|
||||
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
//These return a filepath accurate to the current mode/profile/theme, and can
|
||||
//optionally fallback to a file within a certain directory.
|
||||
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
||||
string profileFile(string filename="", string fallback="", bool sanity=false,bool relative=false);
|
||||
string profileFile(string filename="", string fallback="", bool sanity=false);
|
||||
|
||||
void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE]
|
||||
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
||||
|
||||
@@ -26,14 +26,15 @@ private:
|
||||
char nbcardsStr[400];
|
||||
vector<string> langs;
|
||||
vector<string> primitives;
|
||||
|
||||
size_t mCurrentSetFolderIndex;
|
||||
string mCurrentSetName;
|
||||
string mCurrentSetFileName;
|
||||
vector<string> setFolders;
|
||||
|
||||
string wallpaper;
|
||||
int primitivesLoadCounter;
|
||||
|
||||
DIR *mDip;
|
||||
struct dirent *mDit;
|
||||
char mCurrentSetName[32];
|
||||
char mCurrentSetFileName[512];
|
||||
|
||||
int mReadConf;
|
||||
float timeIndex;
|
||||
void fillScroller();
|
||||
@@ -61,8 +62,7 @@ public:
|
||||
virtual void Render();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
|
||||
int nextDirectory(const char * root, const char * file); // Retrieves the next directory to have matching file
|
||||
void resetDirectory();
|
||||
int nextSetFolder(const string & root, const string & file); // Retrieves the next directory to have matching file
|
||||
void createUsersFirstDeck(int setId);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
|
||||
|
||||
@@ -127,8 +127,6 @@ public:
|
||||
int totalCards();
|
||||
int randomCardId();
|
||||
|
||||
static void loadPrimitives(const char *root_directory);
|
||||
static void loadSets(const char *root_directory, const char* filename);
|
||||
static void loadInstance();
|
||||
static void unloadAll();
|
||||
static inline MTGAllCards* getInstance() { return instance; };
|
||||
|
||||
@@ -101,8 +101,8 @@ public:
|
||||
virtual string cardFile(const string& filename) = 0;
|
||||
virtual string musicFile(const string& filename) = 0;
|
||||
virtual string sfxFile(const string& filename) = 0;
|
||||
virtual int fileOK(const string&, bool relative = false) = 0;
|
||||
virtual int dirOK(const string& dirname) = 0;
|
||||
virtual bool fileOK(const string&) = 0;
|
||||
virtual bool dirOK(const string& dirname) = 0;
|
||||
|
||||
//For backwards compatibility with JWResourceManager. Avoid using these, they're not optimal.
|
||||
virtual int CreateTexture(const string &textureName) = 0;
|
||||
|
||||
@@ -173,8 +173,8 @@ public:
|
||||
string cardFile(const string& filename);
|
||||
string musicFile(const string& filename);
|
||||
string sfxFile(const string& filename);
|
||||
int fileOK(const string&, bool relative = false);
|
||||
int dirOK(const string& dirname);
|
||||
bool fileOK(const string&);
|
||||
bool dirOK(const string& dirname);
|
||||
|
||||
//For backwards compatibility with JResourceManager. Avoid using these, they're not optimal.
|
||||
int CreateTexture(const string &textureName);
|
||||
|
||||
@@ -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