[futurebasic] Re: [FB] Sandboxing: Data migration fails

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2013 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Thu, 9 May 2013 19:01:16 -0400
I response to Brian, Rich asked:

> Icon Pallet requires the ability to read the file names of every folder on the hard drive.
> Do you think Apple will ever approve that?

Rich,

Are you simply reading the file names? Or are you performing a read-write?

I don't have time at this moment, but perhaps someone on the list would like to experiment with the following recursive code that may circumvent your problem by feeding it a root level path.

Ken

- (NSArray *)allFiles:(NSString *)startPath
    NSMutableArray * listing = [NSMutableArray array];
    NSArray * fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:aPath error:nil];
    if (!fileNames) return listing;
    for (NSString * file in fileNames) {
        NSString * absPath = [aPath stringByAppendingPathComponent:file];
        BOOL isDir = NO;
        if ([[NSFileManager defaultManager] fileExistsAtPath:absPath isDirectory:&isDir]) {
            if (isDir) {
                [listing addObject:absPath];
                [listing addObjectsFromArray:[self allFiles:absPath]];
            } else {
                [listing addObject:absPath];
            }
        }
    }
    return listing;
}