@@ -69,43 +69,35 @@ #endif @interface OFDefaultFileManager: OFFileManager @end -const of_file_attribute_key_t of_file_attribute_key_size = - @"of_file_attribute_key_size"; -const of_file_attribute_key_t of_file_attribute_key_type = - @"of_file_attribute_key_type"; -const of_file_attribute_key_t of_file_attribute_key_posix_permissions = - @"of_file_attribute_key_posix_permissions"; -const of_file_attribute_key_t of_file_attribute_key_posix_uid = - @"of_file_attribute_key_posix_uid"; -const of_file_attribute_key_t of_file_attribute_key_posix_gid = - @"of_file_attribute_key_posix_gid"; -const of_file_attribute_key_t of_file_attribute_key_owner = - @"of_file_attribute_key_owner"; -const of_file_attribute_key_t of_file_attribute_key_group = - @"of_file_attribute_key_group"; -const of_file_attribute_key_t of_file_attribute_key_last_access_date = - @"of_file_attribute_key_last_access_date"; -const of_file_attribute_key_t of_file_attribute_key_modification_date = - @"of_file_attribute_key_modification_date"; -const of_file_attribute_key_t of_file_attribute_key_status_change_date = - @"of_file_attribute_key_status_change_date"; -const of_file_attribute_key_t of_file_attribute_key_creation_date = - @"of_file_attribute_key_creation_date"; -const of_file_attribute_key_t of_file_attribute_key_symbolic_link_destination = - @"of_file_attribute_key_symbolic_link_destination"; - -const of_file_type_t of_file_type_regular = @"of_file_type_regular"; -const of_file_type_t of_file_type_directory = @"of_file_type_directory"; -const of_file_type_t of_file_type_symbolic_link = @"of_file_type_symbolic_link"; -const of_file_type_t of_file_type_fifo = @"of_file_type_fifo"; -const of_file_type_t of_file_type_character_special = - @"of_file_type_character_special"; -const of_file_type_t of_file_type_block_special = @"of_file_type_block_special"; -const of_file_type_t of_file_type_socket = @"of_file_type_socket"; +const OFFileAttributeKey OFFileSize = @"OFFileSize"; +const OFFileAttributeKey OFFileType = @"OFFileType"; +const OFFileAttributeKey OFFilePOSIXPermissions = @"OFFilePOSIXPermissions"; +const OFFileAttributeKey OFFileOwnerAccountID = @"OFFileOwnerAccountID"; +const OFFileAttributeKey OFFileGroupOwnerAccountID = + @"OFFileGroupOwnerAccountID"; +const OFFileAttributeKey OFFileOwnerAccountName = @"OFFileOwnerAccountName"; +const OFFileAttributeKey OFFileGroupOwnerAccountName = + @"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"; +const OFFileAttributeType OFFileTypeBlockSpecial = @"OFFileTypeBlockSpecial"; +const OFFileAttributeType OFFileTypeSocket = @"OFFileTypeSocket"; +const OFFileAttributeType OFFileTypeUnknown = @"OFFileTypeUnknown"; #ifdef OF_AMIGAOS4 # define CurrentDir(lock) SetCurrentDir(lock) #endif @@ -121,12 +113,11 @@ UnLock(CurrentDir(originalDirLock)); } #endif static id -attributeForKeyOrException(of_file_attributes_t attributes, - of_file_attribute_key_t key) +attributeForKeyOrException(OFFileAttributes attributes, OFFileAttributeKey key) { id object = [attributes objectForKey: key]; if (object == nil) @throw [OFUndefinedKeyException exceptionWithObject: attributes @@ -229,11 +220,11 @@ objc_autoreleasePoolPop(pool); return [ret autorelease]; } #endif -- (of_file_attributes_t)attributesOfItemAtURL: (OFURL *)URL +- (OFFileAttributes)attributesOfItemAtURL: (OFURL *)URL { OFURLHandler *URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; @@ -243,14 +234,14 @@ return [URLHandler attributesOfItemAtURL: URL]; } #ifdef OF_HAVE_FILES -- (of_file_attributes_t)attributesOfItemAtPath: (OFString *)path +- (OFFileAttributes)attributesOfItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); - of_file_attributes_t ret; + OFFileAttributes ret; ret = [self attributesOfItemAtURL: [OFURL fileURLWithPath: path]]; [ret retain]; @@ -258,12 +249,11 @@ return [ret autorelease]; } #endif -- (void)setAttributes: (of_file_attributes_t)attributes - ofItemAtURL: (OFURL *)URL +- (void)setAttributes: (OFFileAttributes)attributes ofItemAtURL: (OFURL *)URL { OFURLHandler *URLHandler; if (URL == nil) @throw [OFInvalidArgumentException exception]; @@ -273,11 +263,11 @@ [URLHandler setAttributes: attributes ofItemAtURL: URL]; } #ifdef OF_HAVE_FILES -- (void)setAttributes: (of_file_attributes_t)attributes +- (void)setAttributes: (OFFileAttributes)attributes ofItemAtPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self setAttributes: attributes ofItemAtURL: [OFURL fileURLWithPath: path]]; @@ -567,12 +557,12 @@ - (void)copyItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; OFURLHandler *URLHandler; - of_file_attributes_t attributes; - of_file_type_t type; + OFFileAttributes attributes; + OFFileAttributeType type; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); @@ -599,22 +589,21 @@ errNo: e.errNo]; } type = attributes.fileType; - if ([type isEqual: of_file_type_directory]) { + if ([type isEqual: OFFileTypeDirectory]) { OFArray OF_GENERIC(OFURL *) *contents; @try { [self createDirectoryAtURL: destination]; @try { - of_file_attribute_key_t key = - of_file_attribute_key_posix_permissions; + OFFileAttributeKey key = OFFilePOSIXPermissions; OFNumber *permissions = [attributes objectForKey: key]; - of_file_attributes_t destinationAttributes; + OFFileAttributes destinationAttributes; if (permissions != nil) { destinationAttributes = [OFDictionary dictionaryWithObject: permissions forKey: key]; @@ -650,17 +639,17 @@ [self copyItemAtURL: item toURL: destinationURL]; objc_autoreleasePoolPop(pool2); } - } else if ([type isEqual: of_file_type_regular]) { + } else if ([type isEqual: OFFileTypeRegular]) { size_t pageSize = [OFSystemInfo pageSize]; OFStream *sourceStream = nil; OFStream *destinationStream = nil; char *buffer; - buffer = of_alloc(1, pageSize); + buffer = OFAllocMemory(1, pageSize); @try { sourceStream = [[OFURLHandler handlerForURL: source] openItemAtURL: source mode: @"r"]; destinationStream = [[OFURLHandler handlerForURL: @@ -676,15 +665,14 @@ [destinationStream writeBuffer: buffer length: length]; } @try { - of_file_attribute_key_t key = - of_file_attribute_key_posix_permissions; + OFFileAttributeKey key = OFFilePOSIXPermissions; OFNumber *permissions = [attributes objectForKey: key]; - of_file_attributes_t destinationAttributes; + OFFileAttributes destinationAttributes; if (permissions != nil) { destinationAttributes = [OFDictionary dictionaryWithObject: permissions forKey: key]; @@ -709,13 +697,13 @@ @throw e; } @finally { [sourceStream close]; [destinationStream close]; - free(buffer); + OFFreeMemory(buffer); } - } else if ([type isEqual: of_file_type_symbolic_link]) { + } else if ([type isEqual: OFFileTypeSymbolicLink]) { @try { OFString *linkDestination = attributes.fileSymbolicLinkDestination; [self createSymbolicLinkAtURL: destination @@ -905,79 +893,74 @@ { } - (unsigned int)retainCount { - return OF_RETAIN_COUNT_MAX; + return OFMaxRetainCount; } @end @implementation OFDictionary (FileAttributes) - (unsigned long long)fileSize { - return [attributeForKeyOrException(self, of_file_attribute_key_size) + return [attributeForKeyOrException(self, OFFileSize) unsignedLongLongValue]; } -- (of_file_type_t)fileType +- (OFFileAttributeType)fileType { - return attributeForKeyOrException(self, of_file_attribute_key_type); + return attributeForKeyOrException(self, OFFileType); } - (unsigned long)filePOSIXPermissions { return [attributeForKeyOrException(self, - of_file_attribute_key_posix_permissions) unsignedLongValue]; -} - -- (unsigned long)filePOSIXUID -{ - return [attributeForKeyOrException(self, - of_file_attribute_key_posix_uid) unsignedLongValue]; -} - -- (unsigned long)filePOSIXGID -{ - return [attributeForKeyOrException(self, - of_file_attribute_key_posix_gid) unsignedLongValue]; -} - -- (OFString *)fileOwner -{ - return attributeForKeyOrException(self, of_file_attribute_key_owner); -} - -- (OFString *)fileGroup -{ - return attributeForKeyOrException(self, of_file_attribute_key_group); + OFFilePOSIXPermissions) unsignedLongValue]; +} + +- (unsigned long)fileOwnerAccountID +{ + return [attributeForKeyOrException(self, + OFFileOwnerAccountID) unsignedLongValue]; +} + +- (unsigned long)fileGroupOwnerAccountID +{ + return [attributeForKeyOrException(self, + OFFileGroupOwnerAccountID) unsignedLongValue]; +} + +- (OFString *)fileOwnerAccountName +{ + return attributeForKeyOrException(self, OFFileOwnerAccountName); +} + +- (OFString *)fileGroupOwnerAccountName +{ + return attributeForKeyOrException(self, OFFileGroupOwnerAccountName); } - (OFDate *)fileLastAccessDate { - return attributeForKeyOrException(self, - of_file_attribute_key_last_access_date); + return attributeForKeyOrException(self, OFFileLastAccessDate); } - (OFDate *)fileModificationDate { - return attributeForKeyOrException(self, - of_file_attribute_key_modification_date); + return attributeForKeyOrException(self, OFFileModificationDate); } - (OFDate *)fileStatusChangeDate { - return attributeForKeyOrException(self, - of_file_attribute_key_status_change_date); + return attributeForKeyOrException(self, OFFileStatusChangeDate); } - (OFDate *)fileCreationDate { - return attributeForKeyOrException(self, - of_file_attribute_key_creation_date); + return attributeForKeyOrException(self, OFFileCreationDate); } - (OFString *)fileSymbolicLinkDestination { - return attributeForKeyOrException(self, - of_file_attribute_key_symbolic_link_destination); + return attributeForKeyOrException(self, OFFileSymbolicLinkDestination); } @end