- 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:
wagic.the.homebrew
2011-08-21 09:04:59 +00:00
parent 14bd7b7a24
commit e27cf56fa2
73 changed files with 3539 additions and 936 deletions

View File

@@ -78,62 +78,16 @@ int filesize(const char * filename)
return file_size;
}
// check to see if a file exists on the file system.
int fileExists(const char * filename)
bool fileExists(const char * filename)
{
wagic::ifstream fichier(filename);
if (fichier)
{
fichier.close();
return 1;
}
wagic::ifstream fichier2(JGE_GET_RES(filename).c_str());
if (fichier2)
{
fichier2.close();
return 1;
}
return 0;
return JFileSystem::GetInstance()->FileExists(filename);
}
// check to see if a file exists on the file system.
// this can be used to extract last modified date of a file.
bool FileExists(const string& strFilename)
{
struct stat stFileInfo;
bool blnReturn = false;
int intStat;
// Attempt to get the file attributes
intStat = stat(strFilename.c_str(),&stFileInfo);
if(intStat == 0)
{
// We were able to get the file attributes
// so the file obviously exists.
blnReturn = true;
}
else
{
// We were not able to get the file attributes.
// This may mean that we don't have permission to
// access the folder which contains this file. If you
// need to do that level of checking, lookup the
// return values of stat which will give you
// more details on why stat failed.
// try to search in the resource directory
if ( stat( JGE_GET_RES(strFilename).c_str(), &stFileInfo ) == 0)
blnReturn = true;
else
blnReturn = false;
}
return(blnReturn);
bool FileExists(const string & filename)
{
return JFileSystem::GetInstance()->FileExists(filename);
}
/*
#ifdef LINUX
@@ -396,4 +350,21 @@ unsigned long hash_djb2(const char *str)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
std::string buildFilePath(const vector<string> & folders, const string & filename)
{
string result = "";
for (size_t i = 0; i < folders.size(); ++i)
{
result.append(folders[i]);
if (result[result.length()-1] != '/')
{
result.append("/");
}
}
result.append(filename);
return result;
}