Get all files on Mac by Wusheying
#import<Cocoa/Cocoa.h>
intMain (intargc,ConstChar* argv[]) {
Nsmutablearray*directorydict = [NsmutablearrayNew];
[DirectorydictAddObject:@{@ "url":[Nsurlurlwithstring:nshomedirectory()],
@ "id":@ (0)}];
NsintegerId =1;
while(directorydict.Count != 0) {
nsdictionary*info = [DirectorydictFirstobject];
[DirectorydictRemoveobject: info];
Nsdirectoryenumerator*directoryenumerator = [[NsfilemanagerDefaultmanager]
Enumeratoraturl: info[@ "url"]
Includingpropertiesforkeys:Nil Options:nsdirectoryenumerationskipshiddenfi Les ErrorHandler:Nil];
for(Nsurl*fileurlinchdirectoryenumerator) {
[Directoryenumeratorskipdescendants];
NSLog(@"%@", FileURL);
NSNumber*isdirectory=Nil;
Nserror*error=Nil;[FileURLgetresourcevalue: &isdirectory forkey:nsurlisdirectorykey error:&error]; if([IsdirectoryIsequalto:@YES]) {
[DirectorydictAddObject:@{@ "url": FileURL,
@ "id":@(Id)}];
}
id++;
}
info =Nil;
}
returnNsapplicationmain(argc, argv);}
Get all the files on your Mac