Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore hidden files and directories with obj-c

How can I execute hidden directory and files programmatically?

i.e: .DS_Store

I want to execute all the hidden files and directories which start with the "."

Thank you for your help in advance

like image 749
Studie Avatar asked Nov 08 '11 16:11

Studie


1 Answers

Use NSFileManager with NSDirectoryEnumerationSkipsHiddenFiles.

For example:

NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *theFiles =  [fileManager contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Users/Anne/Desktop/"]
                                includingPropertiesForKeys:[NSArray arrayWithObject:NSURLNameKey]
                                                   options:NSDirectoryEnumerationSkipsHiddenFiles
                                                     error:nil];

NSLog(@"%@",theFiles);
like image 141
Anne Avatar answered Oct 08 '22 04:10

Anne