[25] | 1 | /* |
---|
| 2 | * tclFileSystem.h -- |
---|
| 3 | * |
---|
| 4 | * This file contains the common defintions and prototypes for use by |
---|
| 5 | * Tcl's filesystem and path handling layers. |
---|
| 6 | * |
---|
| 7 | * Copyright (c) 2003 Vince Darley. |
---|
| 8 | * |
---|
| 9 | * See the file "license.terms" for information on usage and redistribution of |
---|
| 10 | * this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 11 | * |
---|
| 12 | * RCS: @(#) $Id: tclFileSystem.h,v 1.11 2005/10/13 00:07:17 dkf Exp $ |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #ifndef _TCLFILESYSTEM |
---|
| 16 | #define _TCLFILESYSTEM |
---|
| 17 | |
---|
| 18 | #include "tcl.h" |
---|
| 19 | |
---|
| 20 | /* |
---|
| 21 | * struct FilesystemRecord -- |
---|
| 22 | * |
---|
| 23 | * A filesystem record is used to keep track of each filesystem currently |
---|
| 24 | * registered with the core, in a linked list. Pointers to these structures |
---|
| 25 | * are also kept by each "path" Tcl_Obj, and we must retain a refCount on the |
---|
| 26 | * number of such references. |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | typedef struct FilesystemRecord { |
---|
| 30 | ClientData clientData; /* Client specific data for the new filesystem |
---|
| 31 | * (can be NULL) */ |
---|
| 32 | Tcl_Filesystem *fsPtr; /* Pointer to filesystem dispatch table. */ |
---|
| 33 | int fileRefCount; /* How many Tcl_Obj's use this filesystem. */ |
---|
| 34 | struct FilesystemRecord *nextPtr; |
---|
| 35 | /* The next filesystem registered to Tcl, or |
---|
| 36 | * NULL if no more. */ |
---|
| 37 | struct FilesystemRecord *prevPtr; |
---|
| 38 | /* The previous filesystem registered to Tcl, |
---|
| 39 | * or NULL if no more. */ |
---|
| 40 | } FilesystemRecord; |
---|
| 41 | |
---|
| 42 | /* |
---|
| 43 | * This structure holds per-thread private copy of the current directory |
---|
| 44 | * maintained by the global cwdPathPtr. This structure holds per-thread |
---|
| 45 | * private copies of some global data. This way we avoid most of the |
---|
| 46 | * synchronization calls which boosts performance, at cost of having to update |
---|
| 47 | * this information each time the corresponding epoch counter changes. |
---|
| 48 | */ |
---|
| 49 | |
---|
| 50 | typedef struct ThreadSpecificData { |
---|
| 51 | int initialized; |
---|
| 52 | int cwdPathEpoch; |
---|
| 53 | int filesystemEpoch; |
---|
| 54 | Tcl_Obj *cwdPathPtr; |
---|
| 55 | ClientData cwdClientData; |
---|
| 56 | FilesystemRecord *filesystemList; |
---|
| 57 | } ThreadSpecificData; |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * The internal TclFS API provides routines for handling and manipulating |
---|
| 61 | * paths efficiently, taking direct advantage of the "path" Tcl_Obj type. |
---|
| 62 | * |
---|
| 63 | * These functions are not exported at all at present. |
---|
| 64 | */ |
---|
| 65 | |
---|
| 66 | MODULE_SCOPE int TclFSCwdPointerEquals(Tcl_Obj **pathPtrPtr); |
---|
| 67 | MODULE_SCOPE int TclFSMakePathFromNormalized(Tcl_Interp *interp, |
---|
| 68 | Tcl_Obj *pathPtr, ClientData clientData); |
---|
| 69 | MODULE_SCOPE int TclFSNormalizeToUniquePath(Tcl_Interp *interp, |
---|
| 70 | Tcl_Obj *pathPtr, int startAt, |
---|
| 71 | ClientData *clientDataPtr); |
---|
| 72 | MODULE_SCOPE Tcl_Obj * TclFSMakePathRelative(Tcl_Interp *interp, |
---|
| 73 | Tcl_Obj *pathPtr, Tcl_Obj *cwdPtr); |
---|
| 74 | MODULE_SCOPE Tcl_Obj * TclFSInternalToNormalized( |
---|
| 75 | Tcl_Filesystem *fromFilesystem, |
---|
| 76 | ClientData clientData, |
---|
| 77 | FilesystemRecord **fsRecPtrPtr); |
---|
| 78 | MODULE_SCOPE int TclFSEnsureEpochOk(Tcl_Obj *pathPtr, |
---|
| 79 | Tcl_Filesystem **fsPtrPtr); |
---|
| 80 | MODULE_SCOPE void TclFSSetPathDetails(Tcl_Obj *pathPtr, |
---|
| 81 | FilesystemRecord *fsRecPtr, |
---|
| 82 | ClientData clientData); |
---|
| 83 | MODULE_SCOPE Tcl_Obj * TclFSNormalizeAbsolutePath(Tcl_Interp *interp, |
---|
| 84 | Tcl_Obj *pathPtr, ClientData *clientDataPtr); |
---|
| 85 | |
---|
| 86 | /* |
---|
| 87 | * Private shared variables for use by tclIOUtil.c and tclPathObj.c |
---|
| 88 | */ |
---|
| 89 | |
---|
| 90 | MODULE_SCOPE Tcl_Filesystem tclNativeFilesystem; |
---|
| 91 | MODULE_SCOPE Tcl_ThreadDataKey tclFsDataKey; |
---|
| 92 | |
---|
| 93 | /* |
---|
| 94 | * Private shared functions for use by tclIOUtil.c, tclPathObj.c and |
---|
| 95 | * tclFileName.c, and any platform-specific filesystem code. |
---|
| 96 | */ |
---|
| 97 | |
---|
| 98 | MODULE_SCOPE Tcl_PathType TclFSGetPathType(Tcl_Obj *pathPtr, |
---|
| 99 | Tcl_Filesystem **filesystemPtrPtr, |
---|
| 100 | int *driveNameLengthPtr); |
---|
| 101 | MODULE_SCOPE Tcl_PathType TclFSNonnativePathType(CONST char *pathPtr, |
---|
| 102 | int pathLen, Tcl_Filesystem **filesystemPtrPtr, |
---|
| 103 | int *driveNameLengthPtr, Tcl_Obj **driveNameRef); |
---|
| 104 | MODULE_SCOPE Tcl_PathType TclGetPathType(Tcl_Obj *pathPtr, |
---|
| 105 | Tcl_Filesystem **filesystemPtrPtr, |
---|
| 106 | int *driveNameLengthPtr, Tcl_Obj **driveNameRef); |
---|
| 107 | MODULE_SCOPE int TclFSEpochOk(int filesystemEpoch); |
---|
| 108 | MODULE_SCOPE int TclFSCwdIsNative(void); |
---|
| 109 | MODULE_SCOPE Tcl_Obj * TclWinVolumeRelativeNormalize(Tcl_Interp *interp, |
---|
| 110 | CONST char *path, Tcl_Obj **useThisCwdPtr); |
---|
| 111 | |
---|
| 112 | MODULE_SCOPE Tcl_FSPathInFilesystemProc TclNativePathInFilesystem; |
---|
| 113 | MODULE_SCOPE Tcl_FSCreateInternalRepProc TclNativeCreateNativeRep; |
---|
| 114 | |
---|
| 115 | #endif /* _TCLFILESYSTEM */ |
---|
| 116 | |
---|
| 117 | /* |
---|
| 118 | * Local Variables: |
---|
| 119 | * mode: c |
---|
| 120 | * c-basic-offset: 4 |
---|
| 121 | * fill-column: 78 |
---|
| 122 | * End: |
---|
| 123 | */ |
---|