Differences From Artifact [87d19ba681]:
- File
src/OFStdIOStream.m
— part of check-in
[c9621825fc]
at
2017-06-04 18:48:03
on branch trunk
— Treat MorphOS + ixemul as a separate platform
This reduces the ifdef hell and makes much more sense, as with ixemul,
no native calls are allowed. (user: js, size: 6784) [annotate] [blame] [check-ins using]
To Artifact [fac79ea11f]:
- File
src/OFStdIOStream.m
— part of check-in
[f9cd4f9cab]
at
2017-06-05 15:51:48
on branch trunk
— OFStream: Don't throw when at end of stream
Instead, let reads return 0 and let writes append after the end. (user: js, size: 6626) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFStdIOStream_Win32Console.h" #endif #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include <proto/exec.h> | > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFStdIOStream_Win32Console.h" #endif #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_MORPHOS # define BOOL EXEC_BOOL # include <proto/exec.h> |
︙ | ︙ | |||
163 164 165 166 167 168 169 | [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { #ifndef OF_MORPHOS if (_fd == -1) | < < > | | < | | < | | < | | < | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | [super dealloc]; } - (bool)lowlevelIsAtEndOfStream { #ifndef OF_MORPHOS if (_fd == -1) #else if (_handle == 0) #endif @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; #ifndef OF_MORPHOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS if ((ret = read(_fd, buffer, length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; # else if (length > UINT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = read(_fd, buffer, (unsigned int)length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: errno]; # endif #else if (_handle == 0) @throw [OFNotOpenException exceptionWithObject: self]; if (length > LONG_MAX) @throw [OFOutOfRangeException exception]; if ((ret = Read(_handle, buffer, 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 OF_MORPHOS if (_fd == -1) @throw [OFNotOpenException exceptionWithObject: self]; # ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (write(_fd, buffer, length) != (ssize_t)length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: errno]; # else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if (write(_fd, buffer, (int)length) != (int)length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: errno]; # endif #else if (_handle == 0) @throw [OFNotOpenException exceptionWithObject: self]; if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (Write(_handle, (void *)buffer, length) != (LONG)length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length]; |
︙ | ︙ |