Touch a file - update it by changing the timestamp

Is there an effective way to update the last changed file property on the iPad file system, i.e. unix touch commands?

I looked at NSFileManager but no luck.

+6
objective-c iphone ipad
source share
2 answers

OK, so I answer my question right after I asked him: (

I found the setAttributes: ofItemAtPath: error: method in the NSFileManager class, and I can specify the changed timestamp there.

Thanks anyway!

+10
source share

To update the modification timestamp (which, for example, is shown at the output of ls -l ) filePath , now:

 NSError* error; NSFileManager* fileManager = [NSFileManager defaultManager]; if (![fileManager setAttributes:@{NSFileModificationDate:[NSDate date]} ofItemAtPath:filePath error:&error]) { NSLog(@"Couldn't update modification date: %@", error); } 
+6
source share

All Articles