@@ -47,11 +47,10 @@ #import "OFMoveItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFRemoveItemFailedException.h" #import "OFRetrieveItemAttributesFailedException.h" -#import "OFUndefinedKeyException.h" #import "OFUnsupportedProtocolException.h" #ifdef OF_WINDOWS # include # include @@ -78,42 +77,10 @@ static struct DOSIFace *IDOS = NULL; #endif static OFFileManager *defaultManager; -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_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"; - #ifdef OF_AMIGAOS static bool dirChanged = false; static BPTR originalDirLock = 0; OF_DESTRUCTOR() @@ -129,23 +96,10 @@ CloseLibrary(DOSBase); # endif } #endif -static id -attributeForKeyOrException(of_file_attributes_t attributes, - of_file_attribute_key_t key) -{ - id object = [attributes objectForKey: key]; - - if (object == nil) - @throw [OFUndefinedKeyException exceptionWithObject: attributes - key: key]; - - return object; -} - @implementation OFFileManager + (void)initialize { if (self != [OFFileManager class]) return; @@ -836,75 +790,10 @@ withDestinationPath: target]; objc_autoreleasePoolPop(pool); } #endif -@end - -@implementation OFDictionary (FileAttributes) -- (uintmax_t)fileSize -{ - return [attributeForKeyOrException(self, of_file_attribute_key_size) - uIntMaxValue]; -} - -- (of_file_type_t)fileType -{ - return attributeForKeyOrException(self, of_file_attribute_key_type); -} - -- (uint16_t)filePOSIXPermissions -{ - return [attributeForKeyOrException(self, - of_file_attribute_key_posix_permissions) uInt16Value]; -} - -- (uint32_t)filePOSIXUID -{ - return [attributeForKeyOrException(self, - of_file_attribute_key_posix_uid) uInt32Value]; -} - -- (uint32_t)filePOSIXGID -{ - return [attributeForKeyOrException(self, - of_file_attribute_key_posix_gid) uInt32Value]; -} - -- (OFString *)fileOwner -{ - return attributeForKeyOrException(self, of_file_attribute_key_owner); -} - -- (OFString *)fileGroup -{ - return attributeForKeyOrException(self, of_file_attribute_key_group); -} - -- (OFDate *)fileLastAccessDate -{ - return attributeForKeyOrException(self, - of_file_attribute_key_last_access_date); -} - -- (OFDate *)fileModificationDate -{ - return attributeForKeyOrException(self, - of_file_attribute_key_modification_date); -} - -- (OFDate *)fileStatusChangeDate -{ - return attributeForKeyOrException(self, - of_file_attribute_key_status_change_date); -} - -- (OFString *)fileSymbolicLinkDestination -{ - return attributeForKeyOrException(self, - of_file_attribute_key_symbolic_link_destination); -} @end @implementation OFFileManager_default - (instancetype)autorelease {