FROM : Steve Christensen
DATE : Tue Jul 11 22:59:47 2006
On Jul 11, 2006, at 1:47 PM, Chris Suter wrote:
> On 12/07/2006, at 5:40 AM, Steve Christensen wrote:
>
>> If you're trying to determine if a file contains resources (in
>> either fork), you'd need to try opening the fork(s) using Resource
>> Manager APIs, which would be considerably more time consuming.
>
> I don't believe you need to open the file to find out if a file
> contains resources.
>
> You can use the BSD function getattrlist. On Tiger you can also the
> BSD extended attribute API. See man pages for getattrlist and
> listxattr. The extended attribute name for the resource fork is
> defined by the constant XATTR_RESOURCEFORK_NAME (defined in /usr/
> include/sys/xattr.h).
>
> You can also access resource forks as if they are regular files by
> appending "/..namedfork/rsrc" to the name of the file. You may need
> to check when this was introduced if you need it to work on older
> systems.
The reason why I mentioned opening the resource file using Resource
Manager APIs is that there is nothing in the File Manager APIs to
prevent you from creating a resource fork for a file and filling it
with whatever data you want.
The resource fork is an HFS file system feature that knows nothing of
resource -files-. That there are such special file formats called
"resource files" is by convention only and is managed by the Resource
Manager, sitting on top of the file system. It's really no different
from having a file called foo.pdf that contains a Word document;
while there is likely to be some confusion, the file system doesn't
prevent you from doing it.
steve
DATE : Tue Jul 11 22:59:47 2006
On Jul 11, 2006, at 1:47 PM, Chris Suter wrote:
> On 12/07/2006, at 5:40 AM, Steve Christensen wrote:
>
>> If you're trying to determine if a file contains resources (in
>> either fork), you'd need to try opening the fork(s) using Resource
>> Manager APIs, which would be considerably more time consuming.
>
> I don't believe you need to open the file to find out if a file
> contains resources.
>
> You can use the BSD function getattrlist. On Tiger you can also the
> BSD extended attribute API. See man pages for getattrlist and
> listxattr. The extended attribute name for the resource fork is
> defined by the constant XATTR_RESOURCEFORK_NAME (defined in /usr/
> include/sys/xattr.h).
>
> You can also access resource forks as if they are regular files by
> appending "/..namedfork/rsrc" to the name of the file. You may need
> to check when this was introduced if you need it to work on older
> systems.
The reason why I mentioned opening the resource file using Resource
Manager APIs is that there is nothing in the File Manager APIs to
prevent you from creating a resource fork for a file and filling it
with whatever data you want.
The resource fork is an HFS file system feature that knows nothing of
resource -files-. That there are such special file formats called
"resource files" is by convention only and is managed by the Resource
Manager, sitting on top of the file system. It's really no different
from having a file called foo.pdf that contains a Word document;
while there is likely to be some confusion, the file system doesn't
prevent you from doing it.
steve
| Related mails | Author | Date |
|---|---|---|
| Scott Ellsworth | Jul 11, 19:50 | |
| Ryan Britton | Jul 11, 20:31 | |
| Scott Ellsworth | Jul 11, 21:14 | |
| Steve Christensen | Jul 11, 21:40 | |
| Chris Suter | Jul 11, 22:47 | |
| Steve Christensen | Jul 11, 22:59 | |
| Scott Ellsworth | Jul 11, 23:01 | |
| Uli Kusterer | Jul 12, 00:30 | |
| Steve Christensen | Jul 12, 01:11 |






Cocoa mail archive

