On a Mac, When I zip and unzip files using finder or using zip/ditto from command line, I lose the creation date of the files/folders and the creation date is automatically set same as the modification date. How can I preserve the creation date?
2 Answers
Get file creation date.
- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
zip
- set file creation date.
Use tar with the p(reserve) option:
tar -x -p -v -j -f arhive.tbz
-
Is tar on OSX different from GNU tar? For the latter the
p
option is--preserve-permissions
.– mpyCommented Mar 17, 2013 at 12:07 -
developer.apple.com/library/mac/#documentation/Darwin/Reference/… Commented Mar 17, 2013 at 19:26
-
-P
preserves absolute path names and has nothing to do with time information.tar
always stores owner and permission information by default, and restores it again.– Daniel Beck ♦Commented Mar 17, 2013 at 19:29 -
1
-p
tries to preserves permissions (i.e. file mode, ACLs) when restoring. It's only applicable to-x
(extraction). Plain oldtar cf
andtar xf
preserve modification times already, no additional args needed. AFAIK creation date cannot be influenced.– Daniel Beck ♦Commented Mar 17, 2013 at 19:32