diff options
author | Araq <rumpf_a@web.de> | 2016-11-28 20:59:30 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2016-11-28 20:59:30 +0100 |
commit | 27723af469a937835b9679c41364d9db0090036e (patch) | |
tree | ecdd90e6287d4c172e63cae3f6b25169f4b88708 /lib/pure/asyncfile.nim | |
parent | ebaf57ea3bc17d1476e9d4bbd8d107eb6dd631a2 (diff) | |
parent | f9c184a4932eb839a6ec4b9293e37583cd33a89a (diff) | |
download | Nim-27723af469a937835b9679c41364d9db0090036e.tar.gz |
Merge branch 'devel' into sighashes
Diffstat (limited to 'lib/pure/asyncfile.nim')
-rw-r--r-- | lib/pure/asyncfile.nim | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim index ffe6a391e..0241e4796 100644 --- a/lib/pure/asyncfile.nim +++ b/lib/pure/asyncfile.nim @@ -118,8 +118,8 @@ proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = ## Read ``size`` bytes from the specified file asynchronously starting at ## the current position of the file pointer. ## - ## If the file pointer is past the end of the file then an empty string is - ## returned. + ## If the file pointer is past the end of the file then zero is returned + ## and no bytes are read into ``buf`` var retFuture = newFuture[int]("asyncfile.readBuffer") when defined(windows) or defined(nimdoc): @@ -149,7 +149,11 @@ proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = let err = osLastError() if err.int32 != ERROR_IO_PENDING: GC_unref(ol) - retFuture.fail(newException(OSError, osErrorMsg(err))) + if err.int32 == ERROR_HANDLE_EOF: + # This happens in Windows Server 2003 + retFuture.complete(0) + else: + retFuture.fail(newException(OSError, osErrorMsg(err))) else: # Request completed immediately. var bytesRead: DWord @@ -233,7 +237,12 @@ proc read*(f: AsyncFile, size: int): Future[string] = dealloc buffer buffer = nil GC_unref(ol) - retFuture.fail(newException(OSError, osErrorMsg(err))) + + if err.int32 == ERROR_HANDLE_EOF: + # This happens in Windows Server 2003 + retFuture.complete("") + else: + retFuture.fail(newException(OSError, osErrorMsg(err))) else: # Request completed immediately. var bytesRead: DWord |