diff options
author | Amrykid <amrykid@gmail.com> | 2011-12-24 12:14:17 -0600 |
---|---|---|
committer | Amrykid <amrykid@gmail.com> | 2011-12-24 12:14:17 -0600 |
commit | 2e0f9c8bf77a4baad539bfa162866f324ee94225 (patch) | |
tree | 1394b4947953c16a6e1bbb2618cfe8c679d7fcbf /lib | |
parent | 76f91b90e2a411a6d2ca82f075f55abe63d8f6a5 (diff) | |
download | Nim-2e0f9c8bf77a4baad539bfa162866f324ee94225.tar.gz |
- Added extractFile and extractAll to zipfiles.nim
-- Need to wait until libzip_all.c is updated to support Windows. - Started working on "koch update". -- Waiting on above to finish work.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/impure/zipfiles.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim index bdefc2c93..bf26f93bf 100755 --- a/lib/impure/zipfiles.nim +++ b/lib/impure/zipfiles.nim @@ -142,3 +142,25 @@ iterator walkFiles*(z: var TZipArchive): string = while i < num: yield $zip_get_name(z.w, i, 0'i32) inc(i) + + +proc extractFile*(z: var TZipArchive, srcFile: string, dest: PStream) = + var strm = getStream(z, srcFile) + while true: + if not strm.atEnd: + dest.write(strm.readStr(1)) + else: break + dest.flush() + strm.close() + dest.close() + +proc extractFile*(z: var TZipArchive, srcFile: string, dest: string) = + var file = newFileStream(dest, fmReadWrite) + extractFile(z, srcFile, file) + +proc extractAll*(z: var TZipArchive, dest: string) = + for file in walkFiles(z): + extractFile(z, file, dest & "/" & extractFilename(file)) + + + \ No newline at end of file |