Differences From Artifact [fd77a17f17]:
- File
src/OFFile.m
— part of check-in
[9da9b2b64c]
at
2014-04-14 00:45:58
on branch trunk
— Coding style
No functional change intended. (user: js, size: 20661) [annotate] [blame] [check-ins using]
To Artifact [c90f56e169]:
- File
src/OFFile.m
— part of check-in
[4e59d2692f]
at
2014-04-26 00:40:17
on branch trunk
— Fix a few issues on LLP64 and Win64
LLP64 was mostly fast enumeration using an unsigned long for the state,
which can't store a pointer or a size_t on LLP64. This is now solved by
either throwing an OFOutOfRangeException if the value of the size_t is
bigger than ULONG_MAX or storing the pointer in the extra field (copied
using memcpy, as it's an array of unsigned long, which again would be
too small to store a pointer).Win64 was mostly Microsoft not being able to decide whether a length is
a size_t, a DWORD, an int or an unsigned int (thus the different types
in places that seem to be almost the same). But since that would not be
confusing enough, a file descriptor is an int if it's for a file, but a
long long if it is for a socket. But of course, for ReadFile and friends
it's a DWORD instead of an int then. (user: js, size: 21261) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFSeekFailedException.h" #import "OFUnlockFailedException.h" #import "OFWriteFailedException.h" #import "autorelease.h" | > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFSeekFailedException.h" #import "OFUnlockFailedException.h" #import "OFWriteFailedException.h" #import "autorelease.h" |
︙ | ︙ | |||
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { ssize_t ret; if (_fd == -1 || _atEndOfStream || (ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; if (ret == 0) _atEndOfStream = true; return ret; } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; } - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { off_t ret = lseek(_fd, offset, whence); | > > > > > > > > > > > > > > > > > > > > | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 | } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { ssize_t ret; #ifndef _WIN32 if (_fd == -1 || _atEndOfStream || (ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; #else if (length > UINT_MAX) @throw [OFOutOfRangeException exception]; if (_fd == -1 || _atEndOfStream || (ret = read(_fd, buffer, (unsigned int)length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; #endif if (ret == 0) _atEndOfStream = true; return ret; } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { #ifndef _WIN32 if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; #else if (length > UINT_MAX) @throw [OFOutOfRangeException exception]; if (_fd == -1 || _atEndOfStream || write(_fd, buffer, (unsigned int)length) < length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; #endif } - (off_t)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { off_t ret = lseek(_fd, offset, whence); |
︙ | ︙ |