summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-06-12 09:28:58 (GMT)
committervincentdarley <vincentdarley>2002-06-12 09:28:58 (GMT)
commit85fa4c1014f2115447bba5458e877fe974f04f1b (patch)
tree0c1a8deaa9b8d015e4714b9ce7fb77926a4d499c /generic
parentc1e47417bf2cab1cb467c456f990114f78ad1680 (diff)
downloadtcl-85fa4c1014f2115447bba5458e877fe974f04f1b.zip
tcl-85fa4c1014f2115447bba5458e877fe974f04f1b.tar.gz
tcl-85fa4c1014f2115447bba5458e877fe974f04f1b.tar.bz2
fs clarification and windows fixes
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tclDecls.h6
-rw-r--r--generic/tclIOUtil.c73
3 files changed, 58 insertions, 25 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index b384108..7f10c97 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tcl.decls,v 1.87 2002/05/24 21:19:05 dkf Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.88 2002/06/12 09:28:58 vincentdarley Exp $
library tcl
@@ -1649,7 +1649,7 @@ declare 467 generic {
int Tcl_FSEvalFile(Tcl_Interp *interp, Tcl_Obj *fileName)
}
declare 468 generic {
- Tcl_Obj* Tcl_FSNewNativePath(Tcl_Obj* fromFilesystem,
+ Tcl_Obj* Tcl_FSNewNativePath(Tcl_Filesystem* fromFilesystem,
ClientData clientData)
}
declare 469 generic {
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 95e47ec..8062d1e 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDecls.h,v 1.87 2002/05/24 21:19:05 dkf Exp $
+ * RCS: @(#) $Id: tclDecls.h,v 1.88 2002/06/12 09:28:58 vincentdarley Exp $
*/
#ifndef _TCLDECLS
@@ -1483,7 +1483,7 @@ EXTERN int Tcl_FSEvalFile _ANSI_ARGS_((Tcl_Interp * interp,
Tcl_Obj * fileName));
/* 468 */
EXTERN Tcl_Obj* Tcl_FSNewNativePath _ANSI_ARGS_((
- Tcl_Obj* fromFilesystem,
+ Tcl_Filesystem* fromFilesystem,
ClientData clientData));
/* 469 */
EXTERN CONST char* Tcl_FSGetNativePath _ANSI_ARGS_((Tcl_Obj* pathObjPtr));
@@ -2083,7 +2083,7 @@ typedef struct TclStubs {
ClientData (*tcl_FSGetInternalRep) _ANSI_ARGS_((Tcl_Obj* pathObjPtr, Tcl_Filesystem * fsPtr)); /* 465 */
Tcl_Obj* (*tcl_FSGetTranslatedPath) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj* pathPtr)); /* 466 */
int (*tcl_FSEvalFile) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * fileName)); /* 467 */
- Tcl_Obj* (*tcl_FSNewNativePath) _ANSI_ARGS_((Tcl_Obj* fromFilesystem, ClientData clientData)); /* 468 */
+ Tcl_Obj* (*tcl_FSNewNativePath) _ANSI_ARGS_((Tcl_Filesystem* fromFilesystem, ClientData clientData)); /* 468 */
CONST char* (*tcl_FSGetNativePath) _ANSI_ARGS_((Tcl_Obj* pathObjPtr)); /* 469 */
Tcl_Obj* (*tcl_FSFileSystemInfo) _ANSI_ARGS_((Tcl_Obj* pathObjPtr)); /* 470 */
Tcl_Obj* (*tcl_FSPathSeparator) _ANSI_ARGS_((Tcl_Obj* pathObjPtr)); /* 471 */
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index f5ee327..0858a58 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.47 2002/06/10 17:41:52 vincentdarley Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.48 2002/06/12 09:28:58 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -26,7 +26,7 @@
#include "tclMacInt.h"
#endif
#ifdef __WIN32__
-/* For 'file link' */
+/* for tclWinProcs->useWide */
#include "tclWinInt.h"
#endif
@@ -318,6 +318,9 @@ typedef struct FilesystemRecord {
* to Tcl, or NULL if no more. */
} FilesystemRecord;
+static FilesystemRecord* GetFilesystemRecord
+ _ANSI_ARGS_((Tcl_Filesystem *fromFilesystem, int *epoch));
+
/*
* Declare the native filesystem support. These functions should
* be considered private to Tcl, and should really not be called
@@ -370,7 +373,7 @@ Tcl_FSLinkProc TclpObjLink;
Tcl_FSListVolumesProc TclpObjListVolumes;
/* Define the native filesystem dispatch table */
-static Tcl_Filesystem nativeFilesystem = {
+Tcl_Filesystem nativeFilesystem = {
"native",
sizeof(Tcl_Filesystem),
TCL_FILESYSTEM_VERSION_1,
@@ -3900,20 +3903,22 @@ SetFsPathFromAny(interp, objPtr)
Tcl_Obj *
Tcl_FSNewNativePath(fromFilesystem, clientData)
- Tcl_Obj* fromFilesystem;
+ Tcl_Filesystem* fromFilesystem;
ClientData clientData;
{
Tcl_Obj *objPtr;
- FsPath *fsPathPtr, *fsFromPtr;
+ FsPath *fsPathPtr;
+ FilesystemRecord *fsFromPtr;
Tcl_FSInternalToNormalizedProc *proc;
+ int epoch;
- if (Tcl_FSConvertToPathType(NULL, fromFilesystem) != TCL_OK) {
- return NULL;
+ fsFromPtr = GetFilesystemRecord(fromFilesystem, &epoch);
+
+ if (fsFromPtr == NULL) {
+ return NULL;
}
- fsFromPtr = (FsPath*) fromFilesystem->internalRep.otherValuePtr;
-
- proc = fsFromPtr->fsRecPtr->fsPtr->internalToNormalizedProc;
+ proc = fsFromPtr->fsPtr->internalToNormalizedProc;
if (proc == NULL) {
return NULL;
@@ -3946,10 +3951,10 @@ Tcl_FSNewNativePath(fromFilesystem, clientData)
fsPathPtr->normPathPtr = objPtr;
fsPathPtr->cwdPtr = NULL;
fsPathPtr->nativePathPtr = clientData;
- fsPathPtr->fsRecPtr = fsFromPtr->fsRecPtr;
+ fsPathPtr->fsRecPtr = fsFromPtr;
/* We must increase the refCount for this filesystem. */
fsPathPtr->fsRecPtr->fileRefCount++;
- fsPathPtr->filesystemEpoch = fsFromPtr->filesystemEpoch;
+ fsPathPtr->filesystemEpoch = epoch;
objPtr->internalRep.otherValuePtr = (VOID *) fsPathPtr;
objPtr->typePtr = &tclFsPathType;
@@ -4385,14 +4390,20 @@ NativeCreateNativeRep(pathObjPtr)
str = Tcl_GetStringFromObj(normPtr,&len);
#ifdef __WIN32__
Tcl_WinUtfToTChar(str, len, &ds);
- nativePathPtr = ckalloc((unsigned)(2+Tcl_DStringLength(&ds)));
- memcpy((VOID*)nativePathPtr, (VOID*)Tcl_DStringValue(&ds),
- (size_t) (2+Tcl_DStringLength(&ds)));
+ if (tclWinProcs->useWide) {
+ nativePathPtr = ckalloc((unsigned)(sizeof(WCHAR)+Tcl_DStringLength(&ds)));
+ memcpy((VOID*)nativePathPtr, (VOID*)Tcl_DStringValue(&ds),
+ (size_t) (sizeof(WCHAR)+Tcl_DStringLength(&ds)));
+ } else {
+ nativePathPtr = ckalloc((unsigned)(sizeof(char)+Tcl_DStringLength(&ds)));
+ memcpy((VOID*)nativePathPtr, (VOID*)Tcl_DStringValue(&ds),
+ (size_t) (sizeof(char)+Tcl_DStringLength(&ds)));
+ }
#else
Tcl_UtfToExternalDString(NULL, str, len, &ds);
- nativePathPtr = ckalloc((unsigned)(1+Tcl_DStringLength(&ds)));
+ nativePathPtr = ckalloc((unsigned)(sizeof(char)+Tcl_DStringLength(&ds)));
memcpy((VOID*)nativePathPtr, (VOID*)Tcl_DStringValue(&ds),
- (size_t) (1+Tcl_DStringLength(&ds)));
+ (size_t) (sizeof(char)+Tcl_DStringLength(&ds)));
#endif
Tcl_DStringFree(&ds);
@@ -4439,9 +4450,14 @@ TclpNativeToNormalized(clientData)
* prefix to indicate that they are to be treated specially. For
* example extremely long paths, or symlinks
*/
- if (0 == strncmp(copy,"\\??\\",4)) {
- copy += 4;
- len -= 4;
+ if (*copy == '\\') {
+ if (0 == strncmp(copy,"\\??\\",4)) {
+ copy += 4;
+ len -= 4;
+ } else if (0 == strncmp(copy,"\\\\?\\",4)) {
+ copy += 4;
+ len -= 4;
+ }
}
#endif
@@ -4776,6 +4792,23 @@ Tcl_FSGetFileSystemForPath(pathObjPtr)
return retVal;
}
+/* Simple helper function */
+static FilesystemRecord*
+GetFilesystemRecord(fromFilesystem, epoch)
+ Tcl_Filesystem *fromFilesystem;
+ int *epoch;
+{
+ FilesystemRecord *fsRecPtr = FsGetIterator();
+ while (fsRecPtr != NULL) {
+ if (fsRecPtr->fsPtr == fromFilesystem) {
+ *epoch = theFilesystemEpoch;
+ break;
+ }
+ }
+ FsReleaseIterator();
+ return fsRecPtr;
+}
+
/*
*---------------------------------------------------------------------------
*