Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -150,11 +150,11 @@ - initWithContentsOfFile: (OFString*)path { @try { OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; - off_t size = [OFFile sizeOfFileAtPath: path]; + of_offset_t size = [OFFile sizeOfFileAtPath: path]; if (size > SIZE_MAX) @throw [OFOutOfRangeException exception]; self = [self initWithItemSize: 1 Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -149,11 +149,11 @@ /*! * @brief Returns the size of the specified file. * * @return The size of the specified file */ -+ (off_t)sizeOfFileAtPath: (OFString*)path; ++ (of_offset_t)sizeOfFileAtPath: (OFString*)path; /*! * @brief Returns the date of the last modification of the file. * * @return The date of the last modification of the file Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -478,11 +478,11 @@ #endif @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path]; } -+ (off_t)sizeOfFileAtPath: (OFString*)path ++ (of_offset_t)sizeOfFileAtPath: (OFString*)path { of_stat_t s; if (path == nil) @throw [OFInvalidArgumentException exception]; @@ -490,12 +490,11 @@ if (of_stat(path, &s) == -1) /* FIXME: Maybe use another exception? */ @throw [OFOpenFileFailedException exceptionWithPath: path mode: @"r"]; - /* FIXME: On Android, off_t is 32 bit, but st_size is long long there */ - return (off_t)s.st_size; + return s.st_size; } + (OFDate*)modificationDateOfFileAtPath: (OFString*)path { of_stat_t s; @@ -973,14 +972,14 @@ @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; #endif } -- (off_t)lowlevelSeekToOffset: (off_t)offset - whence: (int)whence +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset + whence: (int)whence { - off_t ret = lseek(_fd, offset, whence); + of_offset_t ret = lseek(_fd, offset, whence); if (ret == -1) @throw [OFSeekFailedException exceptionWithStream: self offset: offset whence: whence]; Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -23,10 +23,16 @@ #include #import "OFStream.h" +#ifdef __ANDROID__ +typedef long long of_offset_t; +#else +typedef off_t of_offset_t; +#endif + /*! * @class OFSeekableStream OFSeekableStream.h ObjFW/OFSeekableStream.h * * @brief A stream that supports seeking. * @@ -48,12 +54,12 @@ * `SEEK_SET` | Seek to the specified byte * `SEEK_CUR` | Seek to the current location + offset * `SEEK_END` | Seek to the end of the stream + offset * @return The new offset form the start of the file */ -- (off_t)seekToOffset: (off_t)offset - whence: (int)whence; +- (of_offset_t)seekToOffset: (of_offset_t)offset + whence: (int)whence; /*! * @brief Seek the stream on the lowlevel. * * @warning Do not call this directly! @@ -69,8 +75,8 @@ * `SEEK_SET` | Seek to the specified byte * `SEEK_CUR` | Seek to the current location + offset * `SEEK_END` | Seek to the end of the stream + offset * @return The new offset from the start of the file */ -- (off_t)lowlevelSeekToOffset: (off_t)offset - whence: (int)whence; +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset + whence: (int)whence; @end Index: src/OFSeekableStream.m ================================================================== --- src/OFSeekableStream.m +++ src/OFSeekableStream.m @@ -37,18 +37,18 @@ } return [super init]; } -- (off_t)lowlevelSeekToOffset: (off_t)offset - whence: (int)whence +- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset + whence: (int)whence { OF_UNRECOGNIZED_SELECTOR } -- (off_t)seekToOffset: (off_t)offset - whence: (int)whence +- (of_offset_t)seekToOffset: (of_offset_t)offset + whence: (int)whence { if (whence == SEEK_CUR) offset -= _readBufferLength; offset = [self lowlevelSeekToOffset: offset Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -76,11 +76,11 @@ uint32_t _CRC32; bool _atEndOfStream; } - initWithArchiveFile: (OFString*)path - offset: (off_t)offset + offset: (of_offset_t)offset localFileHeader: (OFZIPArchive_LocalFileHeader*)localFileHeader; @end uint32_t of_zip_archive_read_field32(uint8_t **data, uint16_t *size) @@ -178,11 +178,11 @@ - (void)OF_readZIPInfo { void *pool = objc_autoreleasePoolPush(); uint16_t commentLength; - off_t offset = -22; + of_offset_t offset = -22; bool valid = false; do { @try { [_file seekToOffset: offset @@ -236,14 +236,14 @@ * central directory record. */ [_file readLittleEndianInt32]; offset64 = [_file readLittleEndianInt64]; - if ((off_t)offset64 != offset64) + if ((of_offset_t)offset64 != offset64) @throw [OFOutOfRangeException exception]; - [_file seekToOffset: (off_t)offset64 + [_file seekToOffset: (of_offset_t)offset64 whence: SEEK_SET]; if ([_file readLittleEndianInt32] != 0x06064B50) @throw [OFInvalidFormatException exception]; @@ -261,11 +261,12 @@ _centralDirectoryEntriesInDisk = [_file readLittleEndianInt64]; _centralDirectoryEntries = [_file readLittleEndianInt64]; _centralDirectorySize = [_file readLittleEndianInt64]; _centralDirectoryOffset = [_file readLittleEndianInt64]; - if ((off_t)_centralDirectoryOffset != _centralDirectoryOffset) + if ((of_offset_t)_centralDirectoryOffset != + _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; } objc_autoreleasePoolPop(pool); } @@ -273,14 +274,14 @@ - (void)OF_readEntries { void *pool = objc_autoreleasePoolPush(); size_t i; - if ((off_t)_centralDirectoryOffset != _centralDirectoryOffset) + if ((of_offset_t)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; - [_file seekToOffset: (off_t)_centralDirectoryOffset + [_file seekToOffset: (of_offset_t)_centralDirectoryOffset whence: SEEK_SET]; _entries = [[OFMutableArray alloc] init]; _pathToEntryMap = [[OFMutableDictionary alloc] init]; @@ -316,23 +317,23 @@ { OFStream *ret; void *pool = objc_autoreleasePoolPush(); OFZIPArchiveEntry *entry = [_pathToEntryMap objectForKey: path]; OFZIPArchive_LocalFileHeader *localFileHeader; - uint64_t offset; + uint64_t offset64; if (entry == nil) { errno = ENOENT; @throw [OFOpenFileFailedException exceptionWithPath: path mode: @"rb"]; } - offset = [entry OF_localFileHeaderOffset]; - if ((off_t)offset != offset) + offset64 = [entry OF_localFileHeaderOffset]; + if ((of_offset_t)offset64 != offset64) @throw [OFOutOfRangeException exception]; - [_file seekToOffset: (off_t)offset + [_file seekToOffset: (of_offset_t)offset64 whence: SEEK_SET]; localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc] initWithFile: _file] autorelease]; if (![localFileHeader matchesEntry: entry]) @@ -444,11 +445,11 @@ } @end @implementation OFZIPArchive_FileStream - initWithArchiveFile: (OFString*)path - offset: (off_t)offset + offset: (of_offset_t)offset localFileHeader: (OFZIPArchive_LocalFileHeader*)localFileHeader { self = [super init]; @try { Index: src/exceptions/OFSeekFailedException.h ================================================================== --- src/exceptions/OFSeekFailedException.h +++ src/exceptions/OFSeekFailedException.h @@ -12,17 +12,12 @@ * 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. */ -#include - -#include - #import "OFException.h" - -@class OFSeekableStream; +#import "OFSeekableStream.h" /*! * @class OFSeekFailedException \ * OFSeekFailedException.h ObjFW/OFSeekFailedException.h * @@ -29,17 +24,17 @@ * @brief An exception indicating that seeking in a stream failed. */ @interface OFSeekFailedException: OFException { OFSeekableStream *_stream; - off_t _offset; + of_offset_t _offset; int _whence, _errNo; } #ifdef OF_HAVE_PROPERTIES @property (readonly, retain) OFSeekableStream *stream; -@property (readonly) off_t offset; +@property (readonly) of_offset_t offset; @property (readonly) int whence, errNo; #endif /*! * @brief Creates a new, autoreleased seek failed exception. @@ -48,11 +43,11 @@ * @param offset The offset to which seeking failed * @param whence To what the offset is relative * @return A new, autoreleased seek failed exception */ + (instancetype)exceptionWithStream: (OFSeekableStream*)stream - offset: (off_t)offset + offset: (of_offset_t)offset whence: (int)whence; /*! * @brief Initializes an already allocated seek failed exception. * @@ -60,11 +55,11 @@ * @param offset The offset to which seeking failed * @param whence To what the offset is relative * @return An initialized seek failed exception */ - initWithStream: (OFSeekableStream*)stream - offset: (off_t)offset + offset: (of_offset_t)offset whence: (int)whence; /*! * @brief Returns the stream for which seeking failed. * @@ -75,11 +70,11 @@ /*! * @brief Returns the offset to which seeking failed. * * @return The offset to which seeking failed */ -- (off_t)offset; +- (of_offset_t)offset; /*! * @brief Returns to what the offset is relative. * * @return To what the offset is relative Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -22,11 +22,11 @@ #import "common.h" @implementation OFSeekFailedException + (instancetype)exceptionWithStream: (OFSeekableStream*)stream - offset: (off_t)offset + offset: (of_offset_t)offset whence: (int)whence { return [[[self alloc] initWithStream: stream offset: offset whence: whence] autorelease]; @@ -36,11 +36,11 @@ { OF_INVALID_INIT_METHOD } - initWithStream: (OFSeekableStream*)stream - offset: (off_t)offset + offset: (of_offset_t)offset whence: (int)whence { self = [super init]; _stream = [stream retain]; @@ -68,11 +68,11 @@ - (OFSeekableStream*)stream { OF_GETTER(_stream, true) } -- (off_t)offset +- (of_offset_t)offset { return _offset; } - (int)whence