Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -59,13 +59,13 @@ @property (readwrite, retain, nonatomic) OFDate *modificationDate; /** * @brief The type of the archive entry. * - * See @ref of_tar_archive_entry_type_t. + * See @ref OFTarArchiveEntryType. */ -@property (readwrite, nonatomic) of_tar_archive_entry_type_t type; +@property (readwrite, nonatomic) OFTarArchiveEntryType type; /** * @brief The file name of the target (for a hard link or symbolic link). */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) Index: src/OFMutableTarArchiveEntry.m ================================================================== --- src/OFMutableTarArchiveEntry.m +++ src/OFMutableTarArchiveEntry.m @@ -64,11 +64,11 @@ OFDate *old = _modificationDate; _modificationDate = [modificationDate retain]; [old release]; } -- (void)setType: (of_tar_archive_entry_type_t)type +- (void)setType: (OFTarArchiveEntryType)type { _type = type; } - (void)setTargetFileName: (OFString *)targetFileName Index: src/OFTarArchive.h ================================================================== --- src/OFTarArchive.h +++ src/OFTarArchive.h @@ -29,14 +29,14 @@ */ OF_SUBCLASSING_RESTRICTED @interface OFTarArchive: OFObject { OFStream *_stream; - enum { - OF_TAR_ARCHIVE_MODE_READ, - OF_TAR_ARCHIVE_MODE_WRITE, - OF_TAR_ARCHIVE_MODE_APPEND + enum OFTarArchiveMode { + OFTarArchiveModeRead, + OFTarArchiveModeWrite, + OFTarArchiveModeAppend } _mode; OFStringEncoding _encoding; OFStream *_Nullable _lastReturnedStream; } Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -84,19 +84,19 @@ @try { _stream = [stream retain]; if ([mode isEqual: @"r"]) - _mode = OF_TAR_ARCHIVE_MODE_READ; + _mode = OFTarArchiveModeRead; else if ([mode isEqual: @"w"]) - _mode = OF_TAR_ARCHIVE_MODE_WRITE; + _mode = OFTarArchiveModeWrite; else if ([mode isEqual: @"a"]) - _mode = OF_TAR_ARCHIVE_MODE_APPEND; + _mode = OFTarArchiveModeAppend; else @throw [OFInvalidArgumentException exception]; - if (_mode == OF_TAR_ARCHIVE_MODE_APPEND) { + if (_mode == OFTarArchiveModeAppend) { uint32_t buffer[1024 / sizeof(uint32_t)]; bool empty = true; if (![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; @@ -156,11 +156,11 @@ { OFTarArchiveEntry *entry; uint32_t buffer[512 / sizeof(uint32_t)]; bool empty = true; - if (_mode != OF_TAR_ARCHIVE_MODE_READ) + if (_mode != OFTarArchiveModeRead) @throw [OFInvalidArgumentException exception]; [(OFTarArchiveFileReadStream *)_lastReturnedStream of_skip]; @try { [_lastReturnedStream close]; @@ -200,11 +200,11 @@ return entry; } - (OFStream *)streamForReadingCurrentEntry { - if (_mode != OF_TAR_ARCHIVE_MODE_READ) + if (_mode != OFTarArchiveModeRead) @throw [OFInvalidArgumentException exception]; if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; @@ -214,12 +214,11 @@ - (OFStream *)streamForWritingEntry: (OFTarArchiveEntry *)entry { void *pool; - if (_mode != OF_TAR_ARCHIVE_MODE_WRITE && - _mode != OF_TAR_ARCHIVE_MODE_APPEND) + if (_mode != OFTarArchiveModeWrite && _mode != OFTarArchiveModeAppend) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); @try { @@ -253,16 +252,14 @@ /* Might have already been closed by the user - that's fine. */ } [_lastReturnedStream release]; _lastReturnedStream = nil; - if (_mode == OF_TAR_ARCHIVE_MODE_WRITE || - _mode == OF_TAR_ARCHIVE_MODE_APPEND) { + if (_mode == OFTarArchiveModeWrite || _mode == OFTarArchiveModeAppend) { char buffer[1024]; memset(buffer, '\0', 1024); - [_stream writeBuffer: buffer - length: 1024]; + [_stream writeBuffer: buffer length: 1024]; } [_stream release]; _stream = nil; } Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -22,28 +22,28 @@ @class OFDate; /** * @brief The type of the archive entry. */ -typedef enum of_tar_archive_entry_type_t { +typedef enum OFTarArchiveEntryType { /** Normal file */ - OF_TAR_ARCHIVE_ENTRY_TYPE_FILE = '0', + OFTarArchiveEntryTypeFile = '0', /** Hard link */ - OF_TAR_ARCHIVE_ENTRY_TYPE_LINK = '1', + OFTarArchiveEntryTypeLink = '1', /** Symbolic link */ - OF_TAR_ARCHIVE_ENTRY_TYPE_SYMLINK = '2', + OFTarArchiveEntryTypeSymlink = '2', /** Character device */ - OF_TAR_ARCHIVE_ENTRY_TYPE_CHARACTER_DEVICE = '3', + OFTarArchiveEntryTypeCharacterDevice = '3', /** Block device */ - OF_TAR_ARCHIVE_ENTRY_TYPE_BLOCK_DEVICE = '4', + OFTarArchiveEntryTypeBlockDevice = '4', /** Directory */ - OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY = '5', + OFTarArchiveEntryTypeDirectory = '5', /** FIFO */ - OF_TAR_ARCHIVE_ENTRY_TYPE_FIFO = '6', + OFTarArchiveEntryTypeFIFO = '6', /** Contiguous file */ - OF_TAR_ARCHIVE_ENTRY_TYPE_CONTIGUOUS_FILE = '7', -} of_tar_archive_entry_type_t; + OFTarArchiveEntryTypeContiguousFile = '7', +} OFTarArchiveEntryType; /** * @class OFTarArchiveEntry OFTarArchiveEntry.h ObjFW/OFTarArchiveEntry.h * * @brief A class which represents an entry of a tar archive. @@ -53,11 +53,11 @@ OFString *_fileName; unsigned long _mode; unsigned long long _size; unsigned long _UID, _GID; OFDate *_modificationDate; - of_tar_archive_entry_type_t _type; + OFTarArchiveEntryType _type; OFString *_Nullable _targetFileName; OFString *_Nullable _owner, *_Nullable _group; unsigned long _deviceMajor, _deviceMinor; OF_RESERVE_IVARS(OFTarArchiveEntry, 4) } @@ -93,13 +93,13 @@ @property (readonly, retain, nonatomic) OFDate *modificationDate; /** * @brief The type of the archive entry. * - * See @ref of_tar_archive_entry_type_t. + * See @ref OFTarArchiveEntryType. */ -@property (readonly, nonatomic) of_tar_archive_entry_type_t type; +@property (readonly, nonatomic) OFTarArchiveEntryType type; /** * @brief The file name of the target (for a hard link or symbolic link). */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -111,11 +111,11 @@ targetFileName = stringFromBuffer(header + 157, 100, encoding); if (targetFileName.length > 0) _targetFileName = [targetFileName copy]; if (_type == '\0') - _type = OF_TAR_ARCHIVE_ENTRY_TYPE_FILE; + _type = OFTarArchiveEntryTypeFile; if (memcmp(header + 257, "ustar\0" "00", 8) == 0) { OFString *prefix; _owner = [stringFromBuffer(header + 265, 32, encoding) @@ -151,11 +151,11 @@ { self = [super init]; @try { _fileName = [fileName copy]; - _type = OF_TAR_ARCHIVE_ENTRY_TYPE_FILE; + _type = OFTarArchiveEntryTypeFile; _mode = 0644; } @catch (id e) { [self release]; @throw e; } @@ -230,11 +230,11 @@ - (OFDate *)modificationDate { return _modificationDate; } -- (of_tar_archive_entry_type_t)type +- (OFTarArchiveEntryType)type { return _type; } - (OFString *)targetFileName Index: utils/ofarc/TarArchive.m ================================================================== --- utils/ofarc/TarArchive.m +++ utils/ofarc/TarArchive.m @@ -170,36 +170,36 @@ if (app->_outputLevel >= 2) { [of_stdout writeString: @"\t"]; switch (entry.type) { - case OF_TAR_ARCHIVE_ENTRY_TYPE_FILE: + case OFTarArchiveEntryTypeFile: [of_stdout writeLine: OF_LOCALIZED( @"list_type_normal", @"Type: Normal file")]; break; - case OF_TAR_ARCHIVE_ENTRY_TYPE_LINK: + case OFTarArchiveEntryTypeLink: [of_stdout writeLine: OF_LOCALIZED( @"list_type_hardlink", @"Type: Hard link")]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_link_target", @"Target file name: %[target]", @"target", entry.targetFileName)]; break; - case OF_TAR_ARCHIVE_ENTRY_TYPE_SYMLINK: + case OFTarArchiveEntryTypeSymlink: [of_stdout writeLine: OF_LOCALIZED( @"list_type_symlink", @"Type: Symbolic link")]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_link_target", @"Target file name: %[target]", @"target", entry.targetFileName)]; break; - case OF_TAR_ARCHIVE_ENTRY_TYPE_CHARACTER_DEVICE: { + case OFTarArchiveEntryTypeCharacterDevice: { OFString *majorString = [OFString stringWithFormat: @"%d", entry.deviceMajor]; OFString *minorString = [OFString stringWithFormat: @"%d", entry.deviceMinor]; @@ -216,11 +216,11 @@ @"list_device_minor", @"Device minor: %[minor]", @"minor", minorString)]; break; } - case OF_TAR_ARCHIVE_ENTRY_TYPE_BLOCK_DEVICE: { + case OFTarArchiveEntryTypeBlockDevice: { OFString *majorString = [OFString stringWithFormat: @"%d", entry.deviceMajor]; OFString *minorString = [OFString stringWithFormat: @"%d", entry.deviceMinor]; @@ -237,21 +237,21 @@ @"list_device_minor", @"Device minor: %[minor]", @"minor", minorString)]; break; } - case OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY: + case OFTarArchiveEntryTypeDirectory: [of_stdout writeLine: OF_LOCALIZED( @"list_type_directory", @"Type: Directory")]; break; - case OF_TAR_ARCHIVE_ENTRY_TYPE_FIFO: + case OFTarArchiveEntryTypeFIFO: [of_stdout writeLine: OF_LOCALIZED( @"list_type_fifo", @"Type: FIFO")]; break; - case OF_TAR_ARCHIVE_ENTRY_TYPE_CONTIGUOUS_FILE: + case OFTarArchiveEntryTypeContiguousFile: [of_stdout writeLine: OF_LOCALIZED( @"list_type_contiguous_file", @"Type: Contiguous file")]; break; default: @@ -275,22 +275,22 @@ OFTarArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = entry.fileName; - of_tar_archive_entry_type_t type = entry.type; + OFTarArchiveEntryType type = entry.type; OFString *outFileName, *directory; OFFile *output; OFStream *stream; uint64_t written = 0, size = entry.size; int8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; - if (type != OF_TAR_ARCHIVE_ENTRY_TYPE_FILE && - type != OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY) { + if (type != OFTarArchiveEntryTypeFile && + type != OFTarArchiveEntryTypeDirectory) { if (app->_outputLevel >= 0) [of_stdout writeLine: OF_LOCALIZED( @"skipping_file", @"Skipping %[file]...", @"file", fileName)]; @@ -313,12 +313,12 @@ if (app->_outputLevel >= 0) [of_stdout writeString: OF_LOCALIZED(@"extracting_file", @"Extracting %[file]...", @"file", fileName)]; - if (type == OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY || - (type == OF_TAR_ARCHIVE_ENTRY_TYPE_FILE && + if (type == OFTarArchiveEntryTypeDirectory || + (type == OFTarArchiveEntryTypeFile && [fileName hasSuffix: @"/"])) { [fileManager createDirectoryAtPath: outFileName createParents: true]; setPermissions(outFileName, entry); setModificationDate(outFileName, entry); @@ -490,26 +490,26 @@ entry.owner = attributes.fileOwnerAccountName; entry.group = attributes.fileGroupOwnerAccountName; #endif if ([type isEqual: OFFileTypeRegular]) - entry.type = OF_TAR_ARCHIVE_ENTRY_TYPE_FILE; + entry.type = OFTarArchiveEntryTypeFile; else if ([type isEqual: OFFileTypeDirectory]) { - entry.type = OF_TAR_ARCHIVE_ENTRY_TYPE_DIRECTORY; + entry.type = OFTarArchiveEntryTypeDirectory; entry.size = 0; } else if ([type isEqual: OFFileTypeSymbolicLink]) { - entry.type = OF_TAR_ARCHIVE_ENTRY_TYPE_SYMLINK; + entry.type = OFTarArchiveEntryTypeSymlink; entry.targetFileName = attributes.fileSymbolicLinkDestination; entry.size = 0; } [entry makeImmutable]; output = [_archive streamForWritingEntry: entry]; - if (entry.type == OF_TAR_ARCHIVE_ENTRY_TYPE_FILE) { + if (entry.type == OFTarArchiveEntryTypeFile) { uint64_t written = 0, size = entry.size; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"];