NSFileWrapper (directory) and internal folders
NSFileWrapper (directory) and internal folders
- Subject: NSFileWrapper (directory) and internal folders
- From: Rick Langschultz <email@hidden>
- Date: Thu, 20 Dec 2007 21:24:29 -0600
Hello everyone,
I have a NSFileWrapper which needs to look for a contents folder
inside an NSFileWrapper. The wrapper is a directory wrapper and
contains a properties.xml file, and a Contents file with many internal
files. The problem is I can't use NSDirectoryEnumerator to open the
Contents folder and load the files into an NSMutableArray.
Am I approaching this the correct way? I tried looking in google.com/
codesearch for an example of this. I have even tried using the BigShow
sample project from bignerdranch.com to guide me along.
Can someone maybe point to a good sample of how I can accomplish this.
Posted is my code to open the NSFileWrapper. Feel free to use it if
your project needs something like this.
- (BOOL)loadFileWrapperRepresentation:(NSFileWrapper *)wrapper ofType:
(NSString *)aType {
NSDictionary *wrappers = [wrapper fileWrappers];
NSArray *files = [wrappers allKeys];
NSXMLDocument *propertiesDocument;
files = [files
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
int countOfFiles;
for (countOfFiles = 0; countOfFiles < [files count]; countOfFiles++) {
NSString *fileName = [files objectAtIndex:countOfFiles];
if ([fileName isEqualToString:@"properties.xml"]) {
NSLog(@"Loaded properties.xml file");
NSURL *propertiesDocumentURL = [NSURL fileURLWithPath:fileName];
propertiesDocument = [[NSXMLDocument alloc]
initWithContentsOfURL:propertiesDocumentURL
options:NSXMLNodePreserveAll error:nil];
} else if ([fileName isEqualToString:@"Contents"]) {
NSLog(@"Found Contents folder");
// NSDirectoryEnumerator *directoryEnum = [[NSFileManager
defaultManager] enumeratorAtPath:fileName];
// This doesn't return any internal results. Added to TDManager.
} else {
return NO;
}
}
return YES;
}
Any help would be appreciated.
Thanks,
Rick L.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden