- 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.
This commit is contained in:
parent
76f91b90e2
commit
2e0f9c8bf7
2 changed files with 42 additions and 0 deletions
20
koch.nim
20
koch.nim
|
|
@ -34,6 +34,7 @@ Possible Commands:
|
||||||
zip builds the installation ZIP package
|
zip builds the installation ZIP package
|
||||||
inno [options] builds the Inno Setup installer (for Windows)
|
inno [options] builds the Inno Setup installer (for Windows)
|
||||||
tests run the testsuite
|
tests run the testsuite
|
||||||
|
update updates nimrod to the latest version from the repo.
|
||||||
Boot options:
|
Boot options:
|
||||||
-d:release produce a release version of the compiler
|
-d:release produce a release version of the compiler
|
||||||
-d:tinyc include the Tiny C backend (not supported on Windows)
|
-d:tinyc include the Tiny C backend (not supported on Windows)
|
||||||
|
|
@ -78,6 +79,24 @@ proc web(args: string) =
|
||||||
exec("nimrod cc -r tools/nimweb.nim web/nimrod --putenv:nimrodversion=$#" %
|
exec("nimrod cc -r tools/nimweb.nim web/nimrod --putenv:nimrodversion=$#" %
|
||||||
NimrodVersion)
|
NimrodVersion)
|
||||||
|
|
||||||
|
proc update(args: string) =
|
||||||
|
if ExistFile("./.git"):
|
||||||
|
# use git to download latest source
|
||||||
|
exec("git pull")
|
||||||
|
else:
|
||||||
|
# use dom96's httpclient to download zip
|
||||||
|
import httpclient
|
||||||
|
import zipfiles
|
||||||
|
downloadFile("https://github.com/Araq/Nimrod/zipball/master","./update.zip")
|
||||||
|
|
||||||
|
var zip :TZipArchive
|
||||||
|
discard open(zip,fmRead) # will add error checking later
|
||||||
|
extractAll(zip,"./")
|
||||||
|
|
||||||
|
exec("./koch boot -d:release")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -------------- boot ---------------------------------------------------------
|
# -------------- boot ---------------------------------------------------------
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -204,6 +223,7 @@ of cmdArgument:
|
||||||
of "inno": inno(op.cmdLineRest)
|
of "inno": inno(op.cmdLineRest)
|
||||||
of "install": install(op.cmdLineRest)
|
of "install": install(op.cmdLineRest)
|
||||||
of "test", "tests": tests(op.cmdLineRest)
|
of "test", "tests": tests(op.cmdLineRest)
|
||||||
|
of "update", "up": update(op.cmdLineRest)
|
||||||
else: showHelp()
|
else: showHelp()
|
||||||
of cmdEnd: showHelp()
|
of cmdEnd: showHelp()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,3 +142,25 @@ iterator walkFiles*(z: var TZipArchive): string =
|
||||||
while i < num:
|
while i < num:
|
||||||
yield $zip_get_name(z.w, i, 0'i32)
|
yield $zip_get_name(z.w, i, 0'i32)
|
||||||
inc(i)
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue