summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-04-03 08:39:24 (GMT)
committervincentdarley <vincentdarley>2002-04-03 08:39:24 (GMT)
commit7aeafd8794e75f5c80d4c801dc71d0c7ea002bf9 (patch)
tree5942a13241543dd5ed12cdde48178810783a1b60
parent021fe1e9bdb2ad887b654e5185fd137145450be7 (diff)
downloadtcl-7aeafd8794e75f5c80d4c801dc71d0c7ea002bf9.zip
tcl-7aeafd8794e75f5c80d4c801dc71d0c7ea002bf9.tar.gz
tcl-7aeafd8794e75f5c80d4c801dc71d0c7ea002bf9.tar.bz2
tilde expansion cache-clearing
-rw-r--r--ChangeLog7
-rw-r--r--doc/FileSystem.315
-rw-r--r--generic/tclEnv.c11
-rw-r--r--generic/tclIOUtil.c47
4 files changed, 51 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index b413b57..29ed413 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-01 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * generic/tclEnv.c:
+ * generic/tclIOUtil.c: invalidate filesystem cache when the
+ user changes env(HOME). Fixes [Bug #535621]. Also cleaned up
+ some of the documentation.
+
2002-04-01 Kevin Kenny <kennykb@acm.org>
* win/tclWinTime.c (Tcl_GetTime): made the checks of clock
diff --git a/doc/FileSystem.3 b/doc/FileSystem.3
index d504b64..c085135 100644
--- a/doc/FileSystem.3
+++ b/doc/FileSystem.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: FileSystem.3,v 1.20 2002/03/24 11:41:48 vincentdarley Exp $
+'\" RCS: @(#) $Id: FileSystem.3,v 1.21 2002/04/03 08:39:26 vincentdarley Exp $
'\"
.so man.macros
.TH Filesystem 3 8.4 Tcl "Tcl Library Procedures"
@@ -239,7 +239,7 @@ all of these functions are 'virtual filesystem aware'. Any virtual
filesystem which has been registered (through
\fBTcl_FSRegister\fR) may reroute file access to alternative
media or access methods. This means that all of these functions (and
-therefore the corresponding \fBfile\fR, \fBpwd\fR, \fBcd\fR,
+therefore the corresponding \fBfile\fR, \fBglob\fR, \fBpwd\fR, \fBcd\fR,
\fBopen\fR, etc. Tcl commands) may be operate on 'files' which are not
native files in the native filesystem. If appropriate vfs's have been
registered, the 'files' may, to give two examples, be remote (e.g.
@@ -1301,12 +1301,11 @@ error message is left in the interp's result.
Function to process a \fBTcl_FSChdir()\fR call. If filesystems do not
implement this, it will be emulated by a series of directory access
checks. Otherwise, virtual filesystems which do implement it need only
-respond with a positive return result if the dirName is a valid
-directory in their filesystem. They need not remember the result,
-since that will be automatically remembered for use by GetCwd. Real
-filesystems should carry out the correct action (i.e. call the correct
-system 'chdir' api). If not implemented, then 'cd' and 'pwd' will fail
-inside the filesystem.
+respond with a positive return result if the dirName is a valid,
+accessible directory in their filesystem. They need not remember the
+result, since that will be automatically remembered for use by GetCwd.
+Real filesystems should carry out the correct action (i.e. call the
+correct system 'chdir' api).
.PP
.CS
typedef int Tcl_FSChdirProc(
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 86a1844..9dd1c6e 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnv.c,v 1.13 2002/03/20 22:47:36 dgp Exp $
+ * RCS: @(#) $Id: tclEnv.c,v 1.14 2002/04/03 08:39:27 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -272,6 +272,15 @@ TclSetEnv(name, value)
}
Tcl_MutexUnlock(&envMutex);
+
+ if (!strcmp(name, "HOME")) {
+ /*
+ * If the user's home directory has changed, we must invalidate
+ * the filesystem cache, because '~' expansions will now be
+ * incorrect.
+ */
+ Tcl_FSMountsChanged(NULL);
+ }
}
/*
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index f6bf2c7..e17179b 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.38 2002/03/24 18:09:19 vincentdarley Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.39 2002/04/03 08:39:27 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -27,9 +27,7 @@
#endif
/*
- * Prototypes for procedures defined later in this file. The last
- * of these could perhaps be exported in the future, if extensions
- * require it.
+ * Prototypes for procedures defined later in this file.
*/
static void DupFsPathInternalRep _ANSI_ARGS_((Tcl_Obj *srcPtr,
@@ -741,6 +739,12 @@ Tcl_FSUnregister(fsPtr)
* (3) when any filesystem (except the native fs) changes the list
* of available volumes.
*
+ * (4) when the mapping from a string representation of a file to
+ * a full, normalized path changes. For example, if 'env(HOME)'
+ * is modified, then any path containing '~' will map to a different
+ * filesystem location. Therefore all such paths need to have
+ * their internal representation invalidated.
+ *
* Tcl has no control over (2) and (3), so any registered filesystem
* must make sure it calls this function when those situations
* occur.
@@ -3408,6 +3412,11 @@ Tcl_FSConvertToPathType(interp, objPtr)
*/
if (objPtr->typePtr == &tclFsPathType) {
FsPath *fsPathPtr = (FsPath*) objPtr->internalRep.otherValuePtr;
+ if (fsPathPtr->filesystemEpoch != theFilesystemEpoch) {
+ FreeFsPathInternalRep(objPtr);
+ objPtr->typePtr = NULL;
+ return Tcl_ConvertToType(interp, objPtr, &tclFsPathType);
+ }
if (fsPathPtr->cwdPtr == NULL) {
return TCL_OK;
} else {
@@ -3511,7 +3520,7 @@ SetFsPathFromAbsoluteNormalized(interp, objPtr)
fsPathPtr->cwdPtr = NULL;
fsPathPtr->nativePathPtr = NULL;
fsPathPtr->fsRecPtr = NULL;
- fsPathPtr->filesystemEpoch = -1;
+ fsPathPtr->filesystemEpoch = theFilesystemEpoch;
objPtr->internalRep.otherValuePtr = (VOID *) fsPathPtr;
objPtr->typePtr = &tclFsPathType;
@@ -3690,7 +3699,7 @@ SetFsPathFromAny(interp, objPtr)
fsPathPtr->cwdPtr = NULL;
fsPathPtr->nativePathPtr = NULL;
fsPathPtr->fsRecPtr = NULL;
- fsPathPtr->filesystemEpoch = -1;
+ fsPathPtr->filesystemEpoch = theFilesystemEpoch;
objPtr->internalRep.otherValuePtr = (VOID *) fsPathPtr;
objPtr->typePtr = &tclFsPathType;
@@ -4546,23 +4555,21 @@ Tcl_FSGetFileSystemForPath(pathObjPtr)
srcFsPathPtr = (FsPath*) pathObjPtr->internalRep.otherValuePtr;
- if (srcFsPathPtr->filesystemEpoch != -1) {
+ /*
+ * Check if the filesystem has changed in some way since
+ * this object's internal representation was calculated.
+ */
+ if (srcFsPathPtr->filesystemEpoch != theFilesystemEpoch) {
/*
- * Check if the filesystem has changed in some way since
- * this object's internal representation was calculated.
+ * We have to discard the stale representation and
+ * recalculate it
*/
- if (srcFsPathPtr->filesystemEpoch != theFilesystemEpoch) {
- /*
- * We have to discard the stale representation and
- * recalculate it
- */
- FreeFsPathInternalRep(pathObjPtr);
- pathObjPtr->typePtr = NULL;
- if (SetFsPathFromAny(NULL, pathObjPtr) != TCL_OK) {
- goto done;
- }
- srcFsPathPtr = (FsPath*) pathObjPtr->internalRep.otherValuePtr;
+ FreeFsPathInternalRep(pathObjPtr);
+ pathObjPtr->typePtr = NULL;
+ if (SetFsPathFromAny(NULL, pathObjPtr) != TCL_OK) {
+ goto done;
}
+ srcFsPathPtr = (FsPath*) pathObjPtr->internalRep.otherValuePtr;
}
/* Check whether the object is already assigned to a fs */