PDA

View Full Version : Handling Aliases using POSIX API's




info1686
Jan 22, 2009, 12:06 AM
Hi all,
I am writing a small backup utility in Mac OS X using C.
I am stuck up with aliases and trying to find out how they should be backed up.

I read that the aliases are empty files and they store their content in the resource forks
I also read that aliases need to be handled using the Alias Manager / Carbon API
In order to backup aliases, should it suffice if I read the data and resource forks of the alias and backup them up?

On restoring the alias along with its resource fork, will it again be interpreted as an alias ?

Also, I will be backing up resource forks of all files hence I need not identify aliases seperately



gnasher729
Jan 22, 2009, 05:46 AM
Hi all,
I am writing a small backup utility in Mac OS X using C.
I am stuck up with aliases and trying to find out how they should be backed up.

I read that the aliases are empty files and they store their content in the resource forks
I also read that aliases need to be handled using the Alias Manager / Carbon API
In order to backup aliases, should it suffice if I read the data and resource forks of the alias and backup them up?

On restoring the alias along with its resource fork, will it again be interpreted as an alias ?

Also, I will be backing up resource forks of all files hence I need not identify aliases seperately

Copying data fork and resource fork is essential; you also need to copy all the finder flags. That should be enough to turn alias files into alias files. It won't handle symbolic links.

info1686
Jan 22, 2009, 05:50 AM
Ok, copying of data and resource forks can be done using the standard API's
But what about the Finder flags?
How do I get their values?

Can I use standard API's or only the Carbon API's?

Why I am asking this is because I feel that use of Carbon API just for aliases is a big overhead

Thanks in advance

info1686
Jan 22, 2009, 07:13 AM
I found HFS+ disk format in the file /usr/include/hfs/hfs_format.h
It declares a number of structures giving volume info, block info, finder info etc.
However, it does not declare any API's

So, how am I supposed to use all those structures?
Where can I find the necessary API's?

Sayer
Jan 22, 2009, 09:18 AM
I found HFS+ disk format in the file /usr/include/hfs/hfs_format.h
It declares a number of structures giving volume info, block info, finder info etc.
However, it does not declare any API's

So, how am I supposed to use all those structures?
Where can I find the necessary API's?

In the Carbon framework (or maybe CarbonCore specifically). Mac OS X is not just another Unix OS. If you don't back up all files completely you will break something while trying to restore the files, which kinda defeats the purpose of backing them up to begin with.

I wrote a software installer years ago, it is not just a simple matter of copying files.