Documentation comments + slight code modifications to zipfiles.nim.
Changes made to osproc.nim so it will compile.
This commit is contained in:
parent
e978272d3c
commit
f0f904ac70
2 changed files with 7 additions and 6 deletions
|
|
@ -145,6 +145,7 @@ iterator walkFiles*(z: var TZipArchive): string =
|
||||||
|
|
||||||
|
|
||||||
proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) =
|
proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) =
|
||||||
|
## extracts a file from the zip archive 'z' to the destination stream.
|
||||||
var strm = getStream(z, srcFile)
|
var strm = getStream(z, srcFile)
|
||||||
while true:
|
while true:
|
||||||
if not strm.atEnd:
|
if not strm.atEnd:
|
||||||
|
|
@ -152,13 +153,15 @@ proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) =
|
||||||
else: break
|
else: break
|
||||||
dest.flush()
|
dest.flush()
|
||||||
strm.close()
|
strm.close()
|
||||||
dest.close()
|
|
||||||
|
|
||||||
proc extractFile*(z: var TZipArchive, srcFile: string, dest: string) =
|
proc extractFile*(z: var TZipArchive, srcFile: string, dest: string) =
|
||||||
|
## extracts a file from the zip archive 'z' to the destination filename.
|
||||||
var file = newFileStream(dest, fmReadWrite)
|
var file = newFileStream(dest, fmReadWrite)
|
||||||
extractFile(z, srcFile, file)
|
extractFile(z, srcFile, file)
|
||||||
|
file.close()
|
||||||
|
|
||||||
proc extractAll*(z: var TZipArchive, dest: string) =
|
proc extractAll*(z: var TZipArchive, dest: string) =
|
||||||
|
## extracts all files from archive 'z' to the destination directory.
|
||||||
for file in walkFiles(z):
|
for file in walkFiles(z):
|
||||||
extractFile(z, file, dest & "/" & extractFilename(file))
|
extractFile(z, file, dest & "/" & extractFilename(file))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ proc processID*(p: PProcess): int {.rtl, extern: "nosp$1".} =
|
||||||
## returns `p`'s process ID.
|
## returns `p`'s process ID.
|
||||||
return p.id
|
return p.id
|
||||||
|
|
||||||
proc waitForExit*(p: PProcess): int {.rtl, extern: "nosp$1".}
|
proc waitForExit*(p: PProcess, timeout: int = -1): int {.rtl, extern: "nosp$1".}
|
||||||
## waits for the process to finish and returns `p`'s error code.
|
## waits for the process to finish and returns `p`'s error code.
|
||||||
|
|
||||||
proc peekExitCode*(p: PProcess): int
|
proc peekExitCode*(p: PProcess): int
|
||||||
|
|
@ -383,9 +383,7 @@ when defined(Windows) and not defined(useNimRtl):
|
||||||
discard TerminateProcess(p.FProcessHandle, 0)
|
discard TerminateProcess(p.FProcessHandle, 0)
|
||||||
|
|
||||||
proc waitForExit(p: PProcess, timeout: int = -1): int =
|
proc waitForExit(p: PProcess, timeout: int = -1): int =
|
||||||
if timeout is -1:
|
discard WaitForSingleObject(p.FProcessHandle, timeout)
|
||||||
discard WaitForSingleObject(p.FProcessHandle, Infinite)
|
|
||||||
else: discard WaitForSingleObject(p.FProcessHandle, timeout)
|
|
||||||
|
|
||||||
var res: int32
|
var res: int32
|
||||||
discard GetExitCodeProcess(p.FProcessHandle, res)
|
discard GetExitCodeProcess(p.FProcessHandle, res)
|
||||||
|
|
@ -643,7 +641,7 @@ elif not defined(useNimRtl):
|
||||||
if kill(-p.id, SIGKILL) != 0'i32: OSError()
|
if kill(-p.id, SIGKILL) != 0'i32: OSError()
|
||||||
else: OSError()
|
else: OSError()
|
||||||
|
|
||||||
proc waitForExit(p: PProcess): int =
|
proc waitForExit(p: PProcess, timeout: int = -1): int =
|
||||||
#if waitPid(p.id, p.exitCode, 0) == int(p.id):
|
#if waitPid(p.id, p.exitCode, 0) == int(p.id):
|
||||||
# ``waitPid`` fails if the process is not running anymore. But then
|
# ``waitPid`` fails if the process is not running anymore. But then
|
||||||
# ``running`` probably set ``p.exitCode`` for us. Since ``p.exitCode`` is
|
# ``running`` probably set ``p.exitCode`` for us. Since ``p.exitCode`` is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue