filesystem.3

来自「tcl是工具命令语言」· 3 代码 · 共 1,350 行 · 第 1/4 页

3
1,350
字号
documented whether \fIpathPtr\fR will have a file separator at its end ofnot, so code should be flexible to both possibilities..PPThe return value is a standard Tcl result indicating whether an erroroccurred in the matching process.  Error messages are placed in interp, but on a TCL_OK result, the interpreter should not be modified, butrather results should be added to the \fIresult\fR object given(which can be assumed to be a valid Tcl list).  The matches addedto \fIresult\fR should include any path prefix given in \fIpathPtr\fR (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 filesystemproblems which may occur during the matching process..SH UTIMEPROC       .PPFunction to process a \fBTcl_FSUtime()\fR call.  Required to allow setting(not reading) of times with 'file mtime', 'file atime' and theopen-r/open-w/fcopy implementation of 'file copy'..PP.CStypedef int Tcl_FSUtimeProc(	Tcl_Obj *\fIpathPtr\fR, 	struct utimbuf *\fItval\fR);.CE.PPThe access and modification times of the file specified by \fIpathPtr\fRshould be changed to the values given in the \fItval\fR structure..PPThe return value is a standard Tcl result indicating whether an erroroccurred in the process..SH LINKPROC .PPFunction to process a \fBTcl_FSLink()\fR call.  Should be implementedonly if the filesystem supports links, and may otherwise be NULL..PP.CStypedef Tcl_Obj* Tcl_FSLinkProc(	Tcl_Obj *\fIlinkNamePtr\fR,	Tcl_Obj *\fItoPtr\fR,	int \fIlinkAction\fR);.CE.PPIf \fItoPtr\fR is NULL, the function is being asked to read thecontents of a link.  The result is a Tcl_Obj specifying the contents ofthe link given by \fIlinkNamePtr\fR, or NULL if the link couldnot be read.  The result is owned by the caller, which should callTcl_DecrRefCount when the result is no longer needed.  If \fItoPtr\fR is not NULL, the function should attempt to create a link.  The resultin this case should be \fItoPtr\fR if the link was successful and NULLotherwise.  In this case the result is not owned by the caller. Seethe documentation for \fBTcl_FSLink\fR for the correct interpretationof the \fIlinkAction\fR flags..SH LISTVOLUMESPROC	    .PPFunction to list any filesystem volumes added by this filesystem.Should be implemented only if the filesystem adds volumes at the headof the filesystem, so that they can be returned by 'file volumes'..PP.CStypedef Tcl_Obj* Tcl_FSListVolumesProc(void);.CE.PPThe result should be a list of volumes added by this filesystem, orNULL (or an empty list) if no volumes are provided.  The result objectis considered to be owned by the filesystem (not by Tcl's core), butshould be given a refCount for Tcl.  Tcl will use the contents of thelist and then decrement that refCount.  This allows filesystems tochoose whether they actually want to retain a 'master list' of volumesor not (if not, they generate the list on the fly and pass it to Tclwith a refCount of 1 and then forget about the list, if yes, thenthey simply increment the refCount of their master list and pass itto Tcl which will copy the contents and then decrement the count backto where it was)..PPTherefore, Tcl considers return values from this proc to be read-only..PP.SH FILEATTRSTRINGSPROC.PPFunction to list all attribute strings which are valid for thisfilesystem.  If not implemented the filesystem will not supportthe \fBfile attributes\fR command.  This allows arbitrary additionalinformation to be attached to files in the filesystem.  If it isnot implemented, there is no need to implement the \fBget\fR and \fBset\fRmethods..PP.CStypedef CONST char** Tcl_FSFileAttrStringsProc(	Tcl_Obj *\fIpathPtr\fR, 	Tcl_Obj** \fIobjPtrRef\fR);.CE.PPThe called function may either return an array of strings, or mayinstead return NULL and place a Tcl list into the given objPtrRef.  Tclwill take that list and first increment its refCount before using it.On completion of that use, Tcl will decrement its refCount.  Hence ifthe list should be disposed of by Tcl when done, it should have arefCount of zero, and if the list should not be disposed of, thefilesystem should ensure it retains a refCount on the object..SH FILEATTRSGETPROC.PPFunction to process a \fBTcl_FSFileAttrsGet()\fR call, used by 'fileattributes'..PP.CStypedef int Tcl_FSFileAttrsGetProc(	Tcl_Interp *\fIinterp\fR,	int \fIindex\fR, 	Tcl_Obj *\fIpathPtr\fR,	Tcl_Obj **\fIobjPtrRef\fR);.CE.PPReturns a standard Tcl return code.  The attribute value retrieved,which corresponds to the \fIindex\fR'th element in the list returned bythe Tcl_FSFileAttrStringsProc, is a Tcl_Obj placed in objPtrRef (ifTCL_OK was returned) and is likely to have a refCount of zero.  Eitherway we must either store it somewhere (e.g. the Tcl result), orIncr/Decr its refCount to ensure it is properly freed..SH FILEATTRSSETPROC.PPFunction to process a \fBTcl_FSFileAttrsSet()\fR call, used by 'fileattributes'.  If the filesystem is read-only, there is no needto implement this..PP.CStypedef int Tcl_FSFileAttrsSetProc(	Tcl_Interp *\fIinterp\fR,	int \fIindex\fR, 	Tcl_Obj *\fIpathPtr\fR,	Tcl_Obj *\fIobjPtr\fR);.CE.PPThe attribute value of the \fIindex\fR'th element in the list returned bythe Tcl_FSFileAttrStringsProc should be set to the \fIobjPtr\fR given..SH CREATEDIRECTORYPROC	    .PPFunction to process a \fBTcl_FSCreateDirectory()\fR call.  Should beimplemented unless the FS is read-only..PP.CStypedef int Tcl_FSCreateDirectoryProc(	Tcl_Obj *\fIpathPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the process.  If successful, a new directory should havebeen added to the filesystem in the location specified by\fIpathPtr\fR..SH REMOVEDIRECTORYPROC	    .PPFunction to process a 'Tcl_FSRemoveDirectory()' call.  Should beimplemented unless the FS is read-only..PP.CStypedef int Tcl_FSRemoveDirectoryProc(	Tcl_Obj *\fIpathPtr\fR,	int \fIrecursive\fR, 	Tcl_Obj **\fIerrorPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the process.  If successful, the directory specified by\fIpathPtr\fR should have been removed from the filesystem.  If the\fIrecursive\fR flag is given, then a non-empty directory shouldbe deleted without error.  If an error does occur, the name ofthe file or directory which caused the error should be placed in\fIerrorPtr\fR..SH DELETEFILEPROC	    .PPFunction to process a \fBTcl_FSDeleteFile()\fR call.  Should be implementedunless the FS is read-only..PP.CStypedef int Tcl_FSDeleteFileProc(	Tcl_Obj *\fIpathPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the process.  If successful, the file specified by\fIpathPtr\fR should have been removed from the filesystem.  Note that,if the filesystem supports symbolic links, Tcl will always call thisfunction and not Tcl_FSRemoveDirectoryProc when needed to delete them(even if they are symbolic links to directories)..SH "FILESYSTEM EFFICIENCY".PP.SH LSTATPROC	    .PPFunction to process a \fBTcl_FSLstat()\fR call.  If not implemented, Tclwill attempt to use the \fIstatProc\fR defined above instead.  Thereforeit need only be implemented if a filesystem can differentiate between\fBstat\fR and \fBlstat\fR calls..PP.CStypedef int Tcl_FSLstatProc(	Tcl_Obj *\fIpathPtr\fR, 	Tcl_StatBuf *\fIstatPtr\fR);.CE.PPThe behavior of this function is very similar to that of the Tcl_FSStatProc defined above, except that if it is appliedto a symbolic link, it returns information about the link, notabout the target file..PP.SH COPYFILEPROC .PPFunction to process a \fBTcl_FSCopyFile()\fR call.  If not implemented Tclwill fall back on open-r, open-w and fcopy as a copying mechanism.Therefore it need only be implemented if the filesystem can performthat action more efficiently..PP.CStypedef int Tcl_FSCopyFileProc(	Tcl_Obj *\fIsrcPathPtr\fR,	Tcl_Obj *\fIdestPathPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the copying process.  Note that, \fIdestPathPtr\fR is thename of the file which should become the copy of \fIsrcPathPtr\fR. Itis never the name of a directory into which \fIsrcPathPtr\fR could becopied (i.e. the function is much simpler than the Tcl level 'filecopy' subcommand).  Note that,if the filesystem supports symbolic links, Tcl will always call thisfunction and not Tcl_FSCopyDirectoryProc when needed to copy them(even if they are symbolic links to directories)..SH RENAMEFILEPROC	    .PPFunction to process a \fBTcl_FSRenameFile()\fR call.  If not implemented,Tcl will fall back on a copy and delete mechanism.  Therefore it needonly be implemented if the filesystem can perform that action moreefficiently..PP.CStypedef int Tcl_FSRenameFileProc(	Tcl_Obj *\fIsrcPathPtr\fR,	Tcl_Obj *\fIdestPathPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the renaming process..SH COPYDIRECTORYPROC	    .PPFunction to process a \fBTcl_FSCopyDirectory()\fR call.  If notimplemented, Tcl will fall back on a recursive create-dir, file copymechanism.  Therefore it need only be implemented if the filesystem canperform that action more efficiently..PP.CStypedef int Tcl_FSCopyDirectoryProc(	Tcl_Obj *\fIsrcPathPtr\fR,	Tcl_Obj *\fIdestPathPtr\fR, 	Tcl_Obj **\fIerrorPtr\fR);.CE.PPThe return value is a standard Tcl result indicating whether an erroroccurred in the copying process.  If an error does occur, the name ofthe file or directory which caused the error should be placed in\fIerrorPtr\fR. Note that, \fIdestPathPtr\fR is the name of thedirectory-name which should become the mirror-image of\fIsrcPathPtr\fR. It is not the name of a directory into which\fIsrcPathPtr\fR should be copied (i.e. the function is much simplerthan the Tcl level 'file copy' subcommand)..SH LOADFILEPROC .PPFunction to process a \fBTcl_FSLoadFile()\fR call.  If not implemented, Tclwill fall back on a copy to native-temp followed by a Tcl_FSLoadFile onthat temporary copy.  Therefore it need only be implemented if thefilesystem can load code directly, or it can be implemented simply toreturn TCL_ERROR to disable load functionality in this filesystementirely..PP.CStypedef int Tcl_FSLoadFileProc(	Tcl_Interp * \fIinterp\fR, 	Tcl_Obj *\fIpathPtr\fR, 	Tcl_LoadHandle * \fIhandlePtr\fR,	Tcl_FSUnloadFileProc * \fIunloadProcPtr\fR);.CE.PPReturns a standard Tcl completion code.  If an error occurs, an errormessage is left in the interp's result.  The function dynamically loadsa binary code file into memory.  On a successfulload, the \fIhandlePtr\fR should be filled with a token for the dynamically loaded file, and the \fIunloadProcPtr\fR should befilled in with the address of a procedure.  The procedure will becalled with the given Tcl_LoadHandle as its only parameter when Tcl needs to unload the file..SH UNLOADFILEPROC	    .PPFunction to unload a previously successfully loaded file.  If load wasimplemented, then this should also be implemented, if there is anycleanup action required..PP.CStypedef void Tcl_FSUnloadFileProc(	Tcl_LoadHandle \fIloadHandle\fR);.CE.SH GETCWDPROC     .PPFunction to process a \fBTcl_FSGetCwd()\fR call.  Most filesystems need notimplement this.  It will usually only be called once, if 'getcwd' iscalled before 'chdir'.  May be NULL..PP.CStypedef Tcl_Obj* Tcl_FSGetCwdProc(	Tcl_Interp *\fIinterp\fR);.CE.PPIf the filesystem supports a native notion of a current workingdirectory (which might perhaps change independent of Tcl), thisfunction should return that cwd as the result, or NULL if the currentdirectory could not be determined (e.g. the user does not haveappropriate permissions on the cwd directory).  If NULL is returned, anerror message is left in the interp's result..PP.SH CHDIRPROC	    .PPFunction to process a \fBTcl_FSChdir()\fR call.  If filesystems do notimplement this, it will be emulated by a series of directory accesschecks.  Otherwise, virtual filesystems which do implement it need onlyrespond with a positive return result if the dirName is a valid,accessible directory in their filesystem.  They need not remember theresult, since that will be automatically remembered for use by GetCwd.Real filesystems should carry out the correct action (i.e. call thecorrect system 'chdir' api)..PP.CStypedef int Tcl_FSChdirProc(	Tcl_Obj *\fIpathPtr\fR);.CE.PPThe \fBTcl_FSChdirProc\fR changes the applications current workingdirectory to the value specified in \fIpathPtr\fR. The function returns-1 on error or 0 on success..SH KEYWORDSstat access filesystem vfs

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?