SOExtendedAttributes Hierarchy
30 |Category References
40 |-
41 |
42 |
- NSURL(SOExtendedAttributes) 43 | 44 |
| Declared in | 133 |NSURL+SOExtendedAttributes.h NSURL+SOExtendedAttributes.m |
134 |
The SOExtendedAttributes category on NSURL enables retrieving and manipulating the extended attributes on a file system item.
144 | 145 |These methods are valid only on file URLs. An NSInternalInconsistencyException is thrown if invoked an a non-file URL.
146 | 147 |Internally, they’re implemented using listxattr(2), getxattr(2), setxattr(2), and removexattr(2).
148 | 149 |Compatibility
150 | 151 |SOExtendedAttributes is compatible with Mac OS X 10.6+ and iOS 5. The clang compiler is required. The source file NSURL+SOExtendedAttributes.m must be compiled with ARC enabled. For an alternate Cocoa implementation compatible with Mac OS X 10.4 and greater, see UKXattrMetadataStore.
Symbolic links
154 | 155 |These methods act on the explicitly given URL. If that URL is to a symbolic link, you’ll be manipulating extended attributes on the symlink, not its original file. Use -URLByResolvingSymlinksInPath to obtain a URL for which points to the original file system item.
Use with iCloud Backup
158 | 159 |Note 2013-06-03: see Apple Tech QA 1719 for the recommended way to mark a file for exclusion from iCloud backup. Hint: don’t use the @“com.apple.MobileMeBackup” extended attribute.
160 | 161 |Error Reporting
162 | 163 |SOExtendedAttributes reports errors under the domain SOExtendedAttributesErrorDomain. When multiple errors occur on getting or setting extended attributes in a batch, those errors are collected in an NSArray and reported via error’s -userInfo dictionary under SOUnderlyingErrorsKey.
– maximumExtendedAttributesSize
182 | The maximum size in bytes for an extended attribute on the receiver.
183 | 184 | 185 | 186 |– extendedAttributesWithError:
197 | Returns the extended attributes of the file system item at this URL.
198 | 199 | 200 | 201 |– setExtendedAttributes:error:
204 | Sets the extended attribute values for the given URL.
205 | 206 | 207 | 208 |– hasExtendedAttributeWithName:
219 | Returns YES if the file system item has the named attribute.
220 | 221 | 222 | 223 |– valueOfExtendedAttributeWithName:error:
226 | Returns the value of the named extended attribute from this file system item.
227 | 228 | 229 | 230 |– setExtendedAttributeValue:forName:error:
233 | Set the value of the named extended attribute.
234 | 235 | 236 | 237 |– removeExtendedAttributeWithName:error:
248 | Removes the named extended attribute from this file system item.
249 | 250 | 251 | 252 |Returns the extended attributes of the file system item at this URL.
277 |- (NSDictionary *)extendedAttributesWithError:(NSError *__autoreleasing *)outErrorIf an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you’re not interested in error reporting.
An NSDictionary object that describes the extended attributes of the file system object, or nil if an error occurred.
298 |Return all extended attributes that the current user account has permission to access. Attributes will include the HFS compression extended attribute if present.
307 |NSURL+SOExtendedAttributes.hReturns YES if the file system item has the named attribute.
331 |- (BOOL)hasExtendedAttributeWithName:(NSString *)nameThe name of the extended attribute. Throws NSInvalidArgumentException if name is nil or empty.
YES if the named extended attribute is present on the URL; NO otherwise.
352 |Sometimes, you’re only interested in the presence or absence of an extended attribute on a given URL. E.g. @“com.apple.MobileMeBackup”.
361 |NSURL+SOExtendedAttributes.hThe maximum size in bytes for an extended attribute on the receiver.
385 |- (NSUInteger)maximumExtendedAttributesSizeThe maximum size in bytes for an extended attribute on the receiver.
396 |Uses pathconf(2) to determine the maximum number of bytes that an extended attribute can hold. This is a computed and approximate value because the system does not report a maximum extended attribute size directly; instead, it reports the number of bits by the file system object to used to hold the maximum extended attribute size.
405 | 406 |The reported maximum extended attribute size for HFS+ on Mac OS X 10.8 is 128KB (131072 bytes), but experimentally, it is actually 50 bytes less: 131022 bytes.
407 |NSURL+SOExtendedAttributes.hRemoves the named extended attribute from this file system item.
431 |- (BOOL)removeExtendedAttributeWithName:(NSString *)name error:(NSError *__autoreleasing *)outErrorThe name of the extended attribute. Throws NSInvalidArgumentException if name is nil or empty.
A pointer to an error object. On return, if an error has occurred, this pointer references an actual error object containing the error information. Pass NULL if you’re not interesting in error reporting.
YES if successfully removed or named attribute does not exist. NO if there was an error.
457 |NSURL+SOExtendedAttributes.hSet the value of the named extended attribute.
485 |- (BOOL)setExtendedAttributeValue:(id)value forName:(NSString *)name error:(NSError *__autoreleasing *)outErrorThe value to be set. Must be an instance of NSData, NSString, NSArray, NSDictionary, NSDate or NSNumber.
The name of the extended attribute. Throws NSInvalidArgumentException if name is nil or empty.
A pointer to an error object. On return, if an error has occurred, this pointer references an actual error object containing the error information. Pass NULL if you’re not interesting in error reporting.
YES if the given value was set; NO if there was an error.
516 |NSURL+SOExtendedAttributes.hSets the extended attribute values for the given URL.
544 |- (BOOL)setExtendedAttributes:(NSDictionary *)attributes error:(NSError *__autoreleasing *)outErrorThe extended attribute names and values to be set. All values be instances of NSData, NSString, NSArray, NSDictionary, NSDate or NSNumber.
If an error occurs, upon return contains an NSError object that describes the problem. Pass NULL if you’re not interested in error reporting.
YES if all given attribute values were set. NO if there was an error setting one or more of the values.
570 |The attributes dictionary parameter may contain any object value that can be encoded as a property list.
579 | 580 |If the attributes dictionary holds a value object that cannot be encoded as a plist, an NSError with code SOExtendedAttributesValueCantBeSerialized is returned via the outError parameter.
On error, one or more of the given extended attributes may have failed to be set. Any underlying errors are reported via the -userInfo dictionary as an NSArray under the key SOUnderlyingErrorsKey.
NSURL+SOExtendedAttributes.hReturns the value of the named extended attribute from this file system item.
607 |- (id)valueOfExtendedAttributeWithName:(NSString *)name error:(NSError *__autoreleasing *)outErrorThe name of the extended attribute. Throws NSInvalidArgumentException if name is nil or empty.
A pointer to an error object. On return, if an error has occurred, this pointer references an actual error object containing the error information. Pass NULL if you’re not interesting in error reporting.
An appropriate Foundation object holding the value, or nil if there was an error.
633 |NSURL+SOExtendedAttributes.h