Re: Backup/Restore of Alias files
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com rohan a wrote: Hello, I am writing a backup/restore utility on Mac OS X and faced some issues with Alias files. Alias files resolve their targets using the target pathname and then its unique File ID. Sort of. Aliases can store either or both. The default one they use - if both are present - depends on the OS version, and can be overridden by any individual developer. Oh, and they can be relative to some other file. Consider I have an alias file named *alias* pointing to *user.txt*. If I backup and restore both *alias* and *user.txt*, then *alias* will no longer point to *user.txt*(If I restore it to some other location) as the file ID of *user.txt* will have changed after the restore(because I am creating a new file). True. It is, as far as the OS is concerned, a completely different file. The fact that the content and leaf node name happen to match something else is not meaningful (or even known). Even if I restore it to the same location, it will point to the right file only till user.txt is moved to some other location. Not quite correct. If you restore it to the correct location and then the alias is resolved, the resolution routine will note that the alias record was stale and has been updated. Any sane software (and I think Finder counts in this specific instance) will then re-save the alias record back to the alias file. Here, the alias files will start pointing to arbitrary files which will be a complete mess. Does Mac OS X provide any API's to deal with Alias files. An alias file is a file with an empty data fork and a resource fork that contains an alias record (resource type 'alis' with ID 0) and custom icons pulled from the target. The type and creator are set to that of the target file, and there's a metadata flag that says it's an alias. If the target is an app, the type code should be 'adrp' instead of 'APPL.' Officially there is no direct means to create them; you do so by sending AppleEvents to Finder. I looked up the Alias manager reference which says that it can only create "alias records" and not "alias files" How do I deal with this problem? Creatively. There really is no supported way to achieve what you want. Probably the one that sucks least is to not actually back up aliases as normal file system objects. Instead build your own record that indicates which item in your backup set they reference. If you end up restoring both, you can restore the target first and then "restore" the alias by constructing a new one based on the above information. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Gregory Weston