Index: src/OFFileIRIHandler.m ================================================================== --- src/OFFileIRIHandler.m +++ src/OFFileIRIHandler.m @@ -1575,10 +1575,32 @@ if (lsetxattr([path cStringWithEncoding: encoding], [name cStringWithEncoding: encoding], data.items, data.count * data.itemSize, 0) != 0) { int errNo = errno; + + /* TODO: Add an attribute (prefix?) for extended attributes? */ + @throw [OFSetItemAttributesFailedException + exceptionWithIRI: IRI + attributes: [OFDictionary dictionary] + failedAttribute: @"" + errNo: errNo]; + } + + objc_autoreleasePoolPop(pool); +} + +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI +{ + void *pool = objc_autoreleasePoolPush(); + OFString *path = IRI.fileSystemRepresentation; + OFStringEncoding encoding = [OFLocale encoding]; + + if (lremovexattr([path cStringWithEncoding: encoding], + [name cStringWithEncoding: encoding]) != 0) { + int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI attributes: [OFDictionary dictionary] Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -684,12 +684,14 @@ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** - * @brief Returns the extended attribute data for the specified name for the - * specified path. + * @brief Returns the extended attribute data for the specified name of the + * item at the specified path. + * + * This method is not available on some systems. * * @param name The name of the extended attribute * @param path The path of the item to return the extended attribute from * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed @@ -699,12 +701,12 @@ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** - * @brief Returns the extended attribute data for the specified name for the - * specified IRI. + * @brief Returns the extended attribute data for the specified name of the + * item at the specified IRI. * * This method is not available for all IRIs. * * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from @@ -718,14 +720,14 @@ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** - * @brief Sets the extended attribute data for the specified name for the - * specified IRI. + * @brief Sets the extended attribute data for the specified name of the item + * at the specified path. * - * This method is not available for all IRIS. + * This method is not available on some systems. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param path The path of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute @@ -737,14 +739,14 @@ forName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** - * @brief Sets the extended attribute data for the specified name for the - * specified IRI. + * @brief Sets the extended attribute data for the specified name of the item + * at the specified IRI. * - * This method is not available for all IRIS. + * This method is not available for all IRIs. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute @@ -755,10 +757,46 @@ * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; + +#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES +/** + * @brief Removes the extended attribute for the specified name wof the item at + * the specified path. + * + * This method is not available on some systems. + * + * @param name The name of the extended attribute to remove + * @param path The path of the item to remove the extended attribute from + * @throw OFSetItemAttributesFailedException Removing the extended attribute + * failed + * @throw OFNotImplementedException Removing extended attributes is not + * implemented for the specified item + */ +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtPath: (OFString *)path; +#endif + +/** + * @brief Removes the extended attribute for the specified name wof the item at + * the specified IRI. + * + * This method is not available for all IRIs. + * + * @param name The name of the extended attribute to remove + * @param IRI The IRI of the item to remove the extended attribute from + * @throw OFSetItemAttributesFailedException Removing the extended attribute + * failed + * @throw OFUnsupportedProtocolException No handler is registered for the IRI's + * scheme + * @throw OFNotImplementedException Removing extended attributes is not + * implemented for the specified item + */ +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI; @end @interface OFDictionary (FileAttributes) /** * @brief The @ref OFFileSize key from the dictionary. Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -948,10 +948,35 @@ forName: name ofItemAtIRI: [OFIRI fileIRIWithPath: path]]; objc_autoreleasePoolPop(pool); } #endif + +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI +{ + OFIRIHandler *IRIHandler; + + if (IRI == nil) + @throw [OFInvalidArgumentException exception]; + + if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) + @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; + + [IRIHandler removeExtendedAttributeForName: name ofItemAtIRI: IRI]; +} + +#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtPath: (OFString *)path +{ + void *pool = objc_autoreleasePoolPush(); + [self removeExtendedAttributeForName: name + ofItemAtIRI: [OFIRI fileIRIWithPath: path]]; + objc_autoreleasePoolPop(pool); +} +#endif @end @implementation OFDefaultFileManager - (instancetype)autorelease { Index: src/OFIRIHandler.h ================================================================== --- src/OFIRIHandler.h +++ src/OFIRIHandler.h @@ -292,42 +292,62 @@ * scheme */ - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** - * @brief Returns the extended attribute with the specified name for the - * specified IRI. + * @brief Returns the extended attribute data for the specified name of the + * item at the specified IRI. * * This method is not available for all IRIs. * * @param name The name of the extended attribute * @param IRI The IRI of the item to return the extended attribute from * @throw OFGetItemAttributesFailedException Getting the extended attribute * failed + * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's + * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; /** - * @brief Sets the extended attribute data for the specified name for the - * specified IRI. + * @brief Sets the extended attribute data for the specified name of the item + * at the specified IRI. * - * This method is not available for all IRIS. + * This method is not available for all IRIs. * * @param data The data for the extended attribute * @param name The name of the extended attribute * @param IRI The IRI of the item to set the extended attribute on * @throw OFSetItemAttributesFailedException Setting the extended attribute * failed - * @throw OFUnsupportedProtocolException No handler is registered for the IRI's + * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; + +/** + * @brief Removes the extended attribute for the specified name wof the item at + * the specified IRI. + * + * This method is not available for all IRIs. + * + * @param name The name of the extended attribute to remove + * @param IRI The IRI of the item to remove the extended attribute from + * @throw OFSetItemAttributesFailedException Removing the extended attribute + * failed + * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's + * scheme + * @throw OFNotImplementedException Removing extended attributes is not + * implemented for the specified item + */ +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI; @end OF_ASSUME_NONNULL_END Index: src/OFIRIHandler.m ================================================================== --- src/OFIRIHandler.m +++ src/OFIRIHandler.m @@ -222,8 +222,14 @@ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { + OF_UNRECOGNIZED_SELECTOR +} + +- (void)removeExtendedAttributeForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI +{ OF_UNRECOGNIZED_SELECTOR } @end