Index: src/OFFileIRIHandler.m ================================================================== --- src/OFFileIRIHandler.m +++ src/OFFileIRIHandler.m @@ -28,11 +28,11 @@ #include "platform.h" #ifdef HAVE_SYS_STAT_H # include #endif #include -#ifdef OF_LINUX +#if defined(OF_LINUX) || defined(OF_MACOS) # include #endif #ifdef OF_WINDOWS # include #endif @@ -540,25 +540,33 @@ } # endif } #endif -#ifdef OF_LINUX +#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES static void setExtendedAttributes(OFMutableFileAttributes attributes, OFIRI *IRI) { OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; +# if defined(OF_LINUX) ssize_t size = llistxattr(cPath, NULL, 0); +# elif defined(OF_MACOS) + ssize_t size = listxattr(cPath, NULL, 0, XATTR_NOFOLLOW); +# endif char *list = OFAllocMemory(1, size); OFMutableArray *names = nil; @try { char *name; +# if defined(OF_LINUX) if ((size = llistxattr(cPath, list, size)) < 0) +# elif defined(OF_MACOS) + if ((size = listxattr(cPath, list, size, XATTR_NOFOLLOW)) < 0) +# endif return; names = [OFMutableArray array]; name = list; @@ -682,11 +690,11 @@ #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS if (S_ISLNK(s.st_mode)) setSymbolicLinkDestinationAttribute(ret, IRI); #endif -#ifdef OF_LINUX +#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES setExtendedAttributes(ret, IRI); #endif objc_autoreleasePoolPop(pool); @@ -1533,24 +1541,34 @@ objc_autoreleasePoolPop(pool); return true; } -#ifdef OF_LINUX -- (OFData *)extendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI +#ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES +- (OFData *)extendedAttributeDataForName: (OFString *)name + ofItemAtIRI: (OFIRI *)IRI { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; const char *cName = [name cStringWithEncoding: encoding]; +# if defined(OF_LINUX) ssize_t size = lgetxattr(cPath, cName, NULL, 0); +# elif defined(OF_MACOS) + ssize_t size = getxattr(cPath, cName, NULL, 0, 0, XATTR_NOFOLLOW); +# endif void *value = OFAllocMemory(1, size); OFData *data; @try { +# if defined(OF_LINUX) if ((size = lgetxattr(cPath, cName, value, size)) < 0) +# elif defined(OF_MACOS) + if ((size = getxattr(cPath, cName, value, size, 0, + XATTR_NOFOLLOW)) < 0) +# endif @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; data = [OFData dataWithItems: value count: size]; @@ -1571,13 +1589,19 @@ { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; +# if defined(OF_LINUX) if (lsetxattr([path cStringWithEncoding: encoding], [name cStringWithEncoding: encoding], data.items, data.count * data.itemSize, 0) != 0) { +# elif defined(OF_MACOS) + if (setxattr([path cStringWithEncoding: encoding], + [name cStringWithEncoding: encoding], data.items, + data.count * data.itemSize, 0, XATTR_NOFOLLOW) != 0) { +# endif int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI @@ -1594,12 +1618,17 @@ { void *pool = objc_autoreleasePoolPush(); OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; +# if defined(OF_LINUX) if (lremovexattr([path cStringWithEncoding: encoding], [name cStringWithEncoding: encoding]) != 0) { +# elif defined(OF_MACOS) + if (removexattr([path cStringWithEncoding: encoding], + [name cStringWithEncoding: encoding], XATTR_NOFOLLOW) != 0) { +# endif int errNo = errno; /* TODO: Add an attribute (prefix?) for extended attributes? */ @throw [OFSetItemAttributesFailedException exceptionWithIRI: IRI Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -31,11 +31,11 @@ # define OF_FILE_MANAGER_SUPPORTS_LINKS # endif # if (defined(OF_HAVE_SYMLINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS) # define OF_FILE_MANAGER_SUPPORTS_SYMLINKS # endif -# ifdef OF_LINUX +# if defined(OF_LINUX) || defined(OF_MACOS) # define OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES # endif #endif @class OFArray OF_GENERIC(ObjectType);