📄 xfiles.txt
字号:
unit xFiles;
TDirEnumProc = procedure (sFileName: string; var bContinue: Boolean) ;//of object;
TFileAcessMode = (famCreate,famModify,famAccess);
//路径中,添加路径尾部的"\"
function AddSlash(const s: string): string;
//路径中,删除路径尾部的"\"
function DelSlash(const s: string): string;
//将文件或盘区大小转换为字符串。
function GetSizeString(Value: Longint): String;
//检测文件是否正在被使用。
function IsFileInUse(fName : string ) : boolean;
//取得文件最近访问时间,可根据Mode,取得创建、修改、访问时间。
function GetFileLastAccessTime(sFileName:string;Mode : TFileAcessMode = famModify):TDateTime;
//输入任意文件名,返回主文件路径
//如'c:\windows\calc.exe',返回c:\windows\calc
function GetMainFilePath(const sFilePath: string): string;
//输入任意文件名,返回主文件名
//如'c:\windows\calc.exe',返回calc
function GetMainFileName(const sFilePath: String): String;
//返回长文件名
function FileLongName(const sFilePath: String): String;
//返回短文件名
function FileShortName(const sFilePath: String): String;
//返回文件类型名
function FileTypeName(const sFilePath: String): String;
//取得文件大小
function FileSizeEx(const sFileName: string): DWORD;
//文件复制,如目标存在,返回False
function FileCopy(const SourceFile, TargetFile : string):Boolean;
//文件复制,使用自定义函数。
function FileCopyEx(const SourceFile, TargetFile: String): Boolean;
//文件碎纸机,将文件填入原字节大小的乱码,然后删除,使信息永远不能恢复。
function FileShredder(const sFilePath: String): Boolean;
//取得相对路径,即将FilePath中的BasePath部分去掉,如:
//'c:\winnt','c:\winnt\system32\kernel32.dll'
//返回'system32\kernel32.dll'
function DirRelative(BasePath, FilePath: string): string;
//析去路径中的%,如%Windows%Explorer.exe,返回Explorer.exe
function DirStripSpecifier(const Path: string): string;
//取得父目录,若是最高层,返回目录本身,支持UNC命名,如
//c:\windows\system -> c:\windows
//\\zebra\c\windows\ -> \\zebra\c\
//\\zebra\c\ -> \\zebra\c\
//c:\ -> c:\
function DirParent(Path: string): string;
//目录比较,无论路径大小写及路径格式
function DirCompare(const Path1, Path2: string): Boolean;
//目录文件枚举,对sDir目录下的每一文件或目录调用DirEnumProc过程,
//sMask:指定一类文件,如'*.txt';
//Attr :指定目录文件属性;faReadOnly,faHidden,faSysFile,faVolumeID,faDirectory,faArchive,faAnyFile
procedure DirEnum(sDir, sMask: string; Attr: Integer; DirEnumProc: TDirEnumProc);
//目录清除子过程,被DirClean调用
procedure DirCleanProc(sFileName: string; var bContinue: Boolean);
//目录清除,将目录下的所有子目录及文件清除
procedure DirClean(sDir: string);
//目录复制,将sDir下的所有文件复制到tDir,若bRecursive = True则包括子目录复制
procedure DirCopy(sDir, tDir: string; bRecursive: Boolean =True);
//取得盘符,sPath将成为无盘符的路径
//如c:\windows\system,返回c ,sPath=windows\system
//如 windows\system,返回windows,sPath=system
//如 \windows\system,返回空 ,sPath=windows\system
function GetRootDir(var sPath: string): string;
//取得指定路径最下层路径,sPath成为返回路径的父路径
//如c:\windows\system,返回system ,sPath=c:\windows\
//如 \system,返回system ,sPath=空
//如 system,返回system ,sPath=空
function GetLeafDir(var sPath: string): string;
//取得系统目录路径,追加\
function GetSystemDir: string;
//取得Windows目录路径,追加\
function GetWindowsDir: string;
//取得Windows所在目录路径的文件名
function GetWindowsDirFile(const sFileName: string): string;
//取得系统所在目录路径的文件名
function GetSystemDirFile(const sFileName: string): string;
//取得系统所在驱动器目录路径的文件名
function GetSystemDriveFile(const sFileName: string): string;
//取得唯一文件名
function GetUniqFile(const Path: string; sFileName: string): string;
//取得临时文件名
function GetTempFile(sPrefix: string = 'TEMP'): string;
//处理文件内图标的指示字符串,若要指向FOO.DLL的第2个图标,会以"FOO.DLL,1"
//表示(编号从零开始)。TruncateTrailNumber将逗号及逗号以后的编号去掉。形成:
//"FOO.DLL"
function TruncateTrailNumber(var S: string): Integer;
//TruncateTrailIfNotDLL判断此文件是否为EXE、DLL、ICL等可能带有图标的文件,
//若是,才保留图标编号。
function TruncateTrailIfNotDLL(S: string): string;
//判断包含图标的文件是否存在。如:"FOO.DLL,1",检查FOO.DLL是否存在。
function FileExistsAfterTruncate(Filename: string): Boolean;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -