summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/zipfs.36
-rw-r--r--doc/zipfs.n12
-rw-r--r--generic/tcl.decls8
-rw-r--r--generic/tclDecls.h10
-rw-r--r--generic/tclInterp.c2
-rw-r--r--generic/tclZipfs.c44
-rw-r--r--library/auto.tcl6
-rw-r--r--tests/safe-zipfs.test2
-rw-r--r--tests/zipfs.test32
9 files changed, 61 insertions, 61 deletions
diff --git a/doc/zipfs.3 b/doc/zipfs.3
index ae4551d..10a9dd0 100644
--- a/doc/zipfs.3
+++ b/doc/zipfs.3
@@ -17,10 +17,10 @@ const char *
\fBTclZipfs_AppHook(\fIargcPtr, argvPtr\fR)
.sp
int
-\fBTclZipfs_Mount\fR(\fIinterp, mountpoint, zipname, password\fR)
+\fBTclZipfs_Mount\fR(\fIinterp, zipname, mountpoint, password\fR)
.sp
int
-\fBTclZipfs_MountBuffer\fR(\fIinterp, mountpoint, data, dataLen, copy\fR)
+\fBTclZipfs_MountBuffer\fR(\fIinterp, data, dataLen, mountpoint, copy\fR)
.sp
int
\fBTclZipfs_Unmount\fR(\fIinterp, mountpoint\fR)
@@ -43,7 +43,7 @@ Name of a mount point, which must be a legal Tcl file or directory name. May
be NULL to query current mount points.
.AP "const char" *password in
An (optional) password. Use NULL if no password is wanted to read the file.
-.AP "unsigned char" *data in
+.AP "const void" *data in
A data buffer to mount. The data buffer must hold the contents of a ZIP
archive, and must not be NULL.
.AP size_t dataLen in
diff --git a/doc/zipfs.n b/doc/zipfs.n
index 5ce8cd2..b5495c2 100644
--- a/doc/zipfs.n
+++ b/doc/zipfs.n
@@ -26,12 +26,12 @@ zipfs \- Mount and work with ZIP files within Tcl
\fBzipfs mkimg\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR? ?\fIinfile\fR?
\fBzipfs mkkey\fR \fIpassword\fR
\fBzipfs mkzip\fR \fIoutfile indir\fR ?\fIstrip\fR? ?\fIpassword\fR?
-\fBzipfs mount\fR ?\fImountpoint\fR? ?\fIzipfile\fR? ?\fIpassword\fR?
+\fBzipfs mount\fR ?\fIzipfile\fR? ?\fImountpoint\fR? ?\fIpassword\fR?
\fBzipfs root\fR
\fBzipfs unmount\fR \fImountpoint\fR
.fi
'\" The following subcommand is *UNDOCUMENTED*
-'\" \fBzipfs mount_data\fR ?\fImountpoint\fR? ?\fIdata\fR?
+'\" \fBzipfs mount_data\fR ?\fIdata\fR ?\fImountpoint\fR??
.BE
.SH DESCRIPTION
.PP
@@ -84,7 +84,7 @@ Return a list of all files in the mounted zipfs, or just those matching
\fIpattern\fR (optionally controlled by the option parameters). The order of
the names in the list is arbitrary.
.TP
-\fBzipfs mount\fR ?\fImountpoint\fR? ?\fIzipfile\fR? ?\fIpassword\fR?
+\fBzipfs mount\fR ?\fIzipfile\fR? ?\fImountpoint\fR? ?\fIpassword\fR?
.
The \fBzipfs mount\fR command mounts a ZIP archive file as a Tcl virtual
filesystem at \fImountpoint\fR. After this command executes, files contained
@@ -186,13 +186,13 @@ before unmounting it again:
set zip myApp.zip
set base [file join [\fBzipfs root\fR] myApp]
-\fBzipfs mount\fR $base $zip
+\fBzipfs mount\fR $zip $base
# $base now has the contents of myApp.zip
source [file join $base app.tcl]
# use the contents, load libraries from it, etc...
-\fBzipfs unmount\fR $zip
+\fBzipfs unmount\fR $base
.CE
.PP
Creating a ZIP archive, given that a directory exists containing the content
@@ -219,7 +219,7 @@ set base [file join [\fBzipfs root\fR] myApp]
\fBzipfs mkzip\fR $targetZip $sourceDir $sourceDir $password
# Mount with password
-\fBzipfs mount\fR $base $zip $password
+\fBzipfs mount\fR $zip $base $password
.CE
.PP
When creating an executable image with a password, the password is placed
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 6517c8f..6ca10c0 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -2395,8 +2395,8 @@ declare 631 {
# TIP #430
declare 632 {
- int TclZipfs_Mount(Tcl_Interp *interp, const char *mountPoint,
- const char *zipname, const char *passwd)
+ int TclZipfs_Mount(Tcl_Interp *interp, const char *zipname,
+ const char *mountPoint, const char *passwd)
}
declare 633 {
int TclZipfs_Unmount(Tcl_Interp *interp, const char *mountPoint)
@@ -2405,8 +2405,8 @@ declare 634 {
Tcl_Obj *TclZipfs_TclLibrary(void)
}
declare 635 {
- int TclZipfs_MountBuffer(Tcl_Interp *interp, const char *mountPoint,
- unsigned char *data, size_t datalen, int copy)
+ int TclZipfs_MountBuffer(Tcl_Interp *interp, const void *data,
+ size_t datalen, const char *mountPoint, int copy)
}
# TIP #445
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 31c59df..25a11d8 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1696,7 +1696,7 @@ EXTERN Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp,
void *callbackData);
/* 632 */
EXTERN int TclZipfs_Mount(Tcl_Interp *interp,
- const char *mountPoint, const char *zipname,
+ const char *zipname, const char *mountPoint,
const char *passwd);
/* 633 */
EXTERN int TclZipfs_Unmount(Tcl_Interp *interp,
@@ -1705,8 +1705,8 @@ EXTERN int TclZipfs_Unmount(Tcl_Interp *interp,
EXTERN Tcl_Obj * TclZipfs_TclLibrary(void);
/* 635 */
EXTERN int TclZipfs_MountBuffer(Tcl_Interp *interp,
- const char *mountPoint, unsigned char *data,
- size_t datalen, int copy);
+ const void *data, size_t datalen,
+ const char *mountPoint, int copy);
/* 636 */
EXTERN void Tcl_FreeInternalRep(Tcl_Obj *objPtr);
/* 637 */
@@ -2511,10 +2511,10 @@ typedef struct TclStubs {
int (*tcl_FSUnloadFile) (Tcl_Interp *interp, Tcl_LoadHandle handlePtr); /* 629 */
void (*tcl_ZlibStreamSetCompressionDictionary) (Tcl_ZlibStream zhandle, Tcl_Obj *compressionDictionaryObj); /* 630 */
Tcl_Channel (*tcl_OpenTcpServerEx) (Tcl_Interp *interp, const char *service, const char *host, unsigned int flags, int backlog, Tcl_TcpAcceptProc *acceptProc, void *callbackData); /* 631 */
- int (*tclZipfs_Mount) (Tcl_Interp *interp, const char *mountPoint, const char *zipname, const char *passwd); /* 632 */
+ int (*tclZipfs_Mount) (Tcl_Interp *interp, const char *zipname, const char *mountPoint, const char *passwd); /* 632 */
int (*tclZipfs_Unmount) (Tcl_Interp *interp, const char *mountPoint); /* 633 */
Tcl_Obj * (*tclZipfs_TclLibrary) (void); /* 634 */
- int (*tclZipfs_MountBuffer) (Tcl_Interp *interp, const char *mountPoint, unsigned char *data, size_t datalen, int copy); /* 635 */
+ int (*tclZipfs_MountBuffer) (Tcl_Interp *interp, const void *data, size_t datalen, const char *mountPoint, int copy); /* 635 */
void (*tcl_FreeInternalRep) (Tcl_Obj *objPtr); /* 636 */
char * (*tcl_InitStringRep) (Tcl_Obj *objPtr, const char *bytes, TCL_HASH_TYPE numBytes); /* 637 */
Tcl_ObjInternalRep * (*tcl_FetchInternalRep) (Tcl_Obj *objPtr, const Tcl_ObjType *typePtr); /* 638 */
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index 79b4634..bd79497 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -401,12 +401,12 @@ Tcl_Init(
"if {$tail eq [info tclversion]} continue\n"
"file join [file dirname $env(TCL_LIBRARY)] tcl[info tclversion]}\n"
" }\n"
+" lappend scripts {::tcl::zipfs::tcl_library_init}\n"
" if {[info exists tclDefaultLibrary]} {\n"
" lappend scripts {set tclDefaultLibrary}\n"
" } else {\n"
" lappend scripts {::tcl::pkgconfig get scriptdir,runtime}\n"
" }\n"
-" lappend scripts {::tcl::zipfs::tcl_library_init}\n"
" lappend scripts {\n"
"set parentDir [file dirname [file dirname [info nameofexecutable]]]\n"
"set grandParentDir [file dirname $parentDir]\n"
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 2df7705..ba2471d 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -1966,9 +1966,9 @@ DescribeMounted(
int
TclZipfs_Mount(
Tcl_Interp *interp, /* Current interpreter. NULLable. */
- const char *mountPoint, /* Mount point path. */
const char *zipname, /* Path to ZIP file to mount; should be
* normalized. */
+ const char *mountPoint, /* Mount point path. */
const char *passwd) /* Password for opening the ZIP, or NULL if
* the ZIP is unprotected. */
{
@@ -2044,9 +2044,9 @@ TclZipfs_Mount(
int
TclZipfs_MountBuffer(
Tcl_Interp *interp, /* Current interpreter. NULLable. */
- const char *mountPoint, /* Mount point path. */
- unsigned char *data,
+ const void *data,
size_t datalen,
+ const char *mountPoint, /* Mount point path. */
int copy)
{
ZipFile *zf;
@@ -2098,7 +2098,7 @@ TclZipfs_MountBuffer(
memcpy(zf->data, data, datalen);
zf->ptrToFree = zf->data;
} else {
- zf->data = data;
+ zf->data = (unsigned char *) data;
zf->ptrToFree = NULL;
}
if (ZipFSFindTOC(interp, 0, zf) != TCL_OK) {
@@ -2222,14 +2222,11 @@ ZipFSMountObjCmd(
if (objc > 4) {
Tcl_WrongNumArgs(interp, 1, objv,
- "?mountpoint? ?zipfile? ?password?");
+ "?zipfile? ?mountpoint? ?password?");
return TCL_ERROR;
}
if (objc > 1) {
- mountPoint = TclGetString(objv[1]);
- }
- if (objc > 2) {
- zipFileObj = Tcl_FSGetNormalizedPath(interp, objv[2]);
+ zipFileObj = Tcl_FSGetNormalizedPath(interp, objv[1]);
if (!zipFileObj) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"could not normalize zip filename", -1));
@@ -2239,11 +2236,14 @@ ZipFSMountObjCmd(
Tcl_IncrRefCount(zipFileObj);
zipFile = TclGetString(zipFileObj);
}
+ if (objc > 2) {
+ mountPoint = TclGetString(objv[2]);
+ }
if (objc > 3) {
password = TclGetString(objv[3]);
}
- result = TclZipfs_Mount(interp, mountPoint, zipFile, password);
+ result = TclZipfs_Mount(interp, zipFile, mountPoint, password);
if (zipFileObj != NULL) {
Tcl_DecrRefCount(zipFileObj);
}
@@ -2278,7 +2278,7 @@ ZipFSMountBufferObjCmd(
Tcl_Size length;
if (objc > 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "?mountpoint? ?data?");
+ Tcl_WrongNumArgs(interp, 1, objv, "?data? ?mountpoint?");
return TCL_ERROR;
}
if (objc < 2) {
@@ -2290,19 +2290,19 @@ ZipFSMountBufferObjCmd(
return ret;
}
- mountPoint = TclGetString(objv[1]);
if (objc < 3) {
ReadLock();
- DescribeMounted(interp, mountPoint);
+ DescribeMounted(interp, TclGetString(objv[1]));
Unlock();
return TCL_OK;
}
- data = Tcl_GetBytesFromObj(interp, objv[2], &length);
+ data = Tcl_GetBytesFromObj(interp, objv[1], &length);
+ mountPoint = TclGetString(objv[2]);
if (data == NULL) {
return TCL_ERROR;
}
- return TclZipfs_MountBuffer(interp, mountPoint, data, length, 1);
+ return TclZipfs_MountBuffer(interp, data, length, mountPoint, 1);
}
/*
@@ -2356,7 +2356,7 @@ ZipFSUnmountObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
if (objc != 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "zipfile");
+ Tcl_WrongNumArgs(interp, 1, objv, "mountpoint");
return TCL_ERROR;
}
return TclZipfs_Unmount(interp, TclGetString(objv[1]));
@@ -5701,7 +5701,7 @@ ZipfsAppHookFindTclInit(
if (zipfs_literal_tcl_library) {
return TCL_ERROR;
}
- if (TclZipfs_Mount(NULL, ZIPFS_ZIP_MOUNT, archive, NULL)) {
+ if (TclZipfs_Mount(NULL, archive, ZIPFS_ZIP_MOUNT, NULL)) {
/* Either the file doesn't exist or it is not a zip archive */
return TCL_ERROR;
}
@@ -5815,7 +5815,7 @@ TclZipfs_AppHook(
* function.
*/
- if (!TclZipfs_Mount(NULL, ZIPFS_APP_MOUNT, archive, NULL)) {
+ if (!TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL)) {
int found;
Tcl_Obj *vfsInitScript;
@@ -5877,7 +5877,7 @@ TclZipfs_AppHook(
Tcl_SetStartupScript(vfsInitScript, NULL);
}
return result;
- } else if (!TclZipfs_Mount(NULL, ZIPFS_APP_MOUNT, archive, NULL)) {
+ } else if (!TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL)) {
int found;
Tcl_Obj *vfsInitScript;
@@ -5926,8 +5926,8 @@ TclZipfs_AppHook(
int
TclZipfs_Mount(
Tcl_Interp *interp, /* Current interpreter. */
- TCL_UNUSED(const char *), /* Mount point path. */
TCL_UNUSED(const char *), /* Path to ZIP file to mount. */
+ TCL_UNUSED(const char *), /* Mount point path. */
TCL_UNUSED(const char *)) /* Password for opening the ZIP, or NULL if
* the ZIP is unprotected. */
{
@@ -5939,9 +5939,9 @@ TclZipfs_Mount(
int
TclZipfs_MountBuffer(
Tcl_Interp *interp, /* Current interpreter. NULLable. */
- TCL_UNUSED(const char *), /* Mount point path. */
- TCL_UNUSED(unsigned char *),
+ TCL_UNUSED(const void *),
TCL_UNUSED(size_t),
+ TCL_UNUSED(const char *), /* Mount point path. */
TCL_UNUSED(int))
{
ZIPFS_ERROR(interp, "no zlib available");
diff --git a/library/auto.tcl b/library/auto.tcl
index 0bfd4f4..44e2c57 100644
--- a/library/auto.tcl
+++ b/library/auto.tcl
@@ -92,7 +92,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
break
}
set found 1
- zipfs mount $mountpoint $dllfile
+ zipfs mount $dllfile $mountpoint
break
}
if {!$found} {
@@ -118,7 +118,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
if {![file exists $archive]} {
continue
}
- zipfs mount $mountpoint $archive
+ zipfs mount $archive $mountpoint
if {[zipfs exists [file join $mountpoint ${basename}_library $initScript]]} {
lappend dirs [file join $mountpoint ${basename}_library]
set found 1
@@ -128,7 +128,7 @@ proc tcl_findLibrary {basename version patch initScript enVarName varName} {
set found 1
break
} else {
- catch {zipfs unmount $archive}
+ catch {zipfs unmount $mountpoint}
}
}
}
diff --git a/tests/safe-zipfs.test b/tests/safe-zipfs.test
index 41c4b78..52ec6c4 100644
--- a/tests/safe-zipfs.test
+++ b/tests/safe-zipfs.test
@@ -31,7 +31,7 @@ apply [list {} {
set TestsDir [file normalize [file dirname [info script]]]
set ZipMountPoint [zipfs root]auto-files
- zipfs mount $ZipMountPoint [file join $TestsDir auto-files.zip]
+ zipfs mount [file join $TestsDir auto-files.zip] $ZipMountPoint
set PathMapp {}
lappend PathMapp $tcl_library TCLLIB $TestsDir TESTSDIR $ZipMountPoint ZIPDIR
diff --git a/tests/zipfs.test b/tests/zipfs.test
index bf9c969..8c98697 100644
--- a/tests/zipfs.test
+++ b/tests/zipfs.test
@@ -42,7 +42,7 @@ if {![string match ${ziproot}* $tcl_library]} {
set tclzip [file join $CWD libtcl[info patchlevel].zip]
testConstraint zipfslib [file isfile $tclzip]
if {[testConstraint zipfslib]} {
- zipfs mount /lib/tcl $tclzip
+ zipfs mount $tclzip /lib/tcl
set ::tcl_library ${ziproot}lib/tcl/tcl_library
}
}
@@ -93,10 +93,10 @@ test zipfs-0.12 {zipfs basics: join} -constraints {zipfs zipfslib} -body {
test zipfs-1.3 {zipfs errors} -constraints zipfs -returnCodes error -body {
zipfs mount a b c d e f
-} -result {wrong # args: should be "zipfs mount ?mountpoint? ?zipfile? ?password?"}
+} -result {wrong # args: should be "zipfs mount ?zipfile? ?mountpoint? ?password?"}
test zipfs-1.4 {zipfs errors} -constraints zipfs -returnCodes error -body {
zipfs unmount a b c d e f
-} -result {wrong # args: should be "zipfs unmount zipfile"}
+} -result {wrong # args: should be "zipfs unmount mountpoint"}
test zipfs-1.5 {zipfs errors} -constraints zipfs -returnCodes error -body {
zipfs mkkey a b c d e f
} -result {wrong # args: should be "zipfs mkkey password"}
@@ -131,7 +131,7 @@ if {[file exists $zipfile]} {
test zipfs-2.2 {zipfs mkzip} -constraints zipfs -body {
cd $tcl_library/encoding
zipfs mkzip $zipfile .
- zipfs mount ${ziproot}abc $zipfile
+ zipfs mount $zipfile ${ziproot}abc
zipfs list -glob ${ziproot}abc/cp850.*
} -cleanup {
cd $CWD
@@ -186,7 +186,7 @@ test zipfs-2.8 {zipfs mkzip} -constraints zipfs -body {
fconfigure $fin -translation binary
set dat [read $fin]
close $fin
- zipfs mount_data def $dat
+ zipfs mount_data $dat def
zipfs list -glob ${ziproot}def/cp850.*
} -cleanup {
cd $CWD
@@ -278,7 +278,7 @@ test zipfs-4.1 {zipfs lmkimg} -constraints zipfs -setup {
file delete $targetImage
} -body {
zipfs lmkimg $targetImage [list $addFile test/add.tcl] {} $baseImage
- zipfs mount ziptest $targetImage
+ zipfs mount $targetImage ziptest
try {
list [source $targetImage] [source //zipfs:/ziptest/test/add.tcl]
} finally {
@@ -298,7 +298,7 @@ test zipfs-4.2 {zipfs lmkimg: making an image from an image} -constraints zipfs
} -body {
zipfs lmkimg $midImage [list $addFile test/ko.tcl] {} $baseImage
zipfs lmkimg $targetImage [list $addFile test/ok.tcl] {} $midImage
- zipfs mount ziptest $targetImage
+ zipfs mount $targetImage ziptest
try {
list [glob -tails -directory //zipfs://ziptest/test *.tcl] \
[if {[file size $midImage] == [file size $targetImage]} {
@@ -325,7 +325,7 @@ test zipfs-4.3 {zipfs lmkimg: stripping password} -constraints zipfs -setup {
set pass gorp
zipfs lmkimg $midImage [list $addFile test/add.tcl] $pass $baseImage
zipfs lmkimg $targetImage [list $addFile test/ok.tcl] {} $midImage
- zipfs mount ziptest $targetImage
+ zipfs mount $targetImage ziptest
try {
glob -tails -directory //zipfs://ziptest/test *.tcl
} finally {
@@ -347,7 +347,7 @@ test zipfs-4.4 {zipfs lmkimg: final password} -constraints zipfs -setup {
set pass gorp
zipfs lmkimg $midImage [list $addFile test/add.tcl] {} $baseImage
zipfs lmkimg $targetImage [list $addFile test/ok.tcl] $pass $midImage
- zipfs mount ziptest $targetImage
+ zipfs mount $targetImage ziptest
try {
glob -tails -directory //zipfs://ziptest/test *.tcl
} finally {
@@ -367,11 +367,11 @@ test zipfs-4.5 {zipfs lmkimg: making image from mounted} -constraints zipfs -set
file delete $midImage $targetImage
} -body {
zipfs lmkimg $midImage [list $addFile test/add.tcl] {} $baseImage
- zipfs mount ziptest $midImage
+ zipfs mount $midImage ziptest
set f [glob -directory //zipfs://ziptest/test *.tcl]
zipfs lmkimg $targetImage [list $f test/ok.tcl] {} $midImage
zipfs unmount ziptest
- zipfs mount ziptest $targetImage
+ zipfs mount $targetImage ziptest
list $f [glob -directory //zipfs://ziptest/test *.tcl]
} -cleanup {
zipfs unmount ziptest
@@ -382,20 +382,20 @@ test zipfs-4.5 {zipfs lmkimg: making image from mounted} -constraints zipfs -set
} -result {//zipfs://ziptest/test/add.tcl //zipfs://ziptest/test/ok.tcl}
test zipfs-5.1 {zipfs mount_data: short data} -constraints zipfs -body {
- zipfs mount_data gorp {}
+ zipfs mount_data {} gorp
} -returnCodes error -result {bad zip data}
test zipfs-5.2 {zipfs mount_data: short data} -constraints zipfs -body {
- zipfs mount_data gorp gorpGORPgorp
+ zipfs mount_data gorpGORPgorp gorp
} -returnCodes error -result {bad zip data}
test zipfs-5.3 {zipfs mount_data: short data} -constraints zipfs -body {
set data PK\x03\x04.....................................
append data PK\x01\x02.....................................
append data PK\x05\x06.....................................
- zipfs mount_data gorp $data
+ zipfs mount_data $data gorp
} -returnCodes error -result {bad zip data}
test zipfs-5.4 {zipfs mount_data: bad arg count} -constraints zipfs -body {
- zipfs mount_data gorp {} foobar
-} -returnCodes error -result {wrong # args: should be "zipfs mount_data ?mountpoint? ?data?"}
+ zipfs mount_data {} gorp foobar
+} -returnCodes error -result {wrong # args: should be "zipfs mount_data ?data? ?mountpoint?"}
test zipfs-6.1 {zipfs mkkey} -constraints zipfs -body {
binary scan [zipfs mkkey gorp] cu* x