Unified Carbon interface for extended attributes?
Unified Carbon interface for extended attributes?
- Subject: Unified Carbon interface for extended attributes?
- From: James Bucanek <email@hidden>
- Date: Mon, 18 Feb 2008 11:59:49 -0700
Greetings,
I'm writing (wrote) a backup utility. One of my goals is to
preserve and restore all file metadata.
I'm using Carbon the APIs (FSRefs) to iterate and read the
files, and I can't find a unified API for capturing and
restoring all of a file's extended attributes.
The extended attributes seem to be an ad hoc collection of
various file properties, some of which overlap existing file
attributes, while others don't. The extended attributes returned
by the BSD APIs (getxattr()) aren't consistent with the
attributes returned by the Carbon APIs (LSCopyItemAttributes).
This has come up because Apple recently defined the
kLSItemQuarantineProperties property, which I'd like to capture
and restore as appropriate. This appears as a new attribute in
both LSCopyItemAttributes and listxattrs(), but doesn't overlap
any other API.
Here's some of what I'm trying to deal with:
- Some attributes overlap existing file attributes. The extended
Finder information attribute (com.apple.FinderInfo) duplicates
the data in the FSCatalogInfo.finderInfo. Setting or getting
finderInfo via FSGetCatalogInfo/FSSetCatalogInfo is equivalent
to accessing com.apple.Finder via getxattr().
- Some attributes returned by FSCopyItemAttributes don't appear
as extended attributes when the file is queried using
getxattr(). For example, kLSItemExtension will return an item's
filename extension, while getxattr() returns nothing.
- Developers are free to create their own extended attributes
and attach them to files. The listxattr() interface will list
all extended attributes for a file, but FSCopyItemAttribute(s)
only accepts an a priori set of defined attribute names. There's
no Carbon interface that I can find that will list or return all
known attributes for a file.
So what I really want to discover (efficiently!) is all of the
extended attributes associated with a file. Ideally, I don't
want extended attributes that duplicate file attributes
manipulated via existing APIs (FinderInfo, type/creator,
extension, Display name, etc.).
It seems I can do this with listxattrs()/getxattr(), but that
API is expensive for me because the files are being scanned via
FSGetCatalogInfoBulk(). I'd have to convert every FSRef to a BSD
path and then use listxattrs() to probe it. This wouldn't be too
bad if there was some flag or bit in FSCatInfo that a file had
one or more extended attributes, but I can't find any such indicator.
I thought I could use LSCopyItemAttributes, but this only
returns pre-determined attributes, some of which are virtual,
and you can't arbitrarily set them (there's no
LSSetItemAttribute that I can find).
Any suggestions?
--
James Bucanek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden