Modified system path defaults to utilize the User vs Res architecture. After reading some comments of the forum I realized I had implemented this all according to 0.16's design and not the new split architecture. All 'core_' zip files are now placed under 'Res' as before, but any other zip file will be put under the 'User' directory
This commit is contained in:
@@ -107,11 +107,11 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
||||
|
||||
#ifdef IOS
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString: @"/Res"];
|
||||
NSString *documentsDirectory = [paths objectAtIndex:0];
|
||||
|
||||
userPath = [documentsDirectory cStringUsingEncoding:1];
|
||||
userPath += "/";
|
||||
systemPath = "";
|
||||
userPath = [[documentsDirectory stringByAppendingString: @"/User/"] cStringUsingEncoding:1];
|
||||
systemPath = [[documentsDirectory stringByAppendingString: @"/Res/"] cStringUsingEncoding:1];
|
||||
|
||||
#elif defined (ANDROID)
|
||||
userPath = "/sdcard/Wagic/Res/";
|
||||
systemPath = "";
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
check for any zip files dropped into the documents directory. If so move them into the "Res" directory.
|
||||
check for any zip files dropped into the documents directory. If so move them into the "User" directory.
|
||||
check for a "core" zip file in the Res directory. If it exists, then return YES. Otherwise, return NO.
|
||||
*/
|
||||
- (BOOL) hasResourceFiles
|
||||
@@ -32,18 +32,26 @@
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString *docsPath = [paths objectAtIndex: 0];
|
||||
NSArray *docsPathContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: docsPath error:nil];
|
||||
NSArray *resourceZipFiles = [docsPathContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.zip'"]];
|
||||
NSCompoundPredicate *compoundPredicate = [[NSCompoundPredicate alloc] initWithType:NSAndPredicateType subpredicates: [NSArray arrayWithObjects: [NSPredicate predicateWithFormat:@"self ENDSWITH '.zip'"], [NSPredicate predicateWithFormat:@"NOT (self BEGINSWITH 'core_')"], nil]];
|
||||
|
||||
NSArray *resourceZipFiles = [docsPathContents filteredArrayUsingPredicate: compoundPredicate];
|
||||
NSString *userPath = [NSString stringWithFormat: @"%@/User", docsPath];
|
||||
NSString *resPath = [NSString stringWithFormat: @"%@/Res", docsPath];
|
||||
NSError *error = nil;
|
||||
|
||||
if ( ([resourceZipFiles count] > 0 ) && ![fileManager fileExistsAtPath: userPath] )
|
||||
[fileManager createDirectoryAtPath: userPath withIntermediateDirectories: YES attributes:nil error:nil ];
|
||||
|
||||
for (NSString *zipFile in resourceZipFiles)
|
||||
{
|
||||
NSString *oldPath = [NSString stringWithFormat: @"%@/%@", docsPath, zipFile];
|
||||
NSString *newPath = [NSString stringWithFormat: @"%@/%@", resPath, zipFile];
|
||||
NSString *newPath = [NSString stringWithFormat: @"%@/%@", userPath, zipFile];
|
||||
|
||||
[fileManager moveItemAtPath: oldPath toPath:newPath error: &error];
|
||||
if ( error != nil )
|
||||
{
|
||||
NSLog(@"Error happened while trying to move %@ to %@: \n%@", oldPath, newPath, [error localizedDescription]);
|
||||
error = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user