From 18f8d46757561d21d663ede071a72da0c41e567e Mon Sep 17 00:00:00 2001 From: Vince Darley Date: Mon, 8 Jul 2002 10:15:30 +0000 Subject: [PATCH] update for tcl cvs head, and win compile --- ChangeLog | 5 +++++ Readme.txt | 7 ------- generic/vfs.c | 25 +++++++++++++++++++++---- library/vfsUtils.tcl | 16 ++++++++++++++++ win/makefile.vc | 19 ++++++++++++++++--- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7877a6b..5a75aec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-07-08 Vince Darley + * generic/vfs.c: update for latest cvs head. + * win/makefile.vc: compilation into Release and Debug + directories as appropriate. + 2002-06-22 Jean-Claude Wippler * mac/pkgIndex_mac.tcl: * library/pkgIndex.tcl: diff --git a/Readme.txt b/Readme.txt index 995a840..8c6e450 100644 --- a/Readme.txt +++ b/Readme.txt @@ -10,13 +10,6 @@ This is an implementation of a 'vfs' extension (and a 'vfs' package, including a small library of Tcl code). The goal of this extension is to expose Tcl 8.4's new filesystem C API to the Tcl level. -Since 8.4 is still in alpha, the APIs on which this extension depends may of -course change. If that happens, it will of course require changes to this -extension, until the point at which 8.4 goes final, when only -backwards-compatible changes should occur. Currently it requires a -version of Tcl 8.4a5 or newer (from March 30th 2002) --- if it compiles -without warning, you should be fine. - Using this extension, the editor Alphatk can actually auto-mount, view and edit (but not save, since they're read-only) the contents of .zip files directly (see ), and you can diff --git a/generic/vfs.c b/generic/vfs.c index d08c228..796cc63 100644 --- a/generic/vfs.c +++ b/generic/vfs.c @@ -1100,13 +1100,30 @@ VfsAccess(pathPtr, mode) } } +static Tcl_Obj* +VfsGetMode(int mode) { + Tcl_Obj *ret = Tcl_NewObj(); + if (mode & O_RDONLY) { + Tcl_AppendToObj(ret, "r", 1); + } else if (mode & O_WRONLY || mode & O_RDWR) { + if (mode & O_TRUNC) { + Tcl_AppendToObj(ret, "w", 1); + } else { + Tcl_AppendToObj(ret, "a", 1); + } + if (mode & O_RDWR) { + Tcl_AppendToObj(ret, "+", 1); + } + } + return ret; +} + static Tcl_Channel -VfsOpenFileChannel(cmdInterp, pathPtr, modeString, permissions) +VfsOpenFileChannel(cmdInterp, pathPtr, mode, permissions) Tcl_Interp *cmdInterp; /* Interpreter for error reporting; * can be NULL. */ Tcl_Obj *pathPtr; /* Name of file to open. */ - CONST char *modeString; /* A list of POSIX open modes or - * a string such as "rw". */ + int mode; /* POSIX open mode. */ int permissions; /* If the open involves creating a * file, with what modes to create * it? */ @@ -1123,7 +1140,7 @@ VfsOpenFileChannel(cmdInterp, pathPtr, modeString, permissions) return NULL; } - Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewStringObj(modeString,-1)); + Tcl_ListObjAppendElement(interp, mountCmd, VfsGetMode(mode)); Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(permissions)); Tcl_SaveResult(interp, &savedResult); /* Now we execute this mount point's callback. */ diff --git a/library/vfsUtils.tcl b/library/vfsUtils.tcl index 8b9af31..aa56557 100644 --- a/library/vfsUtils.tcl +++ b/library/vfsUtils.tcl @@ -199,6 +199,22 @@ proc vfs::matchFiles {types} { } proc vfs::modeToString {mode} { + # Turn a POSIX open 'mode' set of flags into a more readable + # string 'r', 'w', 'w+', 'a', etc. + set res "" + if {$mode & 1} { + append res "r" + } elseif {$mode & 2} { + if {$mode & 16} { + append res "w" + } else { + append res "a" + } + } + if {$mode & 4} { + append res "+" + } + set res } # These lists are used to convert attribute indices into the string equivalent. diff --git a/win/makefile.vc b/win/makefile.vc index 315911d..6c05472 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -13,7 +13,7 @@ VFS_VERSION = 1.0 DLL_VERSION = 10 # comment the following line to compile with symbols -NODEBUG=0 +NODEBUG=1 !IF "$(NODEBUG)" == "1" DEBUGDEFINES = @@ -36,7 +36,11 @@ PROJECT = vfs$(DLL_VERSION)$(DBGX) # note that the tcl vclibs should have been unpacked in $(TCL)\lib !! ROOT = .. -WINDIR = $(ROOT)\win +!IF "$(NODEBUG)" == "1" +WINDIR = $(ROOT)\win\Release +!ELSE +WINDIR = $(ROOT)\win\Debug +!ENDIF GENERICDIR = $(ROOT)\generic LIBDIR = $(ROOT)\library TOOLS32 = C:\Progra~1\devstudio\vc @@ -127,6 +131,11 @@ PATH=$(COMMON32)/bin;$(TOOLS32)\bin;$(PATH) cc32 = $(TOOLS32)\bin\cl -I$(TOOLS32)\include CP = copy RM = del +!if "$(OS)" == "Windows_NT" +RMDIR = rmdir /S /Q +!else +RMDIR = deltree /Y +!endif INCLUDES = \ -I../../tcl8.4/generic \ @@ -145,7 +154,10 @@ DLLOBJS = \ # Targets -all: $(PROJECT).dll +all: setup $(PROJECT).dll + +setup: + -@md $(WINDIR) install: $(PROJECT).dll -@md $(INSTALLDIR) @@ -169,6 +181,7 @@ $(WINDIR)\vfs.obj: $(GENERICDIR)\vfs.c clean: -$(RM) $(WINDIR)\*.obj + -$(RMDIR) $(WINDIR) -$(RM) $(PROJECT).dll -$(RM) $(PROJECT).lib -$(RM) $(PROJECT).exp -- 2.23.0