@@ -36,10 +36,11 @@ #import "OFDictionary.h" #import "OFDataArray.h" #import "OFLocalization.h" #import "OFInitializationFailedException.h" +#import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_WINDOWS @@ -436,11 +437,11 @@ #ifndef OF_WINDOWS if (_readPipe[0] == -1) #else if (_readPipe[0] == NULL) #endif - return true; + @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer @@ -447,13 +448,12 @@ length: (size_t)length { #ifndef OF_WINDOWS ssize_t ret; - if (_readPipe[0] == -1 || _atEndOfStream) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length]; + if (_readPipe[0] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; if ((ret = read(_readPipe[0], buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; @@ -461,13 +461,12 @@ DWORD ret; if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; - if (_readPipe[0] == NULL || _atEndOfStream) - @throw [OFReadFailedException exceptionWithObject: self - requestedLength: length]; + if (_readPipe[0] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; if (!ReadFile(_readPipe[0], buffer, (DWORD)length, &ret, NULL)) { if (GetLastError() == ERROR_BROKEN_PIPE) { _atEndOfStream = true; return 0; @@ -486,13 +485,12 @@ - (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { #ifndef OF_WINDOWS - if (_writePipe[1] == -1 || _atEndOfStream) - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length]; + if (_writePipe[1] == -1) + @throw [OFNotOpenException exceptionWithObject: self]; if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (write(_writePipe[1], buffer, length) != (ssize_t)length) @@ -503,13 +501,12 @@ DWORD ret; if (length > UINT32_MAX) @throw [OFOutOfRangeException exception]; - if (_writePipe[1] == NULL || _atEndOfStream) - @throw [OFWriteFailedException exceptionWithObject: self - requestedLength: length]; + if (_writePipe[1] == NULL) + @throw [OFNotOpenException exceptionWithObject: self]; if (!WriteFile(_writePipe[1], buffer, (DWORD)length, &ret, NULL) || ret != (DWORD)length) { int errNo = 0;