EDIT_v002
I have had a look at all the comments and I am starting to see what I should be doing. To that end I have modified my code (see below) I have changed newPath to a NSString, removed the [[alloc] init] and the end [release] as its now handled by the system. I am using stringByAppendingPathComponent, letting it add a separator between rootPath and fileName before its assigned to the NSString. It does work, and I ran it through the static analyser with no problems.
// ------------------------------------------------------------------- **
// DISC: FILEWALKER ..... (cocoa_fileWalker.m)
// DESC: List all "*.png" files in specified directory
// ------------------------------------------------------------------- **
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *fileName;
NSDictionary *attrDir;
NSError *myError;
NSNumber *fileSize;
NSFileManager *manager = [NSFileManager defaultManager];
NSString *rootPath = [@"~/Pictures/Ren/PRMan" stringByExpandingTildeInPath];
NSString *newPath;
NSLog(@"Home: %@",rootPath);
for(fileName in [manager enumeratorAtPath:rootPath]){
if ([[fileName pathExtension] isEqual:@"png"]) {
newPath = [rootPath stringByAppendingPathComponent:fileName];
attrDir = [manager attributesOfItemAtPath:newPath error:&myError];
fileSize = [attrDir objectForKey: @"NSFileSize"];
NSLog(@"File: %@ Size: %@", newPath, fileSize);
}
}
[pool drain];
return 0;
}
// ------------------------------------------------------------------- **
gary