@@ -33,10 +33,11 @@ #import "OFLocalization.h" #import "OFDataArray.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" +#import "OFNotOpenException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSeekFailedException.h" #import "OFWriteFailedException.h" @@ -307,23 +308,22 @@ } - (bool)lowlevelIsAtEndOfStream { if (!OF_FILE_HANDLE_IS_VALID(_handle)) - return true; + @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; - if (!OF_FILE_HANDLE_IS_VALID(_handle) || _atEndOfStream) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length]; + if (!OF_FILE_HANDLE_IS_VALID(_handle)) + @throw [OFNotOpenException exceptionWithObject: self]; #if defined(OF_WINDOWS) if (length > UINT_MAX) @throw [OFOutOfRangeException exception]; @@ -352,13 +352,12 @@ } - (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { - if (!OF_FILE_HANDLE_IS_VALID(_handle) || _atEndOfStream) - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length]; + if (!OF_FILE_HANDLE_IS_VALID(_handle)) + @throw [OFNotOpenException exceptionWithObject: self]; #if defined(OF_WINDOWS) if (length > INT_MAX) @throw [OFOutOfRangeException exception]; @@ -395,13 +394,11 @@ whence: (int)whence { of_offset_t ret; if (!OF_FILE_HANDLE_IS_VALID(_handle)) - @throw [OFSeekFailedException exceptionWithStream: self - offset: offset - whence: whence]; + @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_MORPHOS # if defined(OF_WINDOWS) ret = _lseeki64(_handle, offset, whence); # elif defined(OF_HAVE_OFF64_T)