|
@@ -46,6 +46,36 @@
|
|
//Cache handling functions
|
|
//Cache handling functions
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
bool isCachePath(const char* path)
|
|
bool isCachePath(const char* path)
|
|
|
|
+{
|
|
|
|
+ if (!path || !*path)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ if (path[0] == '/')
|
|
|
|
+ {
|
|
|
|
+ if (strstr(path, Platform::osGetTemporaryDirectory()) != NULL)
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ const char* tmp = Platform::osGetTemporaryDirectory();
|
|
|
|
+ if (strstr(path, tmp+1) != NULL)
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool isUserDataPath(const char* path)
|
|
{
|
|
{
|
|
if (!path || !*path)
|
|
if (!path || !*path)
|
|
return false;
|
|
return false;
|
|
@@ -142,7 +172,7 @@ File::~File()
|
|
File::Status File::open(const char *filename, const AccessMode openMode)
|
|
File::Status File::open(const char *filename, const AccessMode openMode)
|
|
{
|
|
{
|
|
//If its a cache path then we need to open it using C methods not AssetManager
|
|
//If its a cache path then we need to open it using C methods not AssetManager
|
|
- if (isCachePath(filename))
|
|
|
|
|
|
+ if (isCachePath(filename) || isUserDataPath(filename))
|
|
{
|
|
{
|
|
if (dStrlen(filename) > MAX_MAC_PATH_LONG)
|
|
if (dStrlen(filename) > MAX_MAC_PATH_LONG)
|
|
Con::warnf("File::open: Filename length is pretty long...");
|
|
Con::warnf("File::open: Filename length is pretty long...");
|
|
@@ -155,7 +185,14 @@ File::Status File::open(const char *filename, const AccessMode openMode)
|
|
switch (openMode)
|
|
switch (openMode)
|
|
{
|
|
{
|
|
case Read:
|
|
case Read:
|
|
- handle = (void *)fopen(filename, "rb"); // read only
|
|
|
|
|
|
+ capability = FileRead;
|
|
|
|
+ filePointer = 0;
|
|
|
|
+ buffer = (U8*)_AndroidLoadInternalFile(filename, &size);
|
|
|
|
+ if (buffer == NULL)
|
|
|
|
+ currentStatus = UnknownError;
|
|
|
|
+ else
|
|
|
|
+ currentStatus = Ok;
|
|
|
|
+ return currentStatus;
|
|
break;
|
|
break;
|
|
case Write:
|
|
case Write:
|
|
handle = (void *)fopen(filename, "wb"); // write only
|
|
handle = (void *)fopen(filename, "wb"); // write only
|
|
@@ -794,7 +831,7 @@ bool Platform::isFile(const char *path)
|
|
if (!path || !*path)
|
|
if (!path || !*path)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (isCachePath(path))
|
|
|
|
|
|
+ if (isCachePath(path) || isUserDataPath(path))
|
|
{
|
|
{
|
|
// make sure we can stat the file
|
|
// make sure we can stat the file
|
|
struct stat statData;
|
|
struct stat statData;
|
|
@@ -824,7 +861,7 @@ bool Platform::isDirectory(const char *path)
|
|
if (!path || !*path)
|
|
if (!path || !*path)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- if (isCachePath(path))
|
|
|
|
|
|
+ if (isCachePath(path) || isUserDataPath(path))
|
|
{
|
|
{
|
|
// make sure we can stat the file
|
|
// make sure we can stat the file
|
|
struct stat statData;
|
|
struct stat statData;
|
|
@@ -847,7 +884,7 @@ S32 Platform::getFileSize(const char* pFilePath)
|
|
if (!pFilePath || !*pFilePath)
|
|
if (!pFilePath || !*pFilePath)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
- if (isCachePath(pFilePath))
|
|
|
|
|
|
+ if (isCachePath(pFilePath) || isUserDataPath(pFilePath))
|
|
{
|
|
{
|
|
struct stat statData;
|
|
struct stat statData;
|
|
if( stat(pFilePath, &statData) < 0 )
|
|
if( stat(pFilePath, &statData) < 0 )
|
|
@@ -899,7 +936,7 @@ inline bool isGoodDirectoryCache(dirent* entry)
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
bool Platform::hasSubDirectory(const char *path)
|
|
bool Platform::hasSubDirectory(const char *path)
|
|
{
|
|
{
|
|
- if (isCachePath(path))
|
|
|
|
|
|
+ if (isCachePath(path) || isUserDataPath(path))
|
|
{
|
|
{
|
|
DIR *dir;
|
|
DIR *dir;
|
|
dirent *entry;
|
|
dirent *entry;
|
|
@@ -1091,7 +1128,7 @@ bool recurseDumpDirectoriesCache(const char *basePath, const char *path, Vector<
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
|
|
bool Platform::dumpDirectories(const char *path, Vector<StringTableEntry> &directoryVector, S32 depth, bool noBasePath)
|
|
{
|
|
{
|
|
- if (isCachePath(path))
|
|
|
|
|
|
+ if (isCachePath(path) || isUserDataPath(path))
|
|
{
|
|
{
|
|
PROFILE_START(dumpDirectories);
|
|
PROFILE_START(dumpDirectories);
|
|
|
|
|
|
@@ -1247,7 +1284,7 @@ static bool recurseDumpPathCache(const char* curPath, Vector<Platform::FileInfo>
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
bool Platform::dumpPath(const char *path, Vector<Platform::FileInfo>& fileVector, S32 depth)
|
|
bool Platform::dumpPath(const char *path, Vector<Platform::FileInfo>& fileVector, S32 depth)
|
|
{
|
|
{
|
|
- if (isCachePath(path))
|
|
|
|
|
|
+ if (isCachePath(path) || isUserDataPath(path))
|
|
{
|
|
{
|
|
PROFILE_START(dumpPath);
|
|
PROFILE_START(dumpPath);
|
|
const S32 len = dStrlen(path) + 1;
|
|
const S32 len = dStrlen(path) + 1;
|