Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -158,17 +158,19 @@ platform/GCC4.7/OFAtomic.h \ platform/PowerPC/OFAtomic.h \ platform/macOS/OFAtomic.h \ platform/x86/OFAtomic.h INCLUDES := ${SRCS:.m=.h} \ + OFArchiveEntry.h \ OFCollection.h \ OFCryptographicHash.h \ OFJSONRepresentation.h \ OFKernelEventObserver.h \ OFKeyValueCoding.h \ OFLocking.h \ OFMessagePackRepresentation.h \ + OFMutableArchiveEntry.h \ ObjFW.h \ macros.h \ objfw-defs.h \ platform.h \ ${USE_INCLUDES_ATOMIC} ADDED src/OFArchiveEntry.h Index: src/OFArchiveEntry.h ================================================================== --- src/OFArchiveEntry.h +++ src/OFArchiveEntry.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @protocol OFArchiveEntry OFArchiveEntry.h ObjFW/OFArchiveEntry.h + * + * @brief A class which represents an entry in an archive. + */ +@protocol OFArchiveEntry + +/** + * @brief The file name of the entry. + */ +@property (readonly, copy, nonatomic) OFString *fileName; + +/** + * @brief The compressed size of the entry's file. + */ +@property (readonly, nonatomic) unsigned long long compressedSize; + +/** + * @brief The uncompressed size of the entry's file. + */ +@property (readonly, nonatomic) unsigned long long uncompressedSize; +@end + +OF_ASSUME_NONNULL_END + +#import "OFMutableArchiveEntry.h" Index: src/OFLHAArchiveEntry.h ================================================================== --- src/OFLHAArchiveEntry.h +++ src/OFLHAArchiveEntry.h @@ -12,10 +12,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" +#import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN @class OFArray OF_GENERIC(ObjectType); @class OFData; @@ -27,11 +28,12 @@ /** * @class OFLHAArchiveEntry OFLHAArchiveEntry.h ObjFW/OFLHAArchiveEntry.h * * @brief A class which represents an entry in an LHA archive. */ -@interface OFLHAArchiveEntry: OFObject +@interface OFLHAArchiveEntry: OFObject { OFString *_fileName, *_Nullable _directoryName, *_compressionMethod; unsigned long long _compressedSize, _uncompressedSize; OFDate *_modificationDate; uint8_t _headerLevel; @@ -42,30 +44,15 @@ OFString *_Nullable _owner, *_Nullable _group; OFMutableArray OF_GENERIC(OFData *) *_extensions; OF_RESERVE_IVARS(OFLHAArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readonly, copy, nonatomic) OFString *fileName; - /** * @brief The compression method of the entry. */ @property (readonly, copy, nonatomic) OFString *compressionMethod; -/** - * @brief The compressed size of the entry's file. - */ -@property (readonly, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the entry's file. - */ -@property (readonly, nonatomic) unsigned long long uncompressedSize; - /** * @brief The modification date of the file. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; ADDED src/OFMutableArchiveEntry.h Index: src/OFMutableArchiveEntry.h ================================================================== --- src/OFMutableArchiveEntry.h +++ src/OFMutableArchiveEntry.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFObject.h" + +OF_ASSUME_NONNULL_BEGIN + +/** + * @protocol OFMutableArchiveEntry \ + * OFMutableArchiveEntry.h ObjFW/OFMutableArchiveEntry.h + * + * @brief A class which represents a mutable entry in an archive. + */ +@protocol OFMutableArchiveEntry + +/** + * @brief The file name of the entry. + */ +@property (readwrite, copy, nonatomic) OFString *fileName; + +/** + * @brief The compressed size of the entry's file. + */ +@property (readwrite, nonatomic) unsigned long long compressedSize; + +/** + * @brief The uncompressed size of the entry's file. + */ +@property (readwrite, nonatomic) unsigned long long uncompressedSize; +@end + +OF_ASSUME_NONNULL_END + +#import "OFMutableArchiveEntry.h" Index: src/OFMutableLHAArchiveEntry.h ================================================================== --- src/OFMutableLHAArchiveEntry.h +++ src/OFMutableLHAArchiveEntry.h @@ -12,44 +12,30 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFLHAArchiveEntry.h" +#import "OFMutableArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableLHAArchiveEntry \ * OFMutableLHAArchiveEntry.h ObjFW/OFMutableLHAArchiveEntry.h * * @brief A class which represents a mutable entry in an LHA archive. */ -@interface OFMutableLHAArchiveEntry: OFLHAArchiveEntry +@interface OFMutableLHAArchiveEntry: OFLHAArchiveEntry { OF_RESERVE_IVARS(OFMutableLHAArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readwrite, copy, nonatomic) OFString *fileName; - /** * @brief The compression method of the entry. */ @property (readwrite, copy, nonatomic) OFString *compressionMethod; -/** - * @brief The compressed size of the entry's file. - */ -@property (readwrite, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the entry's file. - */ -@property (readwrite, nonatomic) unsigned long long uncompressedSize; - /** * @brief The modification date of the file. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; Index: src/OFMutableTarArchiveEntry.h ================================================================== --- src/OFMutableTarArchiveEntry.h +++ src/OFMutableTarArchiveEntry.h @@ -12,29 +12,25 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFTarArchiveEntry.h" +#import "OFMutableArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableTarArchiveEntry \ * OFMutableTarArchiveEntry.h ObjFW/OFMutableTarArchiveEntry.h * * @brief A class which represents a mutable entry of a tar archive. */ -@interface OFMutableTarArchiveEntry: OFTarArchiveEntry +@interface OFMutableTarArchiveEntry: OFTarArchiveEntry { OF_RESERVE_IVARS(OFMutableTarArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readwrite, copy, nonatomic) OFString *fileName; - /** * @brief The mode of the entry. */ @property (readwrite, nonatomic) unsigned long mode; @@ -46,20 +42,10 @@ /** * @brief The GID of the group. */ @property (readwrite, nonatomic) unsigned long GID; -/** - * @brief The compressed size of the file. - */ -@property (readwrite, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the file. - */ -@property (readwrite, nonatomic) unsigned long long uncompressedSize; - /** * @brief The date of the last modification of the file. */ @property (readwrite, retain, nonatomic) OFDate *modificationDate; Index: src/OFMutableZIPArchiveEntry.h ================================================================== --- src/OFMutableZIPArchiveEntry.h +++ src/OFMutableZIPArchiveEntry.h @@ -12,10 +12,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFZIPArchiveEntry.h" +#import "OFMutableArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFMutableZIPArchiveEntry \ @@ -22,20 +23,15 @@ * OFMutableZIPArchiveEntry.h ObjFW/OFMutableZIPArchiveEntry.h * * @brief A class which represents a mutable entry in the central directory of * a ZIP archive. */ -@interface OFMutableZIPArchiveEntry: OFZIPArchiveEntry +@interface OFMutableZIPArchiveEntry: OFZIPArchiveEntry { OF_RESERVE_IVARS(OFMutableZIPArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readwrite, copy, nonatomic) OFString *fileName; - /** * @brief The comment of the entry's file. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *fileComment; @@ -87,20 +83,10 @@ * Other values may be returned, but the file cannot be extracted then. */ @property (readwrite, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; -/** - * @brief The compressed size of the entry's file. - */ -@property (readwrite, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the entry's file. - */ -@property (readwrite, nonatomic) unsigned long long uncompressedSize; - /** * @brief The CRC32 checksum of the entry's file. */ @property (readwrite, nonatomic) uint32_t CRC32; Index: src/OFTarArchiveEntry.h ================================================================== --- src/OFTarArchiveEntry.h +++ src/OFTarArchiveEntry.h @@ -12,10 +12,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" +#import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @@ -46,11 +47,12 @@ /** * @class OFTarArchiveEntry OFTarArchiveEntry.h ObjFW/OFTarArchiveEntry.h * * @brief A class which represents an entry of a tar archive. */ -@interface OFTarArchiveEntry: OFObject +@interface OFTarArchiveEntry: OFObject { OFString *_fileName; unsigned long _mode; unsigned long long _compressedSize, _uncompressedSize; unsigned long _UID, _GID; @@ -60,15 +62,10 @@ OFString *_Nullable _owner, *_Nullable _group; unsigned long _deviceMajor, _deviceMinor; OF_RESERVE_IVARS(OFTarArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readonly, copy, nonatomic) OFString *fileName; - /** * @brief The mode of the entry. */ @property (readonly, nonatomic) unsigned long mode; @@ -80,20 +77,10 @@ /** * @brief The GID of the group. */ @property (readonly, nonatomic) unsigned long GID; -/** - * @brief The compressed size of the file. - */ -@property (readonly, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the file. - */ -@property (readonly, nonatomic) unsigned long long uncompressedSize; - /** * @brief The date of the last modification of the file. */ @property (readonly, retain, nonatomic) OFDate *modificationDate; Index: src/OFZIPArchiveEntry.h ================================================================== --- src/OFZIPArchiveEntry.h +++ src/OFZIPArchiveEntry.h @@ -12,10 +12,11 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" +#import "OFArchiveEntry.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @@ -98,11 +99,12 @@ * @class OFZIPArchiveEntry OFZIPArchiveEntry.h ObjFW/OFZIPArchiveEntry.h * * @brief A class which represents an entry in the central directory of a ZIP * archive. */ -@interface OFZIPArchiveEntry: OFObject +@interface OFZIPArchiveEntry: OFObject { OFZIPArchiveEntryAttributeCompatibility _versionMadeBy; OFZIPArchiveEntryAttributeCompatibility _minVersionNeeded; uint16_t _generalPurposeBitFlag; OFZIPArchiveEntryCompressionMethod _compressionMethod; @@ -117,15 +119,10 @@ uint32_t _versionSpecificAttributes; int64_t _localFileHeaderOffset; OF_RESERVE_IVARS(OFZIPArchiveEntry, 4) } -/** - * @brief The file name of the entry. - */ -@property (readonly, copy, nonatomic) OFString *fileName; - /** * @brief The comment of the entry's file. */ @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fileComment; @@ -177,20 +174,10 @@ * Other values may be returned, but the file cannot be extracted then. */ @property (readonly, nonatomic) OFZIPArchiveEntryCompressionMethod compressionMethod; -/** - * @brief The compressed size of the entry's file. - */ -@property (readonly, nonatomic) unsigned long long compressedSize; - -/** - * @brief The uncompressed size of the entry's file. - */ -@property (readonly, nonatomic) unsigned long long uncompressedSize; - /** * @brief The CRC32 checksum of the entry's file. */ @property (readonly, nonatomic) uint32_t CRC32;