This requirement is very specific to read directory contents along with date modified for all sub files and folders. In windows we have some API’s but I didn’t find similar function in Mac OS development. I searched for this where I found that NSFileManager can be used for this.I found one place where I can get the path contents under Documents directory.
Here is the piece of code code which I have.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSFileManager *manager = [[NSFileManager alloc] init];
NSDirectoryEnumerator *fileEnumerator = [manager enumeratorAtPath:documentsPath];
for (NSString *filename in fileEnumerator) {
// Do something with file
NSLog(@"file name : %@",filename );
}
But my requirement is to find the contents under any path on machine with the date modified for all sub files and a folders in it.Please guide me on it.
Thanks,
Tausif.
Apple has a code sample demonstrating how to do this:
Basically this code enumerates the
directoryPathand checks if the file or directory has been modified within the last 24 hours.