ObjFW  Diff

Differences From Artifact [8b087c9ef5]:

To Artifact [754335c8dd]:

  • File src/OFProcess.m — part of check-in [8d2a5052fd] at 2014-01-25 17:39:13 on branch trunk — Generalize stream / socket related exceptions

    This is in preparation for adding UDP sockets, as UDP sockets and TCP
    sockets have no common superclass, as one is stream-oriented while the
    other is packet-oriented.

    Read and write exceptions are for any object now, as they are useful for
    a lot more than just for streams, while the others (bind, listen, etc.)
    are for any socket now (the type is id in this case, though, as there is
    no common superclass). (user: js, size: 11519) [annotate] [blame] [check-ins using]


402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
	    !ReadFile(_readPipe[0], buffer, length, &ret, NULL)) {
		if (GetLastError() == ERROR_BROKEN_PIPE) {
			_atEndOfStream = true;
			return 0;
		}

#endif
		@throw [OFReadFailedException exceptionWithStream: self
						  requestedLength: length];
	}

	if (ret == 0)
		_atEndOfStream = true;

	return ret;







|







402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
	    !ReadFile(_readPipe[0], buffer, length, &ret, NULL)) {
		if (GetLastError() == ERROR_BROKEN_PIPE) {
			_atEndOfStream = true;
			return 0;
		}

#endif
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length];
	}

	if (ret == 0)
		_atEndOfStream = true;

	return ret;
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#else
	DWORD ret;

	if (_writePipe[1] == NULL || _atEndOfStream ||
	    !WriteFile(_writePipe[1], buffer, length, &ret, NULL) ||
	    ret < length)
#endif
		@throw [OFWriteFailedException exceptionWithStream: self
						   requestedLength: length];
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _readPipe[0];







|







425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#else
	DWORD ret;

	if (_writePipe[1] == NULL || _atEndOfStream ||
	    !WriteFile(_writePipe[1], buffer, length, &ret, NULL) ||
	    ret < length)
#endif
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length];
}

- (int)fileDescriptorForReading
{
#ifndef _WIN32
	return _readPipe[0];