On Jun 28, 2014, at 11:28 AM, Dragan Milić <milke(a)mac.com> wrote:
> So, copyfile() function doesn’t restore the creation date of a copied file to original’s creation date. That’s understandable since there’s not really such timestamp metadata available in Darwin (ok, there is st_birthtime in 64-bit environment). However, I need copy functionality to restore the creation date as well.
>
> I can set creation date from Cocoa using -[NSURL setResourceValue:forKey:error:], where key=NSURLCreationDateKey, but I’m interested if there’s a way to do it without jumping into Cocoa and staying on the POSIX level. st_birthtime doesn’t seem settable, at least not with the utimes()/futimes() call.
Use setattrlist(2) to set ATTR_CMN_CRTIME
J
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
On sub 28.06.2014., at 20.41, Jens Alfke wrote:
> On Jun 28, 2014, at 11:28 AM, Dragan Milić <milke(a)mac.com> wrote:
>
>> I can set creation date from Cocoa using -[NSURL setResourceValue:forKey:error:], where key=NSURLCreationDateKey, but I’m interested if there’s a way to do it without jumping into Cocoa and staying on the POSIX level. st_birthtime doesn’t seem settable, at least not with the utimes()/futimes() call.
>
> I don’t know about POSIX, but you can at least do it in C by calling the CoreServices function FSSetCatalogInfo.
No, I don’t want to use deprecated APIs. The whole point of rewriting an application and going for copyfile() was to get rid of the deprecated File Manager API. I know I can also use Core Foundation CFURL’s CFURLSetResourcePropertyForKey(), but that’s essentially the same using its Cocoa companion. I’m interested in staying at POSIX level.
-- Dragan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
So, copyfile() function doesn’t restore the creation date of a copied file to original’s creation date. That’s understandable since there’s not really such timestamp metadata available in Darwin (ok, there is st_birthtime in 64-bit environment). However, I need copy functionality to restore the creation date as well.
I can set creation date from Cocoa using -[NSURL setResourceValue:forKey:error:], where key=NSURLCreationDateKey, but I’m interested if there’s a way to do it without jumping into Cocoa and staying on the POSIX level. st_birthtime doesn’t seem settable, at least not with the utimes()/futimes() call.
-- Dragan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwin-dev(a)lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.ap…
This email sent to site_archiver(a)lists.apple.com