summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAmrykid <amrykid@gmail.com>2011-12-27 09:34:45 -0600
committerAmrykid <amrykid@gmail.com>2011-12-27 09:49:47 -0600
commitf0f904ac70abec7bbab2c00075c9c4148a9b5132 (patch)
treec753ffe98edfb5271fa3fdd8cb28c249e1d78a00
parente978272d3c8da588292af8b7a95eb8ea03befbf4 (diff)
downloadNim-f0f904ac70abec7bbab2c00075c9c4148a9b5132.tar.gz
Documentation comments + slight code modifications to zipfiles.nim.
Changes made to osproc.nim so it will compile.
-rwxr-xr-xlib/impure/zipfiles.nim5
-rwxr-xr-xlib/pure/osproc.nim8
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim
index bf26f93bf..2f0be6b99 100755
--- a/lib/impure/zipfiles.nim
+++ b/lib/impure/zipfiles.nim
@@ -145,6 +145,7 @@ iterator walkFiles*(z: var TZipArchive): string =
 
 
 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)
   while true:
     if not strm.atEnd:
@@ -152,13 +153,15 @@ proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) =
     else: break
   dest.flush()
   strm.close()
-  dest.close()
 
 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)
   extractFile(z, srcFile, file)
+  file.close()
 
 proc extractAll*(z: var TZipArchive, dest: string) =
+  ## extracts all files from archive 'z' to the destination directory.
   for file in walkFiles(z):
     extractFile(z, file, dest & "/" & extractFilename(file))
 
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 99c128e4d..510dff232 100755
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -102,7 +102,7 @@ proc processID*(p: PProcess): int {.rtl, extern: "nosp$1".} =
   ## returns `p`'s process 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.
 
 proc peekExitCode*(p: PProcess): int
@@ -383,9 +383,7 @@ when defined(Windows) and not defined(useNimRtl):
       discard TerminateProcess(p.FProcessHandle, 0)
 
   proc waitForExit(p: PProcess, timeout: int = -1): int =
-    if timeout is -1:
-    	discard WaitForSingleObject(p.FProcessHandle, Infinite)
-    else: discard WaitForSingleObject(p.FProcessHandle, timeout)
+    discard WaitForSingleObject(p.FProcessHandle, timeout)
 
     var res: int32
     discard GetExitCodeProcess(p.FProcessHandle, res)
@@ -643,7 +641,7 @@ elif not defined(useNimRtl):
         if kill(-p.id, SIGKILL) != 0'i32: 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):
     # ``waitPid`` fails if the process is not running anymore. But then
     # ``running`` probably set ``p.exitCode`` for us. Since ``p.exitCode`` is