tclFileSystem.h

Go to the documentation of this file.
00001 /*
00002  * tclFileSystem.h --
00003  *
00004  *      This file contains the common defintions and prototypes for use by
00005  *      Tcl's filesystem and path handling layers.
00006  *
00007  * Copyright (c) 2003 Vince Darley.
00008  *
00009  * See the file "license.terms" for information on usage and redistribution of
00010  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
00011  *
00012  * RCS: @(#) $Id: tclFileSystem.h,v 1.11 2005/10/13 00:07:17 dkf Exp $
00013  */
00014 
00015 #ifndef _TCLFILESYSTEM
00016 #define _TCLFILESYSTEM
00017 
00018 #include "tcl.h"
00019 
00020 /*
00021  * struct FilesystemRecord --
00022  *
00023  * A filesystem record is used to keep track of each filesystem currently
00024  * registered with the core, in a linked list. Pointers to these structures
00025  * are also kept by each "path" Tcl_Obj, and we must retain a refCount on the
00026  * number of such references.
00027  */
00028 
00029 typedef struct FilesystemRecord {
00030     ClientData clientData;      /* Client specific data for the new filesystem
00031                                  * (can be NULL) */
00032     Tcl_Filesystem *fsPtr;      /* Pointer to filesystem dispatch table. */
00033     int fileRefCount;           /* How many Tcl_Obj's use this filesystem. */
00034     struct FilesystemRecord *nextPtr;
00035                                 /* The next filesystem registered to Tcl, or
00036                                  * NULL if no more. */
00037     struct FilesystemRecord *prevPtr;
00038                                 /* The previous filesystem registered to Tcl,
00039                                  * or NULL if no more. */
00040 } FilesystemRecord;
00041 
00042 /*
00043  * This structure holds per-thread private copy of the current directory
00044  * maintained by the global cwdPathPtr. This structure holds per-thread
00045  * private copies of some global data. This way we avoid most of the
00046  * synchronization calls which boosts performance, at cost of having to update
00047  * this information each time the corresponding epoch counter changes.
00048  */
00049 
00050 typedef struct ThreadSpecificData {
00051     int initialized;
00052     int cwdPathEpoch;
00053     int filesystemEpoch;
00054     Tcl_Obj *cwdPathPtr;
00055     ClientData cwdClientData;
00056     FilesystemRecord *filesystemList;
00057 } ThreadSpecificData;
00058 
00059 /*
00060  * The internal TclFS API provides routines for handling and manipulating
00061  * paths efficiently, taking direct advantage of the "path" Tcl_Obj type.
00062  *
00063  * These functions are not exported at all at present.
00064  */
00065 
00066 MODULE_SCOPE int        TclFSCwdPointerEquals(Tcl_Obj **pathPtrPtr);
00067 MODULE_SCOPE int        TclFSMakePathFromNormalized(Tcl_Interp *interp,
00068                             Tcl_Obj *pathPtr, ClientData clientData);
00069 MODULE_SCOPE int        TclFSNormalizeToUniquePath(Tcl_Interp *interp,
00070                             Tcl_Obj *pathPtr, int startAt,
00071                             ClientData *clientDataPtr);
00072 MODULE_SCOPE Tcl_Obj *  TclFSMakePathRelative(Tcl_Interp *interp,
00073                             Tcl_Obj *pathPtr, Tcl_Obj *cwdPtr);
00074 MODULE_SCOPE Tcl_Obj *  TclFSInternalToNormalized(
00075                             Tcl_Filesystem *fromFilesystem,
00076                             ClientData clientData,
00077                             FilesystemRecord **fsRecPtrPtr);
00078 MODULE_SCOPE int        TclFSEnsureEpochOk(Tcl_Obj *pathPtr,
00079                             Tcl_Filesystem **fsPtrPtr);
00080 MODULE_SCOPE void       TclFSSetPathDetails(Tcl_Obj *pathPtr,
00081                             FilesystemRecord *fsRecPtr,
00082                             ClientData clientData);
00083 MODULE_SCOPE Tcl_Obj *  TclFSNormalizeAbsolutePath(Tcl_Interp *interp,
00084                             Tcl_Obj *pathPtr, ClientData *clientDataPtr);
00085 
00086 /*
00087  * Private shared variables for use by tclIOUtil.c and tclPathObj.c
00088  */
00089 
00090 MODULE_SCOPE Tcl_Filesystem tclNativeFilesystem;
00091 MODULE_SCOPE Tcl_ThreadDataKey tclFsDataKey;
00092 
00093 /*
00094  * Private shared functions for use by tclIOUtil.c, tclPathObj.c and
00095  * tclFileName.c, and any platform-specific filesystem code.
00096  */
00097 
00098 MODULE_SCOPE Tcl_PathType TclFSGetPathType(Tcl_Obj *pathPtr,
00099                             Tcl_Filesystem **filesystemPtrPtr,
00100                             int *driveNameLengthPtr);
00101 MODULE_SCOPE Tcl_PathType TclFSNonnativePathType(CONST char *pathPtr,
00102                             int pathLen, Tcl_Filesystem **filesystemPtrPtr,
00103                             int *driveNameLengthPtr, Tcl_Obj **driveNameRef);
00104 MODULE_SCOPE Tcl_PathType TclGetPathType(Tcl_Obj *pathPtr,
00105                             Tcl_Filesystem **filesystemPtrPtr,
00106                             int *driveNameLengthPtr, Tcl_Obj **driveNameRef);
00107 MODULE_SCOPE int        TclFSEpochOk(int filesystemEpoch);
00108 MODULE_SCOPE int        TclFSCwdIsNative(void);
00109 MODULE_SCOPE Tcl_Obj *  TclWinVolumeRelativeNormalize(Tcl_Interp *interp,
00110                             CONST char *path, Tcl_Obj **useThisCwdPtr);
00111 
00112 MODULE_SCOPE Tcl_FSPathInFilesystemProc TclNativePathInFilesystem;
00113 MODULE_SCOPE Tcl_FSCreateInternalRepProc TclNativeCreateNativeRep;
00114 
00115 #endif /* _TCLFILESYSTEM */
00116 
00117 /*
00118  * Local Variables:
00119  * mode: c
00120  * c-basic-offset: 4
00121  * fill-column: 78
00122  * End:
00123  */



Generated on Wed Mar 12 12:18:16 2008 by  doxygen 1.5.1