Overview
Comment: | Support for reading extended attributes on Linux |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
565d2b37634d35e4b3617dd622aab68c |
User & Date: | js on 2023-01-22 21:48:40 |
Other Links: | manifest | tags |
Context
2023-01-22
| ||
21:56 | Add missing #import to make GCC happy check-in: 260c9acb96 user: js tags: trunk | |
21:48 | Support for reading extended attributes on Linux check-in: 565d2b3763 user: js tags: trunk | |
2023-01-13
| ||
13:31 | OFNotificationCenter: Don't retain observer check-in: 5b5c12fa0b user: js tags: trunk | |
Changes
Modified src/OFFileIRIHandler.m from [a3dbfacaa2] to [36e6332bf0].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include "unistd_wrapper.h" #include "platform.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #include <sys/time.h> #ifdef OF_WINDOWS # include <utime.h> #endif #ifdef OF_DJGPP # include <syslimits.h> #endif #ifdef HAVE_PWD_H # include <pwd.h> #endif #ifdef HAVE_GRP_H # include <grp.h> #endif #import "OFFileIRIHandler.h" #import "OFArray.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFSystemInfo.h" | > > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include "unistd_wrapper.h" #include "platform.h" #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #include <sys/time.h> #ifdef OF_LINUX # include <sys/xattr.h> #endif #ifdef OF_WINDOWS # include <utime.h> #endif #ifdef OF_DJGPP # include <syslimits.h> #endif #ifdef HAVE_PWD_H # include <pwd.h> #endif #ifdef HAVE_GRP_H # include <grp.h> #endif #import "OFFileIRIHandler.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFFile.h" #import "OFFileManager.h" #import "OFIRI.h" #import "OFLocale.h" #import "OFNumber.h" #import "OFSystemInfo.h" |
︙ | ︙ | |||
533 534 535 536 537 538 539 540 541 542 543 544 545 546 | # undef slrb } @finally { CloseHandle(handle); } # endif } #endif @implementation OFFileIRIHandler + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | # undef slrb } @finally { CloseHandle(handle); } # endif } #endif #ifdef OF_LINUX static void setExtendedAttributes(OFMutableFileAttributes attributes, OFIRI *IRI) { OFString *path = IRI.fileSystemRepresentation; OFStringEncoding encoding = [OFLocale encoding]; const char *cPath = [path cStringWithEncoding: encoding]; ssize_t size = llistxattr(cPath, NULL, 0); char *list = OFAllocMemory(1, size); OFMutableArray *names = nil; @try { char *name; if ((size = llistxattr(cPath, list, size)) < 0) return; names = [OFMutableArray array]; name = list; while (size > 0) { size_t length = strlen(name); [names addObject: [OFString stringWithCString: name encoding: encoding length: length]]; name += length + 1; size -= length + 1; } } @finally { OFFreeMemory(list); } [attributes setObject: names forKey: OFFileExtendedAttributesNames]; } #endif @implementation OFFileIRIHandler + (void)initialize { #ifdef OF_WINDOWS HMODULE module; #endif |
︙ | ︙ | |||
637 638 639 640 641 642 643 644 645 646 647 648 649 650 | setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS if (S_ISLNK(s.st_mode)) setSymbolicLinkDestinationAttribute(ret, IRI); #endif objc_autoreleasePoolPop(pool); return ret; } - (void)of_setLastAccessDate: (OFDate *)lastAccessDate | > > > > | 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | setOwnerAndGroupAttributes(ret, &s); setDateAttributes(ret, &s); #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS if (S_ISLNK(s.st_mode)) setSymbolicLinkDestinationAttribute(ret, IRI); #endif #ifdef OF_LINUX setExtendedAttributes(ret, IRI); #endif objc_autoreleasePoolPop(pool); return ret; } - (void)of_setLastAccessDate: (OFDate *)lastAccessDate |
︙ | ︙ | |||
1484 1485 1486 1487 1488 1489 1490 1491 | errNo: errno]; #endif objc_autoreleasePoolPop(pool); return true; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | errNo: errno]; #endif objc_autoreleasePoolPop(pool); return true; } #ifdef OF_LINUX - (OFData *)extendedAttributeForName: (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]; ssize_t size = lgetxattr(cPath, cName, NULL, 0); void *value = OFAllocMemory(1, size); OFData *data; @try { if ((size = lgetxattr(cPath, cName, value, size)) < 0) @throw [OFGetItemAttributesFailedException exceptionWithIRI: IRI errNo: errno]; data = [OFData dataWithItems: value count: size]; } @finally { OFFreeMemory(value); } [data retain]; objc_autoreleasePoolPop(pool); return [data autorelease]; } #endif @end |
Modified src/OFFileManager.h from [4fdb735c89] to [59114baee3].
︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # endif # if (defined(OF_HAVE_LINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS) # 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 #endif @class OFArray OF_GENERIC(ObjectType); @class OFConstantString; @class OFDate; @class OFIRI; @class OFString; | > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # endif # if (defined(OF_HAVE_LINK) && !defined(OF_AMIGAOS)) || defined(OF_WINDOWS) # 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 # define OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES # endif #endif @class OFArray OF_GENERIC(ObjectType); @class OFConstantString; @class OFDate; @class OFIRI; @class OFString; |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | * * @ref OFFileOwnerAccountName * * @ref OFFileGroupOwnerAccountName * * @ref OFFileLastAccessDate * * @ref OFFileModificationDate * * @ref OFFileStatusChangeDate * * @ref OFFileCreationDate * * @ref OFFileSymbolicLinkDestination * * Other IRI schemes might not have all keys and might have keys not listed. */ typedef OFConstantString *OFFileAttributeKey; /** * @brief The type of a file. | > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | * * @ref OFFileOwnerAccountName * * @ref OFFileGroupOwnerAccountName * * @ref OFFileLastAccessDate * * @ref OFFileModificationDate * * @ref OFFileStatusChangeDate * * @ref OFFileCreationDate * * @ref OFFileSymbolicLinkDestination * * @ref OFFileExtendedAttributesNames * * Other IRI schemes might not have all keys and might have keys not listed. */ typedef OFConstantString *OFFileAttributeKey; /** * @brief The type of a file. |
︙ | ︙ | |||
184 185 186 187 188 189 190 | * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileCreationDate. */ extern const OFFileAttributeKey OFFileCreationDate; /** | | > > > > > > > > > | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileCreationDate. */ extern const OFFileAttributeKey OFFileCreationDate; /** * @brief The destination of a symbolic link as an @ref OFString. * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileSymbolicLinkDestination. */ extern const OFFileAttributeKey OFFileSymbolicLinkDestination; /** * @brief The names of the extended attributes as an @ref OFArray of * @ref OFString. * * For convenience, a category on @ref OFDictionary is provided to access this * via @ref OFDictionary#fileExtendedAttributesNames. */ extern const OFFileAttributeKey OFFileExtendedAttributesNames; /** * @brief A regular file. */ extern const OFFileAttributeType OFFileTypeRegular; /** * @brief A directory. |
︙ | ︙ | |||
655 656 657 658 659 660 661 | * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @note For file IRIs on Windows, this requires at least Windows Vista and * administrator privileges! * * @param IRI The IRI to the item which should symbolically link to the target * @param target The target of the symbolic link * @throw OFOFCreateSymbolicLinkFailedException Creating a symbolic link failed * @throw OFUnsupportedProtocolException No handler is registered for the IRI's * scheme */ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES /** * @brief Returns the extended attribute with the specified name for the * specified path. * * @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 */ - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtPath: (OFString *)path; #endif /** * @brief Returns the extended attribute with the specified name for 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 No handler is registered for the IRI's * scheme */ - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; @end @interface OFDictionary (FileAttributes) /** * @brief The @ref OFFileSize key from the dictionary. * * @throw OFUndefinedKeyException The key is missing |
︙ | ︙ | |||
751 752 753 754 755 756 757 758 759 760 | /** * @brief The @ref OFFileSymbolicLinkDestination key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFString *fileSymbolicLinkDestination; @end OF_ASSUME_NONNULL_END | > > > > > > > > | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | /** * @brief The @ref OFFileSymbolicLinkDestination key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFString *fileSymbolicLinkDestination; /** * @brief The @ref OFFileExtendedAttributesNames key from the dictionary. * * @throw OFUndefinedKeyException The key is missing */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *fileExtendedAttributesNames; @end OF_ASSUME_NONNULL_END |
Modified src/OFFileManager.m from [64aa04c00e] to [50ee140785].
︙ | ︙ | |||
884 885 886 887 888 889 890 891 892 893 894 895 896 897 | { void *pool = objc_autoreleasePoolPush(); [self createSymbolicLinkAtIRI: [OFIRI fileIRIWithPath: path] withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #endif @end @implementation OFDefaultFileManager - (instancetype)autorelease { return self; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 | { void *pool = objc_autoreleasePoolPush(); [self createSymbolicLinkAtIRI: [OFIRI fileIRIWithPath: path] withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #endif - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { OFIRIHandler *IRIHandler; if (IRI == nil) @throw [OFInvalidArgumentException exception]; if ((IRIHandler = [OFIRIHandler handlerForIRI: IRI]) == nil) @throw [OFUnsupportedProtocolException exceptionWithIRI: IRI]; return [IRIHandler extendedAttributeForName: name ofItemAtIRI: IRI]; } #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFData *ret; ret = [self extendedAttributeForName: name ofItemAtIRI: [OFIRI fileIRIWithPath: path]]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } #endif @end @implementation OFDefaultFileManager - (instancetype)autorelease { return self; } |
︙ | ︙ | |||
971 972 973 974 975 976 977 978 | return attributeForKeyOrException(self, OFFileCreationDate); } - (OFString *)fileSymbolicLinkDestination { return attributeForKeyOrException(self, OFFileSymbolicLinkDestination); } @end | > > > > > | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | return attributeForKeyOrException(self, OFFileCreationDate); } - (OFString *)fileSymbolicLinkDestination { return attributeForKeyOrException(self, OFFileSymbolicLinkDestination); } - (OFArray OF_GENERIC(OFString *) *)fileExtendedAttributesNames { return attributeForKeyOrException(self, OFFileExtendedAttributesNames); } @end |
Modified src/OFFileManagerConstants.inc from [1022c1f264] to [9aaf7f17d6].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | @"OFFileGroupOwnerAccountName"; const OFFileAttributeKey OFFileLastAccessDate = @"OFFileLastAccessDate"; const OFFileAttributeKey OFFileModificationDate = @"OFFileModificationDate"; const OFFileAttributeKey OFFileStatusChangeDate = @"OFFileStatusChangeDate"; const OFFileAttributeKey OFFileCreationDate = @"OFFileCreationDate"; const OFFileAttributeKey OFFileSymbolicLinkDestination = @"OFFileSymbolicLinkDestination"; const OFFileAttributeType OFFileTypeRegular = @"OFFileTypeRegular"; const OFFileAttributeType OFFileTypeDirectory = @"OFFileTypeDirectory"; const OFFileAttributeType OFFileTypeSymbolicLink = @"OFFileTypeSymbolicLink"; const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO"; const OFFileAttributeType OFFileTypeCharacterSpecial = @"OFFileTypeCharacterSpecial"; | > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | @"OFFileGroupOwnerAccountName"; const OFFileAttributeKey OFFileLastAccessDate = @"OFFileLastAccessDate"; const OFFileAttributeKey OFFileModificationDate = @"OFFileModificationDate"; const OFFileAttributeKey OFFileStatusChangeDate = @"OFFileStatusChangeDate"; const OFFileAttributeKey OFFileCreationDate = @"OFFileCreationDate"; const OFFileAttributeKey OFFileSymbolicLinkDestination = @"OFFileSymbolicLinkDestination"; const OFFileAttributeKey OFFileExtendedAttributesNames = @"OFFileExtendedAttributesNames"; const OFFileAttributeType OFFileTypeRegular = @"OFFileTypeRegular"; const OFFileAttributeType OFFileTypeDirectory = @"OFFileTypeDirectory"; const OFFileAttributeType OFFileTypeSymbolicLink = @"OFFileTypeSymbolicLink"; const OFFileAttributeType OFFileTypeFIFO = @"OFFileTypeFIFO"; const OFFileAttributeType OFFileTypeCharacterSpecial = @"OFFileTypeCharacterSpecial"; |
︙ | ︙ |
Modified src/OFIRIHandler.h from [8b927e1cfe] to [a1527ceca1].
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #import "OFFileManager.h" #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFDate; @class OFIRI; @class OFStream; /** * @class OFIRIHandler OFIRIHandler.h ObjFW/OFIRIHandler.h * | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFFileManager.h" #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFData; @class OFDate; @class OFIRI; @class OFStream; /** * @class OFIRIHandler OFIRIHandler.h ObjFW/OFIRIHandler.h * |
︙ | ︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | /** * @brief Returns the attributes for the item at the specified IRI. * * @param IRI The IRI to return the attributes for * @return A dictionary of attributes for the specified IRI, with the keys of * type @ref OFFileAttributeKey */ - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI; /** * @brief Sets the attributes for the item at the specified IRI. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified IRI * @param IRI The IRI of the item to set the attributes for */ - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a file exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a file at the specified IRI */ - (bool)fileExistsAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a directory exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a directory at the specified IRI */ - (bool)directoryExistsAtIRI: (OFIRI *)IRI; /** * @brief Creates a directory at the specified IRI. * * @param IRI The IRI of the directory to create */ - (void)createDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Returns an array with the IRIs of the items in the specified * directory. * * @note `.` and `..` are not part of the returned array. * * @param IRI The IRI to the directory whose items should be returned * @return An array with the IRIs of the items in the specified directory */ - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Removes the item at the specified IRI. * * If the item at the specified IRI is a directory, it is removed recursively. * * @param IRI The IRI to the item which should be removed */ - (void)removeItemAtIRI: (OFIRI *)IRI; /** * @brief Creates a hard link for the specified item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @param source The IRI to the item for which a link should be created * @param destination The IRI to the item which should link to the source */ - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param IRI The IRI to the item which should symbolically link to the target * @param target The target of the symbolic link */ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; /** * @brief Tries to efficiently copy an item. If a copy would only be possible * by reading the entire item and then writing it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If an item already exists, the copy operation fails. This is also the case * if a directory is copied and an item already exists in the destination * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination IRI * @return True if an efficient copy was performed, false if an efficient copy * was not possible. Note that errors while performing a copy are * reported via exceptions and not by returning false! */ - (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Tries to efficiently move an item. If a move would only be possible * by copying the source and deleting it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If the destination is on a different logical device or uses a different * scheme, an efficient move is not possible and false is returned. * * @param source The item to rename * @param destination The new name for the item * @return True if an efficient move was performed, false if an efficient move * was not possible. Note that errors while performing a move are * reported via exceptions and not by returning false! */ - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | /** * @brief Returns the attributes for the item at the specified IRI. * * @param IRI The IRI to return the attributes for * @return A dictionary of attributes for the specified IRI, with the keys of * type @ref OFFileAttributeKey * @throw OFGetItemAttributesFailedException Failed to get the attributes of * the item * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (OFFileAttributes)attributesOfItemAtIRI: (OFIRI *)IRI; /** * @brief Sets the attributes for the item at the specified IRI. * * All attributes not part of the dictionary are left unchanged. * * @param attributes The attributes to set for the specified IRI * @param IRI The IRI of the item to set the attributes for * @@throw OFSetItemAttributesFailedException Failed to set the attributes of * the item * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme * @throw OFNotImplementedException Setting one or more of the specified * attributes is not implpemented for the * specified item */ - (void)setAttributes: (OFFileAttributes)attributes ofItemAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a file exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a file at the specified IRI * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)fileExistsAtIRI: (OFIRI *)IRI; /** * @brief Checks whether a directory exists at the specified IRI. * * @param IRI The IRI to check * @return A boolean whether there is a directory at the specified IRI * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)directoryExistsAtIRI: (OFIRI *)IRI; /** * @brief Creates a directory at the specified IRI. * * @param IRI The IRI of the directory to create * @throw OFCreateDirectoryFailedException Creating the directory failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)createDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Returns an array with the IRIs of the items in the specified * directory. * * @note `.` and `..` are not part of the returned array. * * @param IRI The IRI to the directory whose items should be returned * @return An array with the IRIs of the items in the specified directory * @throw OFOpenItemFailedException Opening the directory failed * @throw OFReadFailedException Reading from the directory failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (OFArray OF_GENERIC(OFIRI *) *)contentsOfDirectoryAtIRI: (OFIRI *)IRI; /** * @brief Removes the item at the specified IRI. * * If the item at the specified IRI is a directory, it is removed recursively. * * @param IRI The IRI to the item which should be removed * @throw OFRemoveItemFailedException Removing the item failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)removeItemAtIRI: (OFIRI *)IRI; /** * @brief Creates a hard link for the specified item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @param source The IRI to the item for which a link should be created * @param destination The IRI to the item which should link to the source * @throw OFLinkItemFailedException Linking the item failed * @throw OFUnsupportedProtocolException The handler cannot handle the scheme * of one of the IRIs * @throw OFNotImplementedException Hardlinks are not implemented for the * specified IRI */ - (void)linkItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Creates a symbolic link for an item. * * The destination IRI must have a full path, which means it must include the * name of the item. * * This method is not available for all IRIs. * * @note On Windows, this requires at least Windows Vista and administrator * privileges! * * @param IRI The IRI to the item which should symbolically link to the target * @param target The target of the symbolic link * @throw OFCreateSymbolicLinkFailed Creating a symbolic link failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (void)createSymbolicLinkAtIRI: (OFIRI *)IRI withDestinationPath: (OFString *)target; /** * @brief Tries to efficiently copy an item. If a copy would only be possible * by reading the entire item and then writing it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If an item already exists, the copy operation fails. This is also the case * if a directory is copied and an item already exists in the destination * directory. * * @param source The file, directory or symbolic link to copy * @param destination The destination IRI * @return True if an efficient copy was performed, false if an efficient copy * was not possible. Note that errors while performing a copy are * reported via exceptions and not by returning false! * @throw OFCopyItemFailedException Copying failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)copyItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Tries to efficiently move an item. If a move would only be possible * by copying the source and deleting it, it returns false. * * The destination IRI must have a full path, which means it must include the * name of the item. * * If the destination is on a different logical device or uses a different * scheme, an efficient move is not possible and false is returned. * * @param source The item to rename * @param destination The new name for the item * @return True if an efficient move was performed, false if an efficient move * was not possible. Note that errors while performing a move are * reported via exceptions and not by returning false! * @throw OFMoveItemFailedException Moving failed * @throw OFUnsupportedProtocolException The handler cannot handle the IRI's * scheme */ - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination; /** * @brief Returns the extended attribute with the specified name for 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 */ - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI; @end OF_ASSUME_NONNULL_END |
Modified src/OFIRIHandler.m from [e1b28ce91b] to [1620a3cb28].
︙ | ︙ | |||
209 210 211 212 213 214 215 216 | return false; } - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { return false; } @end | > > > > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 | return false; } - (bool)moveItemAtIRI: (OFIRI *)source toIRI: (OFIRI *)destination { return false; } - (OFData *)extendedAttributeForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI { return nil; } @end |