diff options
author | vincentdarley <vincentdarley> | 2003-02-10 12:50:30 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2003-02-10 12:50:30 (GMT) |
commit | 71073845ccadf428914c16d0163073f941114c72 (patch) | |
tree | c3b570affd9947fcdb255e3417752cd71200acc1 /generic | |
parent | 850d398c1a0776e72d591c406090dfaca8492aeb (diff) | |
download | tcl-71073845ccadf428914c16d0163073f941114c72.zip tcl-71073845ccadf428914c16d0163073f941114c72.tar.gz tcl-71073845ccadf428914c16d0163073f941114c72.tar.bz2 |
further fs cleanup
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIOUtil.c | 51 | ||||
-rw-r--r-- | generic/tclTest.c | 19 |
2 files changed, 24 insertions, 46 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 6c7b9c0..f48876d 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.72 2003/02/10 10:26:25 vincentdarley Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.73 2003/02/10 12:50:31 vincentdarley Exp $ */ #include "tclInt.h" @@ -3954,10 +3954,9 @@ UpdateStringOfFsPath(objPtr) break; case TCL_PLATFORM_WINDOWS: /* - * We need the cwdLen > 2 because a volume - * relative path doesn't get a '/'. For - * example 'glob C:*cat*.exe' will return - * 'C:cat32.exe' + * We need the extra 'cwdLen != 2', and ':' checks because + * a volume relative path doesn't get a '/'. For example + * 'glob C:*cat*.exe' will return 'C:cat32.exe' */ if (cwdStr[cwdLen-1] != '/' && cwdStr[cwdLen-1] != '\\') { @@ -4547,6 +4546,9 @@ Tcl_FSGetTranslatedPath(interp, pathPtr) } srcFsPathPtr = (FsPath*) pathPtr->internalRep.otherValuePtr; if (srcFsPathPtr->translatedPathPtr == NULL) { + if (srcFsPathPtr->flags != 0) { + return Tcl_FSGetNormalizedPath(interp, pathPtr); + } /* * It is a pure absolute, normalized path object. * This is something like being a 'pure list'. The @@ -4956,43 +4958,6 @@ Tcl_FSGetNativePath(pathObjPtr) return (CONST char *)Tcl_FSGetInternalRep(pathObjPtr, &tclNativeFilesystem); } -static Tcl_Obj* -FsGetValidObjRep(interp, objPtr) - Tcl_Interp *interp; /* Interpreter in which to store error - * message (if necessary). */ - Tcl_Obj *objPtr; /* Object to convert to a valid, current - * path type. */ -{ - FsPath *fsPathPtr; - if (objPtr->typePtr != &tclFsPathType) { - if (Tcl_ConvertToType(interp, objPtr, &tclFsPathType) != TCL_OK) { - return NULL; - } - } - fsPathPtr = (FsPath*) objPtr->internalRep.otherValuePtr; - - if (fsPathPtr->filesystemEpoch != theFilesystemEpoch) { - if (objPtr->bytes == NULL) { - UpdateStringOfFsPath(objPtr); - } - FreeFsPathInternalRep(objPtr); - objPtr->typePtr = NULL; - if (Tcl_ConvertToType(interp, objPtr, &tclFsPathType) != TCL_OK) { - return NULL; - } - fsPathPtr = (FsPath*) objPtr->internalRep.otherValuePtr; - } - - if (fsPathPtr->cwdPtr != NULL) { - if (FsCwdPointerEquals(fsPathPtr->cwdPtr)) { - /* This causes a few minor test failures with links */ - /* Once these are resolved, this would improve efficiency */ - /* return objPtr; */ - } - } - return Tcl_FSGetNormalizedPath(interp, objPtr); -} - /* *--------------------------------------------------------------------------- * @@ -5019,7 +4984,7 @@ NativeCreateNativeRep(pathObjPtr) char *str; /* Make sure the normalized path is set */ - validPathObjPtr = FsGetValidObjRep(NULL, pathObjPtr); + validPathObjPtr = Tcl_FSGetNormalizedPath(NULL, pathObjPtr); str = Tcl_GetStringFromObj(validPathObjPtr, &len); #ifdef __WIN32__ diff --git a/generic/tclTest.c b/generic/tclTest.c index 91a1caf..1acbcf0 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.59 2003/02/07 11:59:43 vincentdarley Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.60 2003/02/10 12:50:31 vincentdarley Exp $ */ #define TCL_TEST @@ -6041,6 +6041,8 @@ SimplePathInFilesystem(Tcl_Obj *pathPtr, ClientData *clientDataPtr) { * copy without an interp */ static Tcl_Interp *simpleInterpPtr = NULL; +/* We use this to ensure we clean up after ourselves */ +static Tcl_Obj *tempFile = NULL; /* * This is a very 'hacky' filesystem which is used just so @@ -6085,6 +6087,11 @@ TestSimpleFilesystemObjCmd(dummy, interp, objc, objv) msg = (res == TCL_OK) ? "registered" : "failed"; simpleInterpPtr = interp; } else { + if (tempFile != NULL) { + Tcl_FSDeleteFile(tempFile); + Tcl_DecrRefCount(tempFile); + tempFile = NULL; + } res = Tcl_FSUnregister(&simpleFilesystem); msg = (res == TCL_OK) ? "unregistered" : "failed"; simpleInterpPtr = NULL; @@ -6121,6 +6128,7 @@ SimpleCopy(pathPtr) Tcl_DecrRefCount(origPtr); if (res != TCL_OK) { + Tcl_FSDeleteFile(tempPtr); Tcl_DecrRefCount(tempPtr); return NULL; } @@ -6153,8 +6161,12 @@ SimpleOpenFileChannel(interp, pathPtr, mode, permissions) } chan = Tcl_FSOpenFileChannel(interp, tempPtr, "r", permissions); - - Tcl_DecrRefCount(tempPtr); + /* When we are done with this file, it will never be deleted */ + if (tempFile != NULL) { + Tcl_FSDeleteFile(tempFile); + Tcl_DecrRefCount(tempFile); + } + tempFile = tempPtr; return chan; } @@ -6179,6 +6191,7 @@ SimpleStat(pathPtr, bufPtr) return TCL_OK; } else { int res = Tcl_FSStat(tempPtr, bufPtr); + Tcl_FSDeleteFile(tempPtr); Tcl_DecrRefCount(tempPtr); return res; } |