Manual Pages for UNIX Darwin command on man Tcl_FSData
MyWebUniversity

Manual Pages for UNIX Darwin command on man Tcl_FSData

Filesystem(3) Tcl Library Procedures Filesystem(3)

NAME

TclFSRegister, TclFSUnregister, TclFSData, TclFSMountsChanged, TclFSGetFileSystemForPath, TclFSGetPathType, TclFSCopyFile,

TclFSCopyDirectory, TclFSCreateDirectory, TclFSDeleteFile, TclFSRe-

moveDirectory, TclFSRenameFile, TclFSListVolumes, TclFSEvalFile, TclFSLoadFile, TclFSMatchInDirectory, TclFSLink, TclFSLstat,

TclFSUtime, TclFSFileAttrsGet, TclFSFileAttrsSet, TclFSFileAt-

trStrings, TclFSStat, TclFSAccess, TclFSOpenFileChannel, TclFSGetCwd, TclFSChdir, TclFSPathSeparator, TclFSJoinPath,

TclFSSplitPath, TclFSEqualPaths, TclFSGetNormalizedPath, TclFSJoin-

ToPath, TclFSConvertToPathType, TclFSGetInternalRep, TclFSGetTrans-

latedPath, TclFSGetTranslatedStringPath, TclFSNewNativePath,

TclFSGetNativePath, TclFSFileSystemInfo, TclAllocStatBuf - proce-

dures to interact with any filesystem

SYNOPSIS

##iinncclluuddee <>

int TTccllFFSSRReeggiisstteerr(clientData, fsPtr) int TTccllFFSSUUnnrreeggiisstteerr(fsPtr) ClientData TTccllFFSSDDaattaa(fsPtr) void TTccllFFSSMMoouunnttssCChhaannggeedd(fsPtr) TclFilesystem* TTccllFFSSGGeettFFiilleeSSyysstteemmFFoorrPPaatthh(pathObjPtr) TclPathType TTccllFFSSGGeettPPaatthhTTyyppee(pathObjPtr) int TTccllFFSSCCooppyyFFiillee(srcPathPtr, destPathPtr) int TTccllFFSSCCooppyyDDiirreeccttoorryy(srcPathPtr, destPathPtr, errorPtr) int TTccllFFSSCCrreeaatteeDDiirreeccttoorryy(pathPtr) int TTccllFFSSDDeelleetteeFFiillee(pathPtr) int TTccllFFSSRReemmoovveeDDiirreeccttoorryy(pathPtr, int recursive, errorPtr) int TTccllFFSSRReennaammeeFFiillee(srcPathPtr, destPathPtr) TclObj* TTccllFFSSLLiissttVVoolluummeess(void) int TTccllFFSSEEvvaallFFiillee(interp, pathPtr) int TTccllFFSSLLooaaddFFiillee(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, handlePtr, unloadProcPtr) int TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy(interp, result, pathPtr, pattern, types) TclObj* TTccllFFSSLLiinnkk(linkNamePtr, toPtr, linkAction) int TTccllFFSSLLssttaatt(pathPtr, statPtr) int TTccllFFSSUUttiimmee(pathPtr, tval) int TTccllFFSSFFiilleeAAttttrrssGGeett(interp, int index, pathPtr, objPtrRef) int TTccllFFSSFFiilleeAAttttrrssSSeett(interp, int index, pathPtr, TclObj *objPtr) CONST char** TTccllFFSSFFiilleeAAttttrrSSttrriinnggss(pathPtr, objPtrRef) int TTccllFFSSSSttaatt(pathPtr, statPtr) int TTccllFFSSAAcccceessss(pathPtr, mode) TclChannel TTccllFFSSOOppeennFFiilleeCChhaannnneell(interp, pathPtr, modeString, permissions) TclObj* TTccllFFSSGGeettCCwwdd(interp) int TTccllFFSSCChhddiirr(pathPtr) TclObj* TTccllFFSSPPaatthhSSeeppaarraattoorr(pathPtr) TclObj* TTccllFFSSJJooiinnPPaatthh(listObj, elements) TclObj* TTccllFFSSSSpplliittPPaatthh(pathPtr, lenPtr) int TTccllFFSSEEqquuaallPPaatthhss(firstPtr, secondPtr) TclObj* TTccllFFSSGGeettNNoorrmmaalliizzeeddPPaatthh(interp, pathPtr) TclObj* TTccllFFSSJJooiinnTTooPPaatthh(basePtr, objc, objv) int TTccllFFSSCCoonnvveerrttTTooPPaatthhTTyyppee(interp, pathPtr) ClientData TTccllFFSSGGeettIInntteerrnnaallRReepp(pathPtr, fsPtr) TclObj* TTccllFFSSGGeettTTrraannssllaatteeddPPaatthh(interp, pathPtr) CONST char* TTccllFFSSGGeettTTrraannssllaatteeddSSttrriinnggPPaatthh(interp, pathPtr) TclObj* TTccllFFSSNNeewwNNaattiivveePPaatthh(fsPtr, clientData) CONST char* TTccllFFSSGGeettNNaattiivveePPaatthh(pathPtr) TclObj* TTccllFFSSFFiilleeSSyysstteemmIInnffoo(pathPtr) TclStatBuf* TTccllAAllllooccSSttaattBBuuff() AARRGGUUMMEENNTTSS TclFilesystem *fsPtr (in) Points to a structure containing the addresses of procedures that

can be called to perform the vari-

ous filesystem operations. TclObj *pathPtr (in) The path represented by this object

is used for the operation in ques-

tion. If the object does not

already have an internal ppaatthh rep-

resentation, it will be converted to have one. TclObj *srcPathPtr(in) As for ppaatthhPPttrr, but used for the source file for a copy or rename operation. TclObj *destPathPtr(in) As for ppaatthhPPttrr, but used for the destination filename for a copy or rename operation. CONST char *pattern (in) Only files or directories matching this pattern will be returned by TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy. GlobTypeData *types (in) Only files or directories matching the type descriptions contained in this structure will be returned by TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy. It is very important that the 'directory' flag

is properly handled. This parame-

ter may be NULL. TclInterp *interp (in) Interpreter to use either for results, evaluation, or reporting error messages. ClientData clientData(in) The native description of the path object to create. TclObj *firstPtr(in) The first of two path objects to

compare. The object may be con-

verted to ppaatthh type. TclObj *secondPtr(in) The second of two path objects to

compare. The object may be con-

verted to ppaatthh type.

TclObj *listObj (in) The list of path elements to oper-

ate on with a jjooiinn operation.

int elements (in) If non-negative, the number of ele-

ments in the listObj which should be joined together. If negative, then all elements are joined. TclObj **errorPtr(out) In the case of an error, filled with an object containing the name of the file which caused an error

in the various copy/rename opera-

tions. TclObj **objPtrRef(out) Filled with an object containing the result of the operation.

TclObj *result (out) Pre-allocated object in which to

store (by lappending) the list of

files or directories which are suc-

cessfully matched in TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy. int mode (in) Mask consisting of one or more of ROK, WOK, XOK and FOK. ROK, WOK and XOK request checking whether the file exists and has

read, write and execute permis-

sions, respectively. FOK just requests checking for the existence of the file. TclStatBuf *statPtr (out) The structure that contains the

result of a stat or lstat opera-

tion. CONST char *sym1 (in) Name of a procedure to look up in the file's symbol table CONST char *sym2 (in) Name of a procedure to look up in the file's symbol table TclPackageInitProc **proc1Ptr(out) Filled with the init function for this code. TclPackageInitProc **proc2Ptr(out)

Filled with the safe-init function

for this code. ClientData *clientDataPtr(out) Filled with the clientData value to pass to this code's unload function when it is called. TclfsUnloadFileProc **unloadProcPtr(out) Filled with the function to use to unload this piece of code. utimbuf *tval (in) The access and modification times in this structure are read and used to set those values for a given file. CONST char *modeString(in) Specifies how the file is to be

accessed. May have any of the val-

ues allowed for the mode argument to the Tcl ooppeenn command.

int permissions(in) POSIX-style permission flags such

as 0644. If a new file is created, these permissions will be set on the created file.

int *lenPtr (out) If non-NULL, filled with the number

of elements in the split path. TclObj *basePtr (in) The base path on to which to join the given elements. May be NULL. int objc (in) The number of elements in objv. TclObj *CONST objv[] (in) The elements to join to the given base path.

DESCRIPTION

There are several reasons for calling the TTccllFFSS...... functions rather than calling system level functions like aacccceessss and ssttaatt directly.

First, they will work cross-platform, so an extension which calls them

should work unmodified on Unix, MacOS and Windows. Second, the Windows implementation of some of these functions fixes some bugs in the system

level calls. Third, these function calls deal with any 'Utf to plat-

form-native' path conversions which may be required (and may cache the

results of such conversions for greater efficiency on subsequent calls). Fourth, and perhaps most importantly, all of these functions are 'virtual filesystem aware'. Any virtual filesystem which has been

registered (through TTccllFFSSRReeggiisstteerr) may reroute file access to alterna-

tive media or access methods. This means that all of these functions (and therefore the corresponding ffiillee, gglloobb, ppwwdd, ccdd, ooppeenn, etc. Tcl commands) may be operate on 'files' which are not native files in the native filesystem. This also means that any Tcl extension which accesses the filesystem through this API is automatically 'virtual filesystem aware'. Of course, if an extension accesses the native

filesystem directly (through platform-specific APIs, for example), then

Tcl cannot intercept such calls. If appropriate vfs's have been registered, the 'files' may, to give two examples, be remote (e.g. situated on a remote ftp server) or archived

(e.g. lying inside a .zip archive). Such registered filesystems pro-

vide a lookup table of functions to implement all or some of the func-

tionality listed here. Finally, the TTccllFFSSSSttaatt and TTccllFFSSLLssttaatt calls abstract away from what the 'struct stat' buffer buffer is actually declared to be, allowing the same code to be used both on systems with and systems without support for files larger than 2GB in size. The TTccllFFSS...... are objectified and may cache internal representations

and other path-related strings (e.g. the current working directory).

One side-effect of this is that one must not pass in objects with a

refCount of zero to any of these functions. If such calls were han-

dled, they might result in memory leaks (under some circumstances, the filesystem code may wish to retain a reference to the passed in object, and so one must not assume that after any of these calls return, the

object still has a refCount of zero - it may have been incremented), or

in a direct segfault due to the object being freed part way through the complex object manipulation required to ensure that the path is fully normalized and absolute for filesystem determination. The practical lesson to learn from this is that TTccllOObbjj **ppaatthh == TTccllNNeewwSSttrriinnggOObbjj((......)) ;; TTccllFFSS......((ppaatthh)) ;; TTccllDDeeccrrRReeffCCoouunntt((ppaatthh)) is wrong, and may segfault. The 'path' must have its refCount incremented before passing it in, or decrementing it. For this reason, objects with a refCount of zero are considered not to be valid filesystem paths and calling any TclFS API with such an object will result in no action being taken. TTccllFFSSCCooppyyFFiillee attempts to copy the file given by srcPathPtr to the path name given by destPathPtr. If the two paths given lie in the same

filesystem (according to TTccllFFSSGGeettFFiilleeSSyysstteemmFFoorrPPaatthh) then that filesys-

tem's 'copy file' function is called (if it is non-NULL). Otherwise

the function returns -1 and sets Tcl's errno to the 'EXDEV' posix error

code (which signifies a 'cross-domain link').

TTccllFFSSCCooppyyDDiirreeccttoorryy attempts to copy the directory given by srcPathPtr to the path name given by destPathPtr. If the two paths given lie in the same filesystem (according to TTccllFFSSGGeettFFiilleeSSyysstteemmFFoorrPPaatthh) then that

filesystem's 'copy file' function is called (if it is non-NULL). Oth-

erwise the function returns -1 and sets Tcl's errno to the 'EXDEV'

posix error code (which signifies a 'cross-domain link').

TTccllFFSSCCrreeaatteeDDiirreeccttoorryy attempts to create the directory given by pathPtr by calling the owning filesystem's 'create directory' function.

TTccllFFSSDDeelleetteeFFiillee attempts to delete the file given by pathPtr by call-

ing the owning filesystem's 'delete file' function. TTccllFFSSRReemmoovveeDDiirreeccttoorryy attempts to remove the directory given by pathPtr by calling the owning filesystem's 'remove directory' function.

TTccllFFSSRReennaammeeFFiillee attempts to rename the file or directory given by src-

PathPtr to the path name given by destPathPtr. If the two paths given lie in the same filesystem (according to TTccllFFSSGGeettFFiilleeSSyysstteemmFFoorrPPaatthh)

then that filesystem's 'rename file' function is called (if it is non-

NULL). Otherwise the function returns -1 and sets Tcl's errno to the

'EXDEV' posix error code (which signifies a ``cross-domain link'').

TTccllFFSSLLiissttVVoolluummeess calls each filesystem which has a non-NULL 'list vol-

umes' function and asks them to return their list of root volumes. It accumulates the return values in a list which is returned to the caller (with a refCount of 0).

TTccllFFSSEEvvaallFFiillee reads the file given by pathPtr and evaluates its con-

tents as a Tcl script. It returns the same information as TTccllEEvvaallOObb-

jjEExx. If the file couldn't be read then a Tcl error is returned to describe why the file couldn't be read. The eofchar for files is '\32' (^Z) for all platforms. If you require a ``^Z'' in code for string comparison, you can use ``\032'' or ``\u001a'', which will be safely substituted by the Tcl interpreter into ``^Z''. TTccllFFSSLLooaaddFFiillee dynamically loads a binary code file into memory and returns the addresses of two procedures within that file, if they are defined. The appropriate function for the filesystem to which pathPtr belongs will be called. If that filesystem does not implement this function (most virtual filesystems will not, because of OS limitations in dynamically loading binary code), Tcl will attempt to copy the file to a temporary directory and load that temporary file. Returns a standard Tcl completion code. If an error occurs, an error message is left in the interp's result.

TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy is used by the globbing code to search a direc-

tory for all files which match a given pattern. The appropriate func-

tion for the filesystem to which pathPtr belongs will be called. The return value is a standard Tcl result indicating whether an error occurred in globbing. Error messages are placed in interp, but good results are placed in the resultPtr given.

Note that the 'glob' code implements recursive pat-

terns internally, so this function will only ever be passed simple pat-

terns, which can be matched using the logic of 'string match'. To han-

dle recursion, Tcl will call this function frequently asking only for directories to be returned. TTccllFFSSLLiinnkk replaces the library version of readlink(), and extends it to support the creation of links. The appropriate function for the filesystem to which linkNamePtr belongs will be called. If the toPtr is NULL, a readlink action is performed. The result is a TclObj specifying the contents of the symbolic link given by linkNamePtr, or NULL if the link could not be read. The result is owned by the caller, which should call TclDecrRefCount when the result is no longer needed. If the toPtr is not NULL, Tcl should create a link of one of the types passed in in the linkAction flag. This flag

is an or'd combination of TCLCREATESYMBOLICLINK and TCLCRE-

ATEHARDLINK. Where a choice exists (i.e. more than one flag is passed in), the Tcl convention is to prefer symbolic links. When a link is successfully created, the return value should be toPtr (which is therefore already owned by the caller). If unsuccessful, NULL should be returned. TTccllFFSSLLssttaatt fills the stat structure statPtr with information about the specified file. You do not need any access rights to the file to get this information but you need search rights to all directories named in

the path leading to the file. The stat structure includes info regard-

ing device, inode (always 0 on Windows), privilege mode, nlink (always 1 on Windows), user id (always 0 on Windows), group id (always 0 on Windows), rdev (same as device on Windows), size, last access time, last modification time, and creation time. If path exists, TTccllFFSSLLssttaatt returns 0 and the stat structure is filled

with data. Otherwise, -1 is returned, and no stat info is given.

TTccllFFSSUUttiimmee replaces the library version of utime. For results see 'utime' documentation. If successful, the function will update the 'atime' and 'mtime' values of the file given. TTccllFFSSFFiilleeAAttttrrssGGeett implements read access for the hookable 'file attributes' subcommand. The appropriate function for the filesystem to which pathPtr belongs will be called. If the result is TCLOK, then an object was placed in objPtrRef, which will only be temporarily valid (unless TclIncrRefCount is called). TTccllFFSSFFiilleeAAttttrrssSSeett implements write access for the hookable 'file attributes' subcommand. The appropriate function for the filesystem to which pathPtr belongs will be called. TTccllFFSSFFiilleeAAttttrrSSttrriinnggss implements part of the hookable 'file attributes'

subcommand. The appropriate function for the filesystem to which path-

Ptr belongs will be called. The called procedure may either return an array of strings, or may instead return NULL and place a Tcl list into the given objPtrRef. Tcl will take that list and first increment its refCount before using it. On completion of that use, Tcl will decrement its refCount. Hence if

the list should be disposed of by Tcl when done, it should have a ref-

Count of zero, and if the list should not be disposed of, the filesys-

tem should ensure it retains a refCount on the object. TTccllFFSSAAcccceessss checks whether the process would be allowed to read, write or test for existence of the file (or other file system object) whose

name is pathname. If pathname is a symbolic link on Unix, then per-

missions of the file referred by this symbolic link are tested. On success (all requested permissions granted), zero is returned. On error (at least one bit in mode asked for a permission that is denied,

or some other error occurred), -1 is returned.

TTccllFFSSSSttaatt fills the stat structure statPtr with information about the specified file. You do not need any access rights to the file to get this information but you need search rights to all directories named in

the path leading to the file. The stat structure includes info regard-

ing device, inode (always 0 on Windows), privilege mode, nlink (always 1 on Windows), user id (always 0 on Windows), group id (always 0 on Windows), rdev (same as device on Windows), size, last access time, last modification time, and creation time. If path exists, TTccllFFSSSSttaatt returns 0 and the stat structure is filled

with data. Otherwise, -1 is returned, and no stat info is given.

TTccllFFSSOOppeennFFiilleeCChhaannnneell opens a file specified by pathPtr and returns a channel handle that can be used to perform input and output on the

file. This API is modeled after the ffooppeenn procedure of the Unix stan-

dard I/O library. The syntax and meaning of all arguments is similar to those given in the Tcl ooppeenn command when opening a file. If an error occurs while opening the channel, TTccllFFSSOOppeennFFiilleeCChhaannnneell returns NULL and records a POSIX error code that can be retrieved with

TTccllGGeettEErrrrnnoo. In addition, if interp is non-NULL, TTccllFFSSOOppeennFFiilleeCChhaann-

nneell leaves an error message in interp's result after any error.

The newly created channel is not registered in the supplied inter-

preter; to register it, use TTccllRReeggiisstteerrCChhaannnneell, described below. If one of the standard channels, ssttddiinn,, ssttddoouutt or ssttddeerrrr was previously closed, the act of creating the new channel also assigns it as a replacement for the standard channel. TTccllFFSSGGeettCCwwdd replaces the library version of getcwd(). It returns the Tcl library's current working directory. This may be different to the native platform's working directory, in the case for which the cwd is not in the native filesystem. The result is a pointer to a TclObj specifying the current directory, or NULL if the current directory could not be determined. If NULL is returned, an error message is left in the interp's result. The result already has its refCount incremented for the caller. When it is no longer needed, that refCount should be

decremented. This is needed for thread-safety purposes, to allow mul-

tiple threads to access this and related functions, while ensuring the results are always valid.

TTccllFFSSCChhddiirr replaces the library version of chdir(). The path is nor-

malized and then passed to the filesystem which claims it. If that filesystem does not implement this function, Tcl will fallback to a combination of stat and access to check whether the directory exists and has appropriate permissions. For results, see chdir() documentation. If successful, we keep a record of the successful path in cwdPathPtr for subsequent calls to getcwd. TTccllFFSSPPaatthhSSeeppaarraattoorr returns the separator character to be used for most specific element of the path specified by pathPtr (i.e. the last part of the path). The separator is returned as a TclObj containing a string of length 1. If the path is invalid, NULL is returned. TTccllFFSSJJooiinnPPaatthh takes the given TclObj, which should be a valid list, and returns the path object given by considering the first 'elements' elements as valid path segments. If elements < 0, we use the entire list. Returns object with refCount of zero, containing the joined path. TTccllFFSSSSpplliittPPaatthh takes the given TclObj, which should be a valid path, and returns a Tcl List object containing each segment of that path as an element. Returns list object with refCount of zero. If the passed in lenPtr is

non-NULL, we use it to return the number of elements in the returned

list. TTccllFFSSEEqquuaallPPaatthhss tests whether the two paths given represent the same filesystem object It returns 1 if the paths are equal, and 0 if they are different. If either path is NULL, 0 is always returned. TTccllFFSSGGeettNNoorrmmaalliizzeeddPPaatthh this important function attempts to extract from the given TclObj a unique normalized path representation, whose string value can be used as a unique identifier for the file. It returns the normalized path object, with refCount of zero, or NULL

if the path was invalid or could otherwise not be successfully con-

verted. Extraction of absolute, normalized paths is very efficient (because the filesystem operates on these representations internally), although the result when the filesystem contains numerous symbolic

links may not be the most user-friendly version of a path.

TTccllFFSSJJooiinnTTooPPaatthh takes the given object, which should usually be a valid path or NULL, and joins onto it the array of paths segments given. Returns object with refCount of zero, containing the joined path. TTccllFFSSCCoonnvveerrttTTooPPaatthhTTyyppee tries to convert the given TclObj to a valid Tcl path type, taking account of the fact that the cwd may have changed even if this object is already supposedly of the correct type. The filename may begin with "~" (to indicate current user's home directory) or "~" (to indicate any user's home directory). If the conversion succeeds (i.e. the object is a valid path in one of

the current filesystems), then TCLOK is returned. Otherwise TCLERROR

is returned, and an error message may be left in the interpreter. TTccllFFSSGGeettIInntteerrnnaallRReepp extracts the internal representation of a given path object, in the given filesystem. If the path object belongs to a different filesystem, we return NULL. If the internal representation is currently NULL, we attempt to generate it, by calling the filesystem's TTccllFFSSCCrreeaatteeIInntteerrnnaallRReeppPPrroocc. Returns NULL or a valid internal path representation. This internal representation is cached, so that repeated calls to this function will not require additional conversions. TTccllFFSSGGeettTTrraannssllaatteeddPPaatthh attempts to extract the translated path from the given TclObj. If the translation succeeds (i.e. the object is a valid path), then it is returned. Otherwise NULL will be returned, and an error message may be left in the interpreter. A "translated" path is one which contains no "~" or "~user" sequences (these have been expanded to their current representation in the filesystem). The object returned is owned by the caller, which must store it or call TclDecrRefCount to ensure memory

is freed. This function is of little practical use, and TTccllFFSSGGeettNNoorr-

mmaalliizzeeddPPaatthh or TTccllGGeettNNaattiivveePPaatthh are usually better functions to use for most purposes. TTccllFFSSGGeettTTrraannssllaatteeddSSttrriinnggPPaatthh does the same as TTccllFFSSGGeettTTrraannssllaatteeddPPaatthh,

but returns a character string or NULL. The string returned is dynami-

cally allocated and owned by the caller, which must store it or call ckfree to ensure it is freed. Again, TTccllFFSSGGeettNNoorrmmaalliizzeeddPPaatthh or

TTccllGGeettNNaattiivveePPaatthh are usually better functions to use for most pur-

poses. TTccllFFSSNNeewwNNaattiivveePPaatthh performs something like that reverse of the usual

obj->path->nativerep conversions. If some code retrieves a path in

native form (from, e.g. readlink or a native dialog), and that path is to be used at the Tcl level, then calling this function is an efficient way of creating the appropriate path object type. The resulting object is a pure 'path' object, which will only receive a

Utf-8 string representation if that is required by some Tcl code.

TTccllFFSSGGeettNNaattiivveePPaatthh is for use by the Win/Unix/MacOS native filesys-

tems, so that they can easily retrieve the native (char* or TCHAR*) representation of a path. This function is a convenience wrapper around TTccllFFSSGGeettIInntteerrnnaallRReepp, and assumes the native representation is

string-based. It may be desirable in the future to have non-string-

based native representations (for example, on MacOS, a representation using a fileSpec of FSRef structure would probably be more efficient). On Windows a full Unicode representation would allow for paths of unlimited length. Currently the representation is simply a character string containing the complete, absolute path in the native encoding. The native representation is cached so that repeated calls to this function will not require additional conversions. TTccllFFSSFFiilleeSSyysstteemmIInnffoo returns a list of two elements. The first element is the name of the filesystem (e.g. "native" or "vfs" or "zip" or "prowrap", perhaps), and the second is the particular type of the given

path within that filesystem (which is filesystem dependent). The sec-

ond element may be empty if the filesystem does not provide a further categorization of files.

A valid list object is returned, unless the path object is not recog-

nized, when NULL will be returned. TTccllFFSSGGeettFFiilleeSSyysstteemmFFoorrPPaatthh returns the a pointer to the TTccllFFiilleessyysstteemm which accepts this path as valid. If no filesystem will accept the path, NULL is returned. TTccllFFSSGGeettPPaatthhTTyyppee determines whether the given path is relative to the current directory, relative to the current volume, or absolute. It returns one of TCLPATHABSOLUTE, TCLPATHRELATIVE, or TCLPATHVOLUMERELATIVE TTccllAAllllooccSSttaattBBuuff allocates a TclStatBuf on the system heap (which may be deallocated by being passed to cckkffrreeee.) This allows extensions to invoke TTccllFFSSSSttaatt and TTccllFFSSLLSSttaatt without being dependent on the size of the buffer. That in turn depends on the flags used to build Tcl. TCLFILESYSTEM A filesystem provides a TTccllFFiilleessyysstteemm structure that contains pointers to functions that implement the various operations on a filesystem;

these operations are invoked as needed by the generic layer, which gen-

erally occurs through the functions listed above.

The TTccllFFiilleessyysstteemm structures are manipulated using the following meth-

ods. TTccllFFSSRReeggiisstteerr takes a pointer to a filesystem structure and an optional piece of data to associated with that filesystem. On calling this function, Tcl will attach the filesystem to the list of known filesystems, and it will become fully functional immediately. Tcl does not check if the same filesystem is registered multiple times (and in general that is not a good thing to do). TCLOK will be returned. TTccllFFSSUUnnrreeggiisstteerr removes the given filesystem structure from the list of known filesystems, if it is known, and returns TCLOK. If the

filesystem is not currently registered, TCLERROR is returned.

TTccllFFSSDDaattaa will return the ClientData associated with the given filesystem, if that filesystem is registered. Otherwise it will return NULL. TTccllFFSSMMoouunnttssCChhaannggeedd is used to inform the Tcl's core that the set of mount points for the given (already registered) filesystem have changed, and that cached file representations may therefore no longer be correct. The TTccllFFiilleessyysstteemm structure contains the following fields: typedef struct TclFilesystem { CONST char *typeName; int structureLength; TclFSVersion version; TclFSPathInFilesystemProc *pathInFilesystemProc; TclFSDupInternalRepProc *dupInternalRepProc; TclFSFreeInternalRepProc *freeInternalRepProc; TclFSInternalToNormalizedProc *internalToNormalizedProc; TclFSCreateInternalRepProc *createInternalRepProc; TclFSNormalizePathProc *normalizePathProc; TclFSFilesystemPathTypeProc *filesystemPathTypeProc; TclFSFilesystemSeparatorProc *filesystemSeparatorProc; TclFSStatProc *statProc; TclFSAccessProc *accessProc; TclFSOpenFileChannelProc *openFileChannelProc; TclFSMatchInDirectoryProc *matchInDirectoryProc; TclFSUtimeProc *utimeProc; TclFSLinkProc *linkProc; TclFSListVolumesProc *listVolumesProc; TclFSFileAttrStringsProc *fileAttrStringsProc; TclFSFileAttrsGetProc *fileAttrsGetProc; TclFSFileAttrsSetProc *fileAttrsSetProc; TclFSCreateDirectoryProc *createDirectoryProc; TclFSRemoveDirectoryProc *removeDirectoryProc; TclFSDeleteFileProc *deleteFileProc; TclFSCopyFileProc *copyFileProc; TclFSRenameFileProc *renameFileProc; TclFSCopyDirectoryProc *copyDirectoryProc; TclFSLstatProc *lstatProc; TclFSLoadFileProc *loadFileProc; TclFSGetCwdProc *getCwdProc; TclFSChdirProc *chdirProc; } TclFilesystem;

Except for the first three fields in this structure which contain sim-

ple data elements, all entries contain addresses of functions called by

the generic filesystem layer to perform the complete range of filesys-

tem related actions.

The many functions in this structure are broken down into three cate-

gories: infrastructure functions (almost all of which must be imple-

mented), operational functions (which must be implemented if a complete filesystem is provided), and efficiency functions (which need only be

implemented if they can be done so efficiently, or if they have side-

effects which are required by the filesystem; Tcl has less efficient emulations it can fall back on). It is important to note that, in the current version of Tcl, most of these fallbacks are only used to handle commands initiated in Tcl, not in C. What this means is, that if a 'file rename' command is issued in Tcl, and the relevant filesystem(s) do not implement their TclFSRenameFileProc, Tcl's core will instead fallback on a combination of other filesystem functions (it will use

TclFSCopyFileProc followed by TclFSDeleteFileProc, and if TclFSCopy-

FileProc is not implemented there is a further fallback). However, if a TclFSRenameFile command is issued at the C level, no such fallbacks occur. This is true except for the last four entries in the filesystem table (lstat, load, getcwd and chdir) for which fallbacks do in fact occur at the C level. As an example, here is the filesystem lookup table used by the "vfs" extension which allows filesystem actions to be implemented in Tcl. static TclFilesystem vfsFilesystem = { "tclvfs", sizeof(TclFilesystem), TCLFILESYSTEMVERSION1, &VfsPathInFilesystem, &VfsDupInternalRep, &VfsFreeInternalRep, /* No internal to normalized, since we don't create any * pure 'internal' TclObj path representations */ NULL, /* No create native rep function, since we don't use it * and don't choose to support uses of 'TclFSNewNativePath' */ NULL,

/* Normalize path isn't needed - we assume paths only have

* one representation */ NULL, &VfsFilesystemPathType, &VfsFilesystemSeparator, &VfsStat, &VfsAccess, &VfsOpenFileChannel, &VfsMatchInDirectory, &VfsUtime, /* We choose not to support symbolic links inside our vfs's */ NULL, &VfsListVolumes, &VfsFileAttrStrings, &VfsFileAttrsGet, &VfsFileAttrsSet, &VfsCreateDirectory, &VfsRemoveDirectory, &VfsDeleteFile,

/* No copy file - fallback will occur at Tcl level */

NULL,

/* No rename file - fallback will occur at Tcl level */

NULL,

/* No copy directory - fallback will occur at Tcl level */

NULL, /* Core will use stat for lstat */ NULL,

/* No load - fallback on core implementation */

NULL,

/* We don't need a getcwd or chdir - fallback on Tcl's versions */

NULL, NULL }; Any functions which take path names in TclObj form take those names in

UTF-8 form. The filesystem infrastructure API is designed to support

efficient, cached conversion of these UTF-8 paths to other native rep-

resentations.

TYPENAME

The typeName field contains a null-terminated string that identifies

the type of the filesystem implemented, e.g. nnaattiivvee or zziipp or vvffss. SSTTRRUUCCTTUURREE LLEENNGGTTHH The structureLength field is generally implemented as sizeof(TclFilesystem), and is there to allow easier binary backwards compatibility if the size of the structure changes in a future Tcl release. VVEERRSSIIOONN h vrin il sol b st o TCLFILESYSTEMVERSION1

FILESYSTEM INFRASTRUCTURE

These fields contain addresses of functions which are used to associate a particular filesystem with a file path, and deal with the internal handling of path representations, for example copying and freeing such representations. PATHINFILESYSTEMPROC The pathInFilesystemProc field contains the address of a function which is called to determine whether a given path object belongs to this

filesystem or not. Tcl will only call the rest of the filesystem func-

tions with a path for which this function has returned TTCCLLOOKK. If the

path does not belong, -1 should be returned (the behaviour of Tcl for

any other return value is not defined). If TTCCLLOOKK is returned, then the optional cclliieennttDDaattaaPPttrr output parameter can be used to return an internal (filesystem specific) representation of the path, which will be cached inside the path object, and may be retrieved efficiently by the other filesystem functions. Tcl will simultaneously cache the fact that this path belongs to this filesystem. Such caches are invalidated when filesystem structures are added or removed from Tcl's internal list of known filesystems. typedef int TclFSPathInFilesystemProc( TclObj *pathPtr, ClientData *clientDataPtr); DDUUPPIINNTTEERRNNAALLRREEPPPPRROOCC This function makes a copy of a path's internal representation, and is called when Tcl needs to duplicate a path object. If NULL, Tcl will simply not copy the internal representation, which may then need to be regenerated later. typedef ClientData TclFSDupInternalRepProc( ClientData clientData); FFRREEEEIINNTTEERRNNAALLRREEPPPPRROOCC Free the internal representation. This must be implemented if internal representations need freeing (i.e. if some memory is allocated when an internal representation is generated), but may otherwise be NULL. typedef void TclFSFreeInternalRepProc( ClientData clientData); IINNTTEERRNNAALLTTOONNOORRMMAALLIIZZEEDDPPRROOCC Function to convert internal representation to a normalized path. Only required if the filesystem creates pure path objects with no string/path representation. The return value is a Tcl object whose string representation is the normalized path. typedef TclObj* TclFSInternalToNormalizedProc( ClientData clientData); CCRREEAATTEEIINNTTEERRNNAALLRREEPPPPRROOCC

Function to take a path object, and calculate an internal representa-

tion for it, and store that native representation in the object. May be NULL if paths have no internal representation, or if the

TclFSPathInFilesystemProc for this filesystem always immediately cre-

ates an internal representation for paths it accepts. typedef ClientData TclFSCreateInternalRepProc( TclObj *pathPtr); NNOORRMMAALLIIZZEEPPAATTHHPPRROOCC

Function to normalize a path. Should be implemented for all filesys-

tems which can have multiple string representations for the same path object. In Tcl, every 'path' must have a single unique 'normalized' string representation. Depending on the filesystem, there may be more than one unnormalized string representation which refers to that path (e.g. a relative path, a path with different character case if the filesystem is case insensitive, a path contain a reference to a home directory such as '~', a path containing symbolic links, etc). If the very last component in the path is a symbolic link, it should not be converted into the object it points to (but its case or other aspects should be made unique). All other path components should be converted from symbolic links. This one exception is required to agree with

Tcl's semantics with 'file delete', 'file rename', 'file copy' operat-

ing on symbolic links. This function may be called with 'nextCheck-

point' either at the beginning of the path (i.e. zero), at the end of the path, or at any intermediate file separator in the path. It will never point to any other arbitrary position in the path. In the last of the three valid cases, the implementation can assume that the path up to and including the file separator is known and normalized. typedef int TclFSNormalizePathProc( TclInterp *interp, TclObj *pathPtr, int nextCheckpoint); FILESYSTEM OPERATIONS

The fields in this section of the structure contain addresses of func-

tions which are called to carry out the basic filesystem operations. A

filesystem which expects to be used with the complete standard Tcl com-

mand set must implement all of these. If some of them are not imple-

mented, then certain Tcl commands may fail when operating on paths

within that filesystem. However, in some instances this may be desir-

able (for example, a read-only filesystem should not implement the last

four functions, and a filesystem which does not support symbolic links need not implement the rreeaaddlliinnkk function, etc. The Tcl core expects filesystems to behave in this way). FILESYSTEMPATHTYPEPROC Function to determine the type of a path in this filesystem. May be NULL, in which case no type information will be available to users of the filesystem. The 'type' is used only for informational purposes, and should be returned as the string representation of the TclObj which is returned. A typical return value might be "networked", "zip" or "ftp". The TclObj result is owned by the filesystem and so Tcl will increment the refCount of that object if it wishes to retain a reference to it. typedef TclObj* TclFSFilesystemPathTypeProc( TclObj *pathPtr); FILESYSTEMSEPARATORPROC Function to return the separator character(s) for this filesystem. Must be implemented, otherwise the ffiillee sseeppaarraattoorr command will not

function correctly. The usual return value will be a TclObj contain-

ing the string "/". typedef TclObj* TclFSFilesystemSeparatorProc( TclObj *pathPtr); SSTTAATTPPRROOCC Function to process a TTccllFFSSSSttaatt(()) call. Must be implemented for any reasonable filesystem, since many Tcl level commands depend crucially upon it (e.g. ffiillee aattiimmee, ffiillee iissddiirreeccttoorryy, ffiillee ssiizzee, gglloobb). typedef int TclFSStatProc( TclObj *pathPtr, TclStatBuf *statPtr); The TTccllFFSSSSttaattPPrroocc fills the stat structure statPtr with information about the specified file. You do not need any access rights to the

file to get this information but you need search rights to all directo-

ries named in the path leading to the file. The stat structure includes info regarding device, inode (always 0 on Windows), privilege mode, nlink (always 1 on Windows), user id (always 0 on Windows), group id (always 0 on Windows), rdev (same as device on Windows), size, last access time, last modification time, and creation time. If the file represented by pathPtr exists, the TTccllFFSSSSttaattPPrroocc returns 0

and the stat structure is filled with data. Otherwise, -1 is returned,

and no stat info is given. AACCCCEESSSSPPRROOCC Function to process a TTccllFFSSAAcccceessss(()) call. Must be implemented for any reasonable filesystem, since many Tcl level commands depend crucially upon it (e.g. ffiillee eexxiissttss, ffiillee rreeaaddaabbllee). typedef int TclFSAccessProc( TclObj *pathPtr, int mode); The TTccllFFSSAAcccceessssPPrroocc checks whether the process would be allowed to read, write or test for existence of the file (or other file system object) whose name is pathname. If pathname is a symbolic link, then permissions of the file referred by this symbolic link should be tested. On success (all requested permissions granted), zero is returned. On error (at least one bit in mode asked for a permission that is denied,

or some other error occurred), -1 is returned.

OOPPEENNFFIILLEECCHHAANNNNEELLPPRROOCC

Function to process a TTccllFFSSOOppeennFFiilleeCChhaannnneell(()) call. Must be imple-

mented for any reasonable filesystem, since any operations which require open or accessing a file's contents will use it (e.g. ooppeenn, eennccooddiinngg, and many Tk commands). typedef TclChannel TclFSOpenFileChannelProc( TclInterp *interp, TclObj *pathPtr, int mode, int permissions); The TTccllFFSSOOppeennFFiilleeCChhaannnneellPPrroocc opens a file specified by pathPtr and returns a channel handle that can be used to perform input and output on the file. This API is modeled after the ffooppeenn procedure of the Unix

standard I/O library. The syntax and meaning of all arguments is simi-

lar to those given in the Tcl ooppeenn command when opening a file, where the mode argument is a combination of the POSIX flags ORDONLY, OWRONLY, etc. If an error occurs while opening the channel, the TTccllFFSSOOppeennFFiilleeCChhaannnneellPPrroocc returns NULL and records a POSIX error code that can be retrieved with TTccllGGeettEErrrrnnoo. In addition, if interp is

non-NULL, the TTccllFFSSOOppeennFFiilleeCChhaannnneellPPrroocc leaves an error message in

interp's result after any error.

The newly created channel is not registered in the supplied inter-

preter; to register it, use TTccllRReeggiisstteerrCChhaannnneell. If one of the standard channels, ssttddiinn,, ssttddoouutt or ssttddeerrrr was previously closed, the act of

creating the new channel also assigns it as a replacement for the stan-

dard channel. MMAATTCCHHIINNDDIIRREECCTTOORRYYPPRROOCC

Function to process a TTccllFFSSMMaattcchhIInnDDiirreeccttoorryy(()) call. If not imple-

mented, then glob and recursive copy functionality will be lacking in the filesystem (and this may impact commands like 'encoding names' which use glob functionality internally). typedef int TclFSMatchInDirectoryProc( TclInterp* interp, TclObj *result, TclObj *pathPtr, CONST char *pattern, TclGlobTypeData * types);

The function should return all files or directories (or other filesys-

tem objects) which match the given pattern and accord with the types specification given. There are two ways in which this function may be called. If pattern is NULL, then pathPtr is a full path specification of a single file or directory which should be checked for existence and correct type. Otherwise, pathPtr is a directory, the contents of which

the function should search for files or directories which have the cor-

rect type. In either case, pathPtr can be assumed to be both non-NULL

and non-empty. It is not currently documented whether pathPtr will

have a file separator at its end of not, so code should be flexible to both possibilities. The return value is a standard Tcl result indicating whether an error occurred in the matching process. Error messages are placed in interp, but on a TCLOK result, the interpreter should not be modified, but rather results should be added to the result object given (which can be assumed to be a valid Tcl list). The matches added to result should include any path prefix given in pathPtr (this usually means they will be absolute path specifications). Note that if no matches are found,

that simply leads to an empty result -- errors are only signaled for

actual file or filesystem problems which may occur during the matching process. UUTTIIMMEEPPRROOCC Function to process a TTccllFFSSUUttiimmee(()) call. Required to allow setting

(not reading) of times with 'file mtime', 'file atime' and the open-

r/open-w/fcopy implementation of 'file copy'.

typedef int TclFSUtimeProc( TclObj *pathPtr, struct utimbuf *tval); The access and modification times of the file specified by pathPtr should be changed to the values given in the tval structure. The return value is a standard Tcl result indicating whether an error occurred in the process. LLIINNKKPPRROOCC Function to process a TTccllFFSSLLiinnkk(()) call. Should be implemented only if the filesystem supports links, and may otherwise be NULL. typedef TclObj* TclFSLinkProc( TclObj *linkNamePtr, TclObj *toPtr, int linkAction); If toPtr is NULL, the function is being asked to read the contents of a link. The result is a TclObj specifying the contents of the link given by linkNamePtr, or NULL if the link could not be read. The result is owned by the caller, which should call TclDecrRefCount when the result is no longer needed. If toPtr is not NULL, the function should attempt to create a link. The result in this case should be toPtr if the link was successful and NULL otherwise. In this case the result is not owned by the caller. See the documentation for TTccllFFSSLLiinnkk for the correct interpretation of the linkAction flags. LLIISSTTVVOOLLUUMMEESSPPRROOCC Function to list any filesystem volumes added by this filesystem. Should be implemented only if the filesystem adds volumes at the head of the filesystem, so that they can be returned by 'file volumes'. typedef TclObj* TclFSListVolumesProc(void); The result should be a list of volumes added by this filesystem, or NULL (or an empty list) if no volumes are provided. The result object is considered to be owned by the filesystem (not by Tcl's core), but should be given a refCount for Tcl. Tcl will use the contents of the list and then decrement that refCount. This allows filesystems to choose whether they actually want to retain a 'master list' of volumes or not (if not, they generate the list on the fly and pass it to Tcl with a refCount of 1 and then forget about the list, if yes, then they simply increment the refCount of their master list and pass it to Tcl which will copy the contents and then decrement the count back to where it was).

Therefore, Tcl considers return values from this proc to be read-only.

FFIILLEEAATTTTRRSSTTRRIINNGGSSPPRROOCC Function to list all attribute strings which are valid for this filesystem. If not implemented the filesystem will not support the ffiillee aattttrriibbuutteess command. This allows arbitrary additional information to be attached to files in the filesystem. If it is not implemented, there is no need to implement the ggeett and sseett methods. typedef CONST char** TclFSFileAttrStringsProc( TclObj *pathPtr, TclObj** objPtrRef); The called function may either return an array of strings, or may instead return NULL and place a Tcl list into the given objPtrRef. Tcl will take that list and first increment its refCount before using it. On completion of that use, Tcl will decrement its refCount. Hence if

the list should be disposed of by Tcl when done, it should have a ref-

Count of zero, and if the list should not be disposed of, the filesys-

tem should ensure it retains a refCount on the object. FFIILLEEAATTTTRRSSGGEETTPPRROOCC Function to process a TTccllFFSSFFiilleeAAttttrrssGGeett(()) call, used by 'file attributes'. typedef int TclFSFileAttrsGetProc( TclInterp *interp, int index, TclObj *pathPtr, TclObj **objPtrRef); Returns a standard Tcl return code. The attribute value retrieved, which corresponds to the index'th element in the list returned by the TclFSFileAttrStringsProc, is a TclObj placed in objPtrRef (if TCLOK was returned) and is likely to have a refCount of zero. Either way we must either store it somewhere (e.g. the Tcl result), or Incr/Decr its refCount to ensure it is properly freed. FFIILLEEAATTTTRRSSSSEETTPPRROOCC Function to process a TTccllFFSSFFiilleeAAttttrrssSSeett(()) call, used by 'file

attributes'. If the filesystem is read-only, there is no need to

implement this. typedef int TclFSFileAttrsSetProc( TclInterp *interp, int index, TclObj *pathPtr, TclObj *objPtr); The attribute value of the index'th element in the list returned by the TclFSFileAttrStringsProc should be set to the objPtr given. CCRREEAATTEEDDIIRREECCTTOORRYYPPRROOCC

Function to process a TTccllFFSSCCrreeaatteeDDiirreeccttoorryy(()) call. Should be imple-

mented unless the FS is read-only.

typedef int TclFSCreateDirectoryProc( TclObj *pathPtr); The return value is a standard Tcl result indicating whether an error occurred in the process. If successful, a new directory should have been added to the filesystem in the location specified by pathPtr. RREEMMOOVVEEDDIIRREECCTTOORRYYPPRROOCC

Function to process a 'TclFSRemoveDirectory()' call. Should be imple-

mented unless the FS is read-only.

typedef int TclFSRemoveDirectoryProc( TclObj *pathPtr, int recursive, TclObj **errorPtr); The return value is a standard Tcl result indicating whether an error occurred in the process. If successful, the directory specified by pathPtr should have been removed from the filesystem. If the recursive

flag is given, then a non-empty directory should be deleted without

error. If an error does occur, the name of the file or directory which caused the error should be placed in errorPtr. DDEELLEETTEEFFIILLEEPPRROOCC Function to process a TTccllFFSSDDeelleetteeFFiillee(()) call. Should be implemented

unless the FS is read-only.

typedef int TclFSDeleteFileProc( TclObj *pathPtr); The return value is a standard Tcl result indicating whether an error occurred in the process. If successful, the file specified by pathPtr should have been removed from the filesystem. Note that, if the filesystem supports symbolic links, Tcl will always call this function and not TclFSRemoveDirectoryProc when needed to delete them (even if they are symbolic links to directories). FILESYSTEM EFFICIENCYLLSSTTAATTPPRROOCC Function to process a TTccllFFSSLLssttaatt(()) call. If not implemented, Tcl will attempt to use the statProc defined above instead. Therefore it need only be implemented if a filesystem can differentiate between ssttaatt and llssttaatt calls. typedef int TclFSLstatProc( TclObj *pathPtr, TclStatBuf *statPtr); The behavior of this function is very similar to that of the

TclFSStatProc defined above, except that if it is applied to a sym-

bolic link, it returns information about the link, not about the target file. CCOOPPYYFFIILLEEPPRROOCC Function to process a TTccllFFSSCCooppyyFFiillee(()) call. If not implemented Tcl

will fall back on open-r, open-w and fcopy as a copying mechanism.

Therefore it need only be implemented if the filesystem can perform that action more efficiently. typedef int TclFSCopyFileProc( TclObj *srcPathPtr, TclObj *destPathPtr); The return value is a standard Tcl result indicating whether an error occurred in the copying process. Note that, destPathPtr is the name of the file which should become the copy of srcPathPtr. It is never the name of a directory into which srcPathPtr could be copied (i.e. the function is much simpler than the Tcl level 'file copy' subcommand). Note that, if the filesystem supports symbolic links, Tcl will always call this function and not TclFSCopyDirectoryProc when needed to copy them (even if they are symbolic links to directories).

RENAMEFILEPROC

Function to process a TTccllFFSSRReennaammeeFFiillee(()) call. If not implemented, Tcl will fall back on a copy and delete mechanism. Therefore it need only

be implemented if the filesystem can perform that action more effi-

ciently. typedef int TclFSRenameFileProc( TclObj *srcPathPtr, TclObj *destPathPtr); The return value is a standard Tcl result indicating whether an error occurred in the renaming process. CCOOPPYYDDIIRREECCTTOORRYYPPRROOCC Function to process a TTccllFFSSCCooppyyDDiirreeccttoorryy(()) call. If not implemented,

Tcl will fall back on a recursive create-dir, file copy mechanism.

Therefore it need only be implemented if the filesystem can perform that action more efficiently. typedef int TclFSCopyDirectoryProc( TclObj *srcPathPtr, TclObj *destPathPtr, TclObj **errorPtr); The return value is a standard Tcl result indicating whether an error occurred in the copying process. If an error does occur, the name of the file or directory which caused the error should be placed in

errorPtr. Note that, destPathPtr is the name of the directory-name

which should become the mirror-image of srcPathPtr. It is not the name

of a directory into which srcPathPtr should be copied (i.e. the func-

tion is much simpler than the Tcl level 'file copy' subcommand). LLOOAADDFFIILLEEPPRROOCC Function to process a TTccllFFSSLLooaaddFFiillee(()) call. If not implemented, Tcl

will fall back on a copy to native-temp followed by a TclFSLoadFile on

that temporary copy. Therefore it need only be implemented if the filesystem can load code directly, or it can be implemented simply to

return TCLERROR to disable load functionality in this filesystem

entirely. typedef int TclFSLoadFileProc( TclInterp * interp, TclObj *pathPtr, TclLoadHandle * handlePtr, TclFSUnloadFileProc * unloadProcPtr); Returns a standard Tcl completion code. If an error occurs, an error message is left in the interp's result. The function dynamically loads a binary code file into memory. On a successful load, the handlePtr should be filled with a token for the dynamically loaded file, and the unloadProcPtr should be filled in with the address of a procedure. The procedure will be called with the given TclLoadHandle as its only parameter when Tcl needs to unload the file. UUNNLLOOAADDFFIILLEEPPRROOCC Function to unload a previously successfully loaded file. If load was implemented, then this should also be implemented, if there is any cleanup action required. typedef void TclFSUnloadFileProc( TclLoadHandle loadHandle); GGEETTCCWWDDPPRROOCC Function to process a TTccllFFSSGGeettCCwwdd(()) call. Most filesystems need not implement this. It will usually only be called once, if 'getcwd' is called before 'chdir'. May be NULL. typedef TclObj* TclFSGetCwdProc( TclInterp *interp);

If the filesystem supports a native notion of a current working direc-

tory (which might perhaps change independent of Tcl), this function should return that cwd as the result, or NULL if the current directory

could not be determined (e.g. the user does not have appropriate per-

missions on the cwd directory). If NULL is returned, an error message is left in the interp's result. CCHHDDIIRRPPRROOCC

Function to process a TTccllFFSSCChhddiirr(()) call. If filesystems do not imple-

ment 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, 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). typedef int TclFSChdirProc( TclObj *pathPtr); The TTccllFFSSCChhddiirrPPrroocc changes the applications current working directory

to the value specified in pathPtr. The function returns -1 on error or

0 on success. KKEEYYWWOORRDDSS stat access filesystem vfs Tcl 8.4 Filesystem(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™