LazFileUtils/zh CN: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: LazFileUtils/zh CN
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## 比 较文件名称 | |
| 2 | + | ||
| 3 | + | ``` pascal | |
| 4 | + | function CompareFilenames(const Filename1, Filename2: string): integer; overload; | |
| 5 | + | ||
| 6 | + | function CompareFilenamesIgnoreCase(const Filename1, Filename2: string): integer; | |
| 7 | + | ||
| 8 | + | function CompareFileExt(const Filename, Ext: string; CaseSensitive: boolean): integer; overload; | |
| 9 | + | ||
| 10 | + | function CompareFileExt(const Filename, Ext: string): integer; overload; | |
| 11 | + | ||
| 12 | + | function CompareFilenameStarts(const Filename1, Filename2: string): integer; | |
| 13 | + | ||
| 14 | + | function CompareFilenames(Filename1: PChar; Len1: integer; Filename2: PChar; Len2: integer): integer; overload; | |
| 15 | + | ||
| 16 | + | function CompareFilenamesP(Filename1, Filename2: PChar; IgnoreCase: boolean = false): integer; // false = 使用默认 | |
| 17 | + | ``` | |
| 18 | + | ||
| 19 | + | ## 目录 | |
| 20 | + | ||
| 21 | + | ``` pascal | |
| 22 | + | function DirPathExists(DirectoryName: string): boolean; | |
| 23 | + | ||
| 24 | + | function DirectoryIsWritable(const DirectoryName: string): boolean; | |
| 25 | + | ``` | |
| 26 | + | ||
| 27 | + | ## 文件名称 | |
| 28 | + | ||
| 29 | + | ``` pascal | |
| 30 | + | function ExtractFileNameOnly(const AFilename: string): string; | |
| 31 | + | ||
| 32 | + | function FilenameIsAbsolute(const TheFilename: string):boolean; | |
| 33 | + | ||
| 34 | + | function FilenameIsWinAbsolute(const TheFilename: string):boolean; | |
| 35 | + | ||
| 36 | + | function FilenameIsUnixAbsolute(const TheFilename: string):boolean; | |
| 37 | + | ||
| 38 | + | function ForceDirectory(DirectoryName: string): boolean; | |
| 39 | + | ||
| 40 | + | procedure CheckIfFileIsExecutable(const AFilename: string); | |
| 41 | + | ||
| 42 | + | procedure CheckIfFileIsSymlink(const AFilename: string); | |
| 43 | + | ||
| 44 | + | function FileIsExecutable(const AFilename: string): boolean; | |
| 45 | + | ||
| 46 | + | function FileIsSymlink(const AFilename: string): boolean; | |
| 47 | + | ||
| 48 | + | function FileIsHardLink(const AFilename: string): boolean; | |
| 49 | + | ||
| 50 | + | function FileIsReadable(const AFilename: string): boolean; | |
| 51 | + | ||
| 52 | + | function FileIsWritable(const AFilename: string): boolean; | |
| 53 | + | ||
| 54 | + | function FileIsText(const AFilename: string): boolean; | |
| 55 | + | ||
| 56 | + | function FileIsText(const AFilename: string; out FileReadable: boolean): boolean; | |
| 57 | + | ||
| 58 | + | function FilenameIsTrimmed(const TheFilename: string): boolean; | |
| 59 | + | ||
| 60 | + | function FilenameIsTrimmed(StartPos: PChar; NameLen: integer): boolean; | |
| 61 | + | ||
| 62 | + | function TrimFilename(const AFilename: string): string; | |
| 63 | + | ||
| 64 | + | function ResolveDots(const AFilename: string): string; | |
| 65 | + | ||
| 66 | + | Procedure ForcePathDelims(Var FileName: string); | |
| 67 | + | ||
| 68 | + | Function GetForcedPathDelims(Const FileName: string): String; | |
| 69 | + | ||
| 70 | + | function CleanAndExpandFilename(const Filename: string): string; //空的字符串返回当前目录 | |
| 71 | + | ||
| 72 | + | function CleanAndExpandDirectory(const Filename: string): string; //空的字符串返回当前目录 | |
| 73 | + | ||
| 74 | + | function TrimAndExpandFilename(const Filename: string; const BaseDir: string = ''): string; //空的字符串返回空的字符串 | |
| 75 | + | ||
| 76 | + | function TrimAndExpandDirectory(const Filename: string; const BaseDir: string = ''): string; //空的字符串返回空的字符串 | |
| 77 | + | ||
| 78 | + | function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean; AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean; | |
| 79 | + | ||
| 80 | + | function CreateRelativePath(const Filename, BaseDirectory: string;UsePointDirectory: boolean = false; AlwaysRequireSharedBaseFolder: Boolean = True): string; | |
| 81 | + | ||
| 82 | + | function FileIsInPath(const Filename, Path: string): boolean; | |
| 83 | + | ||
| 84 | + | function AppendPathDelim(const Path: string): string; | |
| 85 | + | ||
| 86 | + | function ChompPathDelim(const Path: string): string; | |
| 87 | + | ``` | |
| 88 | + | ||
| 89 | + | ## 搜索路径 | |
| 90 | + | ||
| 91 | + | ``` pascal | |
| 92 | + | function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string; | |
| 93 | + | ||
| 94 | + | function CreateRelativeSearchPath(const SearchPath, BaseDirectory: string): string; | |
| 95 | + | ||
| 96 | + | function MinimizeSearchPath(const SearchPath: string): string; | |
| 97 | + | ||
| 98 | + | function FindPathInSearchPath(APath: PChar; APathLen: integer; SearchPath: PChar; SearchPathLen: integer): PChar; overload; | |
| 99 | + | ||
| 100 | + | function FindPathInSearchPath(const APath, SearchPath: string): integer; overload; | |
| 101 | + | ``` | |
| 102 | + | ||
| 103 | + | ## 文件操作 | |
| 104 | + | ||
| 105 | + | ``` pascal | |
| 106 | + | function FileExistsUTF8(const Filename: string): boolean; | |
| 107 | + | ||
| 108 | + | function FileAgeUTF8(const FileName: string): Longint; | |
| 109 | + | ||
| 110 | + | function DirectoryExistsUTF8(const Directory: string): Boolean; | |
| 111 | + | ||
| 112 | + | function ExpandFileNameUTF8(const FileName: string; {const} BaseDir: string = ''): string; | |
| 113 | + | ||
| 114 | + | function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint; | |
| 115 | + | ||
| 116 | + | function FindNextUTF8(var Rslt: TSearchRec): Longint; | |
| 117 | + | ||
| 118 | + | procedure FindCloseUTF8(var F: TSearchrec); inline; | |
| 119 | + | ``` | |
| 120 | + | ||
| 121 | + | ## 文件属性 | |
| 122 | + | ||
| 123 | + | ``` pascal | |
| 124 | + | function FileSetDateUTF8(const FileName: String; Age: Longint): Longint; | |
| 125 | + | ||
| 126 | + | function FileGetAttrUTF8(const FileName: String): Longint; | |
| 127 | + | ||
| 128 | + | function FileSetAttrUTF8(const Filename: String; Attr: longint): Longint; | |
| 129 | + | ||
| 130 | + | function DeleteFileUTF8(const FileName: String): Boolean; | |
| 131 | + | ||
| 132 | + | function RenameFileUTF8(const OldName, NewName: String): Boolean; | |
| 133 | + | ||
| 134 | + | function FileSearchUTF8(const Name, DirList : String; ImplicitCurrentDir : Boolean = True): String; | |
| 135 | + | ||
| 136 | + | function FileIsReadOnlyUTF8(const FileName: String): Boolean; | |
| 137 | + | ``` | |
| 138 | + | ||
| 139 | + | ## 获取、设置、创建、移除或强制移动目录 | |
| 140 | + | ||
| 141 | + | ``` pascal | |
| 142 | + | function GetCurrentDirUTF8: String; | |
| 143 | + | ||
| 144 | + | function SetCurrentDirUTF8(const NewDir: String): Boolean; | |
| 145 | + | ||
| 146 | + | function CreateDirUTF8(const NewDir: String): Boolean; | |
| 147 | + | ||
| 148 | + | function RemoveDirUTF8(const Dir: String): Boolean; | |
| 149 | + | ||
| 150 | + | function ForceDirectoriesUTF8(const Dir: string): Boolean; | |
| 151 | + | ``` | |
| 152 | + | ||
| 153 | + | ## 文件打开或创建 | |
| 154 | + | ||
| 155 | + | ``` pascal | |
| 156 | + | function FileOpenUTF8(Const FileName : string; Mode : Integer) : THandle; | |
| 157 | + | ||
| 158 | + | function FileCreateUTF8(Const FileName : string) : THandle; overload; | |
| 159 | + | ||
| 160 | + | function FileCreateUTF8(Const FileName : string; Rights: Cardinal) : THandle; overload; | |
| 161 | + | ||
| 162 | + | Function FileCreateUtf8(Const FileName : String; ShareMode : Integer; Rights : Cardinal) : THandle; overload; | |
| 163 | + | ``` | |
| 164 | + | ||
| 165 | + | ## 文件属性或大小 | |
| 166 | + | ||
| 167 | + | ``` pascal | |
| 168 | + | function FileSizeUtf8(const Filename: string): int64; | |
| 169 | + | ||
| 170 | + | function GetFileDescription(const AFilename: string): string; | |
| 171 | + | ||
| 172 | + | function ReadAllLinks(const Filename: string; {%H-}ExceptionOnError: boolean): string; //如果一个链接是破损的,返回'' | |
| 173 | + | ||
| 174 | + | function TryReadAllLinks(const Filename: string): string; //如果一个链接是破损的,返回文件名称 | |
| 175 | + | ||
| 176 | + | function GetShellLinkTarget(const FileName: string): string; | |
| 177 | + | ``` | |
| 178 | + | ||
| 179 | + | ## 针对调试期间 | |
| 180 | + | ||
| 181 | + | ``` pascal | |
| 182 | + | function DbgSFileAttr(Attr: LongInt): String; | |
| 183 | + | ||
| 184 | + | TPhysicalFilenameOnError = (pfeException,pfeEmpty,pfeOriginal); //获取FileNameOnError | |
| 185 | + | ``` | |
| 186 | + | ||
| 187 | + | ## 获取文件名称 | |
| 188 | + | ||
| 189 | + | ``` pascal | |
| 190 | + | // Getting file name except for Unix | |
| 191 | + | function GetPhysicalFilename(const Filename: string; OnError: TPhysicalFilenameOnError): string; | |
| 192 | + | ||
| 193 | + | // for Unix | |
| 194 | + | function GetUnixPhysicalFilename(const Filename: string; ExceptionOnError: boolean): string; //如果一个链接是破损的,返回'' | |
| 195 | + | ``` | |
| 196 | + | ||
| 197 | + | ## 获取路径 | |
| 198 | + | ||
| 199 | + | ``` pascal | |
| 200 | + | function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string; | |
| 201 | + | ||
| 202 | + | function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false; CreateDir: boolean = false): string; | |
| 203 | + | ||
| 204 | + | function GetTempFileNameUTF8(const Dir, Prefix: String): String; | |
| 205 | + | ||
| 206 | + | // UNC路径 | |
| 207 | + | function IsUNCPath(const {%H-}Path: String): Boolean; | |
| 208 | + | ||
| 209 | + | function ExtractUNCVolume(const {%H-}Path: String): String; | |
| 210 | + | ||
| 211 | + | function ExtractFileRoot(FileName: String): String; | |
| 212 | + | ||
| 213 | + | // Darwin (macOS)路径 | |
| 214 | + | function GetDarwinSystemFilename(Filename: string): string; | |
| 215 | + | ||
| 216 | + | function GetDarwinNormalizedFilename(Filename: string; nForm:Integer=2): string; | |
| 217 | + | ||
| 218 | + | // Windows路径 | |
| 219 | + | function SHGetFolderPathUTF8(ID : Integer) : String; | |
| 220 | + | ``` | |
| 221 | + | ||
| 222 | + | ## 命令行参数 | |
| 223 | + | ||
| 224 | + | ``` pascal | |
| 225 | + | procedure SplitCmdLineParams(const Params: string; ParamList: TStrings; ReadBackslash: boolean = false); | |
| 226 | + | ||
| 227 | + | function StrToCmdLineParam(const Param: string): string; | |
| 228 | + | ||
| 229 | + | function MergeCmdLineParams(ParamList: TStrings): string; | |
| 230 | + | ``` | |
| 231 | + | ||
| 232 | + | ## 高速缓冲存储器 | |
| 233 | + | ||
| 234 | + | ``` pascal | |
| 235 | + | TInvalidateFileStateCacheEvent = procedure(const Filename: string); var OnInvalidateFileStateCache: TInvalidateFileStateCacheEvent = nil; | |
| 236 | + | ||
| 237 | + | procedure InvalidateFileStateCache(const Filename: string = ''); inline; | |
| 238 | + | ``` | |
| 239 | + | ||
| 240 | + | ## 参考 | |
| 241 | + | ||
| 242 | + | - [针对LazFileUtils单元的参考](https://lazarus-ccr.sourceforge.io/docs/lazutils/lazfileutils/)。 | |
| 243 | + | ||
| 244 | + | # 贡献者和更改 | |
| 245 | + | ||
| 246 | + | - 简体中文版本由 robsean 于 2022-05-07 创建 | |
| 247 | + | ||
| 248 | + | --- | |
| 249 | + | *From the Free Pascal wiki, page "LazFileUtils/zh CN", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 250 | + | Category: LazUtils | |
| 251 | + | Category: Lazarus |
