ObjFW  Diff

Differences From Artifact [4cea821d7a]:

To Artifact [c3e373372b]:


31
32
33
34
35
36
37

38
39
40
41
42
43
44
#import "OFFile.h"
#import "OFString.h"
#import "OFLocalization.h"
#import "OFDataArray.h"

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"

#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSeekFailedException.h"
#import "OFWriteFailedException.h"

#ifdef OF_WINDOWS







>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#import "OFFile.h"
#import "OFString.h"
#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"

#ifdef OF_WINDOWS
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331

	return self;
}

- (bool)lowlevelIsAtEndOfStream
{
	if (!OF_FILE_HANDLE_IS_VALID(_handle))
		return true;

	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 defined(OF_WINDOWS)
	if (length > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	if ((ret = read(_handle, buffer, (unsigned int)length)) < 0)
		@throw [OFReadFailedException exceptionWithObject: self







|









|
|
<







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324

325
326
327
328
329
330
331

	return self;
}

- (bool)lowlevelIsAtEndOfStream
{
	if (!OF_FILE_HANDLE_IS_VALID(_handle))
		@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))
		@throw [OFNotOpenException exceptionWithObject: self];


#if defined(OF_WINDOWS)
	if (length > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	if ((ret = read(_handle, buffer, (unsigned int)length)) < 0)
		@throw [OFReadFailedException exceptionWithObject: self
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366

	return ret;
}

- (void)lowlevelWriteBuffer: (const void *)buffer
		     length: (size_t)length
{
	if (!OF_FILE_HANDLE_IS_VALID(_handle) || _atEndOfStream)
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length];

#if defined(OF_WINDOWS)
	if (length > INT_MAX)
		@throw [OFOutOfRangeException exception];

	if (write(_handle, buffer, (int)length) != (int)length)
		@throw [OFWriteFailedException exceptionWithObject: self







|
|
<







350
351
352
353
354
355
356
357
358

359
360
361
362
363
364
365

	return ret;
}

- (void)lowlevelWriteBuffer: (const void *)buffer
		     length: (size_t)length
{
	if (!OF_FILE_HANDLE_IS_VALID(_handle))
		@throw [OFNotOpenException exceptionWithObject: self];


#if defined(OF_WINDOWS)
	if (length > INT_MAX)
		@throw [OFOutOfRangeException exception];

	if (write(_handle, buffer, (int)length) != (int)length)
		@throw [OFWriteFailedException exceptionWithObject: self
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
			     whence: (int)whence
{
	of_offset_t ret;

	if (!OF_FILE_HANDLE_IS_VALID(_handle))
		@throw [OFSeekFailedException exceptionWithStream: self
							   offset: offset
							   whence: whence];

#ifndef OF_MORPHOS
# if defined(OF_WINDOWS)
	ret = _lseeki64(_handle, offset, whence);
# elif defined(OF_HAVE_OFF64_T)
	ret = lseek64(_handle, offset, whence);
# else







|
<
<







392
393
394
395
396
397
398
399


400
401
402
403
404
405
406

- (of_offset_t)lowlevelSeekToOffset: (of_offset_t)offset
			     whence: (int)whence
{
	of_offset_t ret;

	if (!OF_FILE_HANDLE_IS_VALID(_handle))
		@throw [OFNotOpenException exceptionWithObject: self];



#ifndef OF_MORPHOS
# if defined(OF_WINDOWS)
	ret = _lseeki64(_handle, offset, whence);
# elif defined(OF_HAVE_OFF64_T)
	ret = lseek64(_handle, offset, whence);
# else