From db234eeee9bc569615b0e5969fe0c39a9eda5875 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 7 Sep 2023 10:46:30 +0000 Subject: Experiment: What if we changed "//zipfs:/" to "/zipfs:/", which doesn't look like an UNC path any more? --- doc/zipfs.3 | 2 +- doc/zipfs.n | 4 ++-- generic/tclZipfs.c | 9 ++++----- tests/zipfs.test | 14 +++++++------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/zipfs.3 b/doc/zipfs.3 index c8ee455..7ff7ee2 100644 --- a/doc/zipfs.3 +++ b/doc/zipfs.3 @@ -61,7 +61,7 @@ follows: .IP [1] If the current application has a mountable ZIP archive, that archive is mounted under \fIZIPFS_VOLUME\fBapp\fR as a read-only Tcl virtual file -system. \fIZIPFS_VOLUME\fR is \fB//zipfs:/\fR on all platforms. +system. \fIZIPFS_VOLUME\fR is \fB/zipfs:/\fR on all platforms. .IP [2] If a file named \fBmain.tcl\fR is located in the root directory of that file system (i.e., at \fIZIPROOT\fB/app/main.tcl\fR after the ZIP archive is diff --git a/doc/zipfs.n b/doc/zipfs.n index 5ce8cd2..577be7b 100644 --- a/doc/zipfs.n +++ b/doc/zipfs.n @@ -108,7 +108,7 @@ to access the files inside the mount). Returns a constant string which indicates the mount point for zipfs volumes for the current platform. This value is -.QW \fB//zipfs:/\fR . +.QW \fB/zipfs:/\fR . .TP \fBzipfs unmount \fImountpoint\fR . @@ -244,7 +244,7 @@ close $f # Launch the executable, printing its output to stdout exec $img >@stdout -# prints: \fIHi. This is //zipfs:/app/main.tcl\fR +# prints: \fIHi. This is /zipfs:/app/main.tcl\fR .CE .SH "SEE ALSO" tclsh(1), file(n), zipfs(3), zlib(n) diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index cfb0cf7..56a25e3 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -81,10 +81,10 @@ static const z_crc_t* crc32tab; ** TIP430 style zipfs prefix */ -#define ZIPFS_VOLUME "//zipfs:/" -#define ZIPFS_VOLUME_LEN 9 -#define ZIPFS_APP_MOUNT "//zipfs:/app" -#define ZIPFS_ZIP_MOUNT "//zipfs:/lib/tcl" +#define ZIPFS_VOLUME "/zipfs:/" +#define ZIPFS_VOLUME_LEN 8 +#define ZIPFS_APP_MOUNT ZIPFS_VOLUME "app" +#define ZIPFS_ZIP_MOUNT ZIPFS_VOLUME "lib/tcl" #define ZIPFS_FALLBACK_ENCODING "cp437" /* @@ -852,7 +852,6 @@ CanonicalPath( #endif /* _WIN32 */ if (haveZipfsPath) { - /* UNC style path */ if (root && strncmp(root, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN) == 0) { isVfs = 1; } else if (tail && diff --git a/tests/zipfs.test b/tests/zipfs.test index bf9c969..6e8b8ba 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -280,7 +280,7 @@ test zipfs-4.1 {zipfs lmkimg} -constraints zipfs -setup { zipfs lmkimg $targetImage [list $addFile test/add.tcl] {} $baseImage zipfs mount ziptest $targetImage try { - list [source $targetImage] [source //zipfs:/ziptest/test/add.tcl] + list [source $targetImage] [source /zipfs:/ziptest/test/add.tcl] } finally { zipfs unmount ziptest } @@ -300,7 +300,7 @@ test zipfs-4.2 {zipfs lmkimg: making an image from an image} -constraints zipfs zipfs lmkimg $targetImage [list $addFile test/ok.tcl] {} $midImage zipfs mount ziptest $targetImage try { - list [glob -tails -directory //zipfs://ziptest/test *.tcl] \ + list [glob -tails -directory /zipfs://ziptest/test *.tcl] \ [if {[file size $midImage] == [file size $targetImage]} { string cat equal } else { @@ -327,7 +327,7 @@ test zipfs-4.3 {zipfs lmkimg: stripping password} -constraints zipfs -setup { zipfs lmkimg $targetImage [list $addFile test/ok.tcl] {} $midImage zipfs mount ziptest $targetImage try { - glob -tails -directory //zipfs://ziptest/test *.tcl + glob -tails -directory /zipfs://ziptest/test *.tcl } finally { zipfs unmount ziptest } @@ -349,7 +349,7 @@ test zipfs-4.4 {zipfs lmkimg: final password} -constraints zipfs -setup { zipfs lmkimg $targetImage [list $addFile test/ok.tcl] $pass $midImage zipfs mount ziptest $targetImage try { - glob -tails -directory //zipfs://ziptest/test *.tcl + glob -tails -directory /zipfs://ziptest/test *.tcl } finally { zipfs unmount ziptest } @@ -368,18 +368,18 @@ test zipfs-4.5 {zipfs lmkimg: making image from mounted} -constraints zipfs -set } -body { zipfs lmkimg $midImage [list $addFile test/add.tcl] {} $baseImage zipfs mount ziptest $midImage - set f [glob -directory //zipfs://ziptest/test *.tcl] + set f [glob -directory /zipfs://ziptest/test *.tcl] zipfs lmkimg $targetImage [list $f test/ok.tcl] {} $midImage zipfs unmount ziptest zipfs mount ziptest $targetImage - list $f [glob -directory //zipfs://ziptest/test *.tcl] + list $f [glob -directory /zipfs://ziptest/test *.tcl] } -cleanup { zipfs unmount ziptest removeFile $baseImage removeFile $midImage removeFile $targetImage removeFile $addFile -} -result {//zipfs://ziptest/test/add.tcl //zipfs://ziptest/test/ok.tcl} +} -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 {} -- cgit v0.12 From 5a67846a1bca5cfd90804116cad4e7cb13d7fec3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 7 Sep 2023 14:34:36 +0000 Subject: Exchange TclZipfs_MountBuffer/"zipfs mount_data" arguments as well --- doc/zipfs.3 | 4 ++-- doc/zipfs.n | 2 +- generic/tcl.decls | 4 ++-- generic/tclDecls.h | 6 +++--- generic/tclZipfs.c | 20 ++++++++++---------- tests/zipfs.test | 12 ++++++------ 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/zipfs.3 b/doc/zipfs.3 index a4bb486..c67ce67 100644 --- a/doc/zipfs.3 +++ b/doc/zipfs.3 @@ -20,7 +20,7 @@ int \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 b04eeb5..1e6ddad 100644 --- a/doc/zipfs.n +++ b/doc/zipfs.n @@ -31,7 +31,7 @@ zipfs \- Mount and work with ZIP files within Tcl \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 diff --git a/generic/tcl.decls b/generic/tcl.decls index 301e22f..7c2c12a 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2346,8 +2346,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 44f2149..e3cd94c 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1893,8 +1893,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 */ @@ -2721,7 +2721,7 @@ typedef struct TclStubs { 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/tclZipfs.c b/generic/tclZipfs.c index faa7afa..5053c0f 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -2058,9 +2058,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; @@ -2112,7 +2112,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) { @@ -2292,7 +2292,7 @@ ZipFSMountBufferObjCmd( int length; if (objc > 3) { - Tcl_WrongNumArgs(interp, 1, objv, "?mountpoint? ?data?"); + Tcl_WrongNumArgs(interp, 1, objv, "?data? ?mountpoint?"); return TCL_ERROR; } if (objc < 2) { @@ -2304,19 +2304,19 @@ ZipFSMountBufferObjCmd( return ret; } - mountPoint = Tcl_GetString(objv[1]); if (objc < 3) { ReadLock(); - DescribeMounted(interp, mountPoint); + DescribeMounted(interp, Tcl_GetString(objv[1])); Unlock(); return TCL_OK; } - data = TclGetBytesFromObj(interp, objv[2], &length); + data = TclGetBytesFromObj(interp, objv[1], &length); + mountPoint = Tcl_GetString(objv[2]); if (data == NULL) { return TCL_ERROR; } - return TclZipfs_MountBuffer(interp, mountPoint, data, length, 1); + return TclZipfs_MountBuffer(interp, data, length, mountPoint, 1); } /* @@ -5960,9 +5960,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/tests/zipfs.test b/tests/zipfs.test index 55f430c..99e1cdc 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -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 @@ -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 -- cgit v0.12 From e39ec8cfc69936810da41fc0b2bff5ebe0609294 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 7 Sep 2023 14:53:19 +0000 Subject: More patches from juliannoble2. Thanks! --- doc/zipfs.n | 2 +- generic/tclZipfs.c | 11 +---------- library/auto.tcl | 2 +- tests/zipfs.test | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/doc/zipfs.n b/doc/zipfs.n index 1e6ddad..b39e82a 100644 --- a/doc/zipfs.n +++ b/doc/zipfs.n @@ -192,7 +192,7 @@ set base [file join [\fBzipfs root\fR] myApp] 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 diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 5053c0f..6eaca58 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -2370,7 +2370,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, Tcl_GetString(objv[1])); @@ -3669,22 +3669,13 @@ ZipFSExistsObjCmd( { char *filename; int exists; - Tcl_DString ds; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "filename"); return TCL_ERROR; } - /* - * Prepend ZIPFS_VOLUME to filename, eliding the final / - */ - filename = Tcl_GetString(objv[1]); - Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN - 1); - Tcl_DStringAppend(&ds, filename, -1); - filename = Tcl_DStringValue(&ds); ReadLock(); exists = ZipFSLookup(filename) != NULL; diff --git a/library/auto.tcl b/library/auto.tcl index a4f8d41..2e70873 100644 --- a/library/auto.tcl +++ b/library/auto.tcl @@ -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/zipfs.test b/tests/zipfs.test index 99e1cdc..b5ecffa 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -96,7 +96,7 @@ test zipfs-1.3 {zipfs errors} -constraints zipfs -returnCodes error -body { } -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"} -- cgit v0.12