@@ -40,11 +40,11 @@ static void setPermissions(OFString *path, OFLHAArchiveEntry *entry) { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - OFNumber *mode = [entry mode]; + OFNumber *mode = entry.mode; if (mode == nil) return; of_file_attributes_t attributes = [OFDictionary @@ -58,11 +58,11 @@ @implementation LHAArchive + (void)initialize { if (self == [LHAArchive class]) - app = (OFArc *)[[OFApplication sharedApplication] delegate]; + app = (OFArc *)[OFApplication sharedApplication].delegate; } + (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream mode: (OFString *)mode encoding: (of_string_encoding_t)encoding @@ -81,11 +81,11 @@ @try { _archive = [[OFLHAArchive alloc] initWithStream: stream mode: mode]; if (encoding != OF_STRING_ENCODING_AUTODETECT) - [_archive setEncoding: encoding]; + _archive.encoding = encoding; } @catch (id e) { [self release]; @throw e; } @@ -104,21 +104,21 @@ OFLHAArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); - [of_stdout writeLine: [entry fileName]]; + [of_stdout writeLine: entry.fileName]; if (app->_outputLevel >= 1) { - OFString *date = [[entry date] + OFString *date = [entry.date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; OFString *compressedSize = [OFString stringWithFormat: - @"%" PRIu32, [entry compressedSize]]; + @"%" PRIu32, entry.compressedSize]; OFString *uncompressedSize = [OFString stringWithFormat: - @"%" PRIu32, [entry uncompressedSize]]; + @"%" PRIu32, entry.uncompressedSize]; OFString *CRC16 = [OFString stringWithFormat: - @"%04" PRIX16, [entry CRC16]]; + @"%04" PRIX16, entry.CRC16]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compressed_size", @"Compressed: %[size] bytes", @@ -130,84 +130,84 @@ @"size", uncompressedSize)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_compression_method", @"Compression method: %[method]", - @"method", [entry compressionMethod])]; + @"method", entry.compressionMethod)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_crc16", @"CRC16: %[crc16]", @"crc16", CRC16)]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_date", @"Date: %[date]", @"date", date)]; - if ([entry mode] != nil) { + if (entry.mode != nil) { OFString *modeString = [OFString stringWithFormat: - @"%" PRIo16, [[entry mode] uInt16Value]]; + @"%" PRIo16, entry.mode.uInt16Value]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_mode", @"Mode: %[mode]", @"mode", modeString)]; } - if ([entry UID] != nil) { + if (entry.UID != nil) { [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_uid", @"UID: %[uid]", - @"uid", [entry UID])]; + @"uid", entry.UID)]; } - if ([entry GID] != nil) { + if (entry.GID != nil) { [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED(@"list_gid", @"GID: %[gid]", - @"gid", [entry GID])]; + @"gid", entry.GID)]; } - if ([entry owner] != nil) { + if (entry.owner != nil) { [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_owner", @"Owner: %[owner]", - @"owner", [entry owner])]; + @"owner", entry.owner)]; } - if ([entry group] != nil) { + if (entry.group != nil) { [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_group", @"Group: %[group]", - @"group", [entry group])]; + @"group", entry.group)]; } if (app->_outputLevel >= 2) { OFString *headerLevel = [OFString stringWithFormat: @"%" PRIu8, - [entry headerLevel]]; + entry.headerLevel]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_header_level", @"Header level: %[level]", @"level", headerLevel)]; - if ([entry operatingSystemIdentifier] != '\0') { + if (entry.operatingSystemIdentifier != '\0') { OFString *OSID = [OFString stringWithFormat: @"%c", - [entry operatingSystemIdentifier]]; + entry.operatingSystemIdentifier]; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_osid", @"Operating system identifier: " "%[osid]", @"osid", OSID)]; } - if ([entry modificationDate] != nil) { - OFString *modificationDate = [[entry - modificationDate] description]; + if (entry.modificationDate != nil) { + OFString *modificationDate = + entry.modificationDate.description; [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_modification_date", @"Modification date: %[date]", @@ -214,12 +214,12 @@ @"date", modificationDate)]; } } if (app->_outputLevel >= 3) { - OFString *extensions = indent([[entry - extensions] description]); + OFString *extensions = + indent(entry.extensions.description); [of_stdout writeString: @"\t"]; [of_stdout writeLine: OF_LOCALIZED( @"list_extensions", @"Extensions: %[extensions]", @@ -232,22 +232,22 @@ } - (void)extractFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; - bool all = ([files count] == 0); + bool all = (files.count == 0); OFMutableSet OF_GENERIC(OFString *) *missing = [OFMutableSet setWithArray: files]; OFLHAArchiveEntry *entry; while ((entry = [_archive nextEntry]) != nil) { void *pool = objc_autoreleasePoolPush(); - OFString *fileName = [entry fileName]; + OFString *fileName = entry.fileName; OFString *outFileName, *directory; OFFile *output; OFStream *stream; - uint64_t written = 0, size = [entry uncompressedSize]; + uint64_t written = 0, size = entry.uncompressedSize; int8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) continue; @@ -283,11 +283,11 @@ } goto outer_loop_end; } - directory = [outFileName stringByDeletingLastPathComponent]; + directory = outFileName.stringByDeletingLastPathComponent; if (![fileManager directoryExistsAtPath: directory]) [fileManager createDirectoryAtPath: directory createParents: true]; if (![app shouldExtractFile: fileName @@ -297,11 +297,11 @@ stream = [_archive streamForReadingCurrentEntry]; output = [OFFile fileWithPath: outFileName mode: @"w"]; setPermissions(outFileName, entry); - while (![stream isAtEndOfStream]) { + while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: output fileName: fileName]; if (length < 0) { @@ -339,11 +339,11 @@ outer_loop_end: objc_autoreleasePoolPop(pool); } - if ([missing count] > 0) { + if (missing.count > 0) { for (OFString *file in missing) [of_stderr writeLine: OF_LOCALIZED( @"file_not_in_archive", @"File %[file] is not in the archive!", @"file", file)]; @@ -355,29 +355,29 @@ - (void)printFiles: (OFArray OF_GENERIC(OFString *) *)files_ { OFMutableSet *files; OFLHAArchiveEntry *entry; - if ([files_ count] < 1) { + if (files_.count < 1) { [of_stderr writeLine: OF_LOCALIZED(@"print_no_file_specified", @"Need one or more files to print!")]; app->_exitStatus = 1; return; } files = [OFMutableSet setWithArray: files_]; while ((entry = [_archive nextEntry]) != nil) { - OFString *fileName = [entry fileName]; + OFString *fileName = entry.fileName; OFStream *stream; if (![files containsObject: fileName]) continue; stream = [_archive streamForReadingCurrentEntry]; - while (![stream isAtEndOfStream]) { + while (!stream.atEndOfStream) { ssize_t length = [app copyBlockFromStream: stream toStream: of_stdout fileName: fileName]; if (length < 0) { @@ -387,11 +387,11 @@ } [files removeObject: fileName]; [stream close]; - if ([files count] == 0) + if (files.count == 0) break; } for (OFString *file in files) { [of_stderr writeLine: OF_LOCALIZED(@"file_not_in_archive", @@ -398,15 +398,16 @@ @"File %[file] is not in the archive!", @"file", file)]; app->_exitStatus = 1; } } + - (void)addFiles: (OFArray OF_GENERIC(OFString *) *)files { OFFileManager *fileManager = [OFFileManager defaultManager]; - if ([files count] < 1) { + if (files.count < 1) { [of_stderr writeLine: OF_LOCALIZED(@"add_no_file_specified", @"Need one or more files to add!")]; app->_exitStatus = 1; return; } @@ -422,41 +423,41 @@ [of_stdout writeString: OF_LOCALIZED(@"adding_file", @"Adding %[file]...", @"file", fileName)]; attributes = [fileManager attributesOfItemAtPath: fileName]; - type = [attributes fileType]; + type = attributes.fileType; entry = [OFMutableLHAArchiveEntry entryWithFileName: fileName]; #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - [entry setMode: [OFNumber numberWithUInt16: - [attributes filePOSIXPermissions]]]; + entry.mode = [OFNumber numberWithUInt16: + attributes.filePOSIXPermissions]; #endif - [entry setDate: [attributes fileModificationDate]]; + entry.date = attributes.fileModificationDate; #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER - [entry setUID: [OFNumber numberWithUInt16: - [attributes filePOSIXUID]]]; - [entry setGID: [OFNumber numberWithUInt16: - [attributes filePOSIXGID]]]; - [entry setOwner: [attributes fileOwner]]; - [entry setGroup: [attributes fileGroup]]; + entry.UID = + [OFNumber numberWithUInt16: attributes.filePOSIXUID]; + entry.GID = + [OFNumber numberWithUInt16: attributes.filePOSIXGID]; + entry.owner = attributes.fileOwner; + entry.group = attributes.fileGroup; #endif if ([type isEqual: of_file_type_directory]) - [entry setCompressionMethod: @"-lhd-"]; + entry.compressionMethod = @"-lhd-"; output = [_archive streamForWritingEntry: entry]; if ([type isEqual: of_file_type_regular]) { - uintmax_t written = 0, size = [attributes fileSize]; + uintmax_t written = 0, size = attributes.fileSize; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"]; - while (![input isAtEndOfStream]) { + while (!input.atEndOfStream) { ssize_t length = [app copyBlockFromStream: input toStream: output fileName: fileName];