1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Castle Game Engine: CastleFilesUtils</title>
<meta name="generator" content="PasDoc 0.13.0">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
</head>
<body>
<table class="container"><tr><td class="navigation">
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
<h1 class="unit">Unit CastleFilesUtils</h1>
<table class="sections wide_list">
<tr>
<td><a class="section" href="#PasDoc-Description">Description</a></td><td><a class="section" href="#PasDoc-Uses">Uses</a></td><td><a class="section" href="#PasDoc-Classes">Classes, Interfaces, Objects and Records</a></td><td><a class="section" href="#PasDoc-FuncsProcs">Functions and Procedures</a></td><td>Types</td><td>Constants</td><td>Variables</td></tr></table>
<a name="PasDoc-Description"></a><h2 class="description">Description</h2>
<p>
Operations on files.
<p>Includes functions to help cross-platform programs to know where to read/write files: </p>
<ul class="compact_spacing">
<li><p><a class="normal" href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a> – user config files</p></li>
<li><p><a class="normal" href="CastleFilesUtils.html#ApplicationData">ApplicationData</a> – installed program's data files</p></li>
</ul>
<p>
<p>List of things to do / not to do if you want to write truly cross-platform program (that also handles URLs everywhere):
<p></p>
<ul class="paragraph_spacing">
<li><p>Never use things like ParamStr(0), or Lazarus Application.ExeName. If you really want the filename of your executable, we have <a class="normal" href="CastleFilesUtils.html#ExeName">CastleFilesUtils.ExeName</a>, but this also should not be depended on (it may raise exception on some OSes).
<p>If you want a nice application name, use SysUtils.ApplicationName (our units use it too).
<p>If you want to load program data or save program config, it's best to use <a class="normal" href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a> and <a class="normal" href="CastleFilesUtils.html#ApplicationData">ApplicationData</a> for all paths.</p></li>
<li><p>Do not use standard FindFirst/FindNext.
<p>If you need to search a directory for some files, use <a class="normal" href="CastleFindFiles.html">CastleFindFiles</a> unit. But it only works for local filesystems (or Android assets filesystem), of course you cannot search for files within http URLs. So in general avoid such file searching.</p></li>
<li><p>Read / write all data using streams (TStream) descendants. Open and save these streams using our <a class="normal" href="CastleDownload.html">CastleDownload</a> unit.</p></li>
</ul>
<p></p>
<a name="PasDoc-Uses"></a><h2 class="uses">Uses</h2>
<ul class="useslist"><li>BaseUnix</li><li>Unix</li><li>SysUtils</li><li><a href="CastleUtils.html">CastleUtils</a></li></ul><h2 class="overview">Overview</h2>
<a name="PasDoc-Classes"></a><h3 class="cio">Classes, Interfaces, Objects and Records</h3>
<table class="classestable wide_list">
<tr class="listheader">
<th class="itemname">Name</th>
<th class="itemdesc">Description</th>
</tr>
<tr class="list">
<td class="itemname">Class <a class="bold" href="CastleFilesUtils.EExeNameNotAvailable.html"><code>EExeNameNotAvailable</code></a></td>
<td class="itemdesc"> </td>
</tr>
</table>
<a name="PasDoc-FuncsProcs"></a><h3 class="summary">Functions and Procedures</h3>
<table class="summary wide_list">
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ExeName">ExeName</a></b>: string;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ProgramName">ProgramName</a></b>: string; deprecated;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#NormalFileExists">NormalFileExists</a></b>(const fileName: string): boolean; deprecated;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#UserConfigPath">UserConfigPath</a></b>: string; deprecated;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#UserConfigFile">UserConfigFile</a></b>(const Extension: string): string; deprecated;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ProgramDataPath">ProgramDataPath</a></b>: string; deprecated;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a></b>(const Path: string): string;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ApplicationData">ApplicationData</a></b>(const Path: string): string;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#HomePath">HomePath</a></b>: string;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ExpandHomePath">ExpandHomePath</a></b>(const FileName: string): string;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a href="CastleFilesUtils.html#CheckDeleteFile">CheckDeleteFile</a></b>(const FileName: string; const Warn: boolean = false);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a href="CastleFilesUtils.html#CheckRemoveDir">CheckRemoveDir</a></b>(const DirFileName: string);</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a href="CastleFilesUtils.html#CheckForceDirectories">CheckForceDirectories</a></b>(const Dir: string);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>procedure <b><a href="CastleFilesUtils.html#CheckRenameFile">CheckRenameFile</a></b>(const Source, Dest: string);</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>procedure <b><a href="CastleFilesUtils.html#RemoveNonEmptyDir">RemoveNonEmptyDir</a></b>(const DirName: string);</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#FileNameAutoInc">FileNameAutoInc</a></b>(const FileNamePattern: string): string;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#FnameAutoInc">FnameAutoInc</a></b>(const FileNamePattern: string): string; deprecated;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#ParentPath">ParentPath</a></b>(DirName: string; DoExpandDirName: boolean = true): string;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#CombinePaths">CombinePaths</a></b>(BasePath, RelPath: string): string; deprecated;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>Function <b><a href="CastleFilesUtils.html#PathFileSearch">PathFileSearch</a></b>(Const Name : String; ImplicitCurrentDir : Boolean = True) : String;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#FindExe">FindExe</a></b>(const ExeName: string): string;</code></td>
</tr>
<tr class="list2">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#GetTempFileNameCheck">GetTempFileNameCheck</a></b>: string;</code></td>
</tr>
<tr class="list">
<td class="itemcode"><code>function <b><a href="CastleFilesUtils.html#GetTempFileNamePrefix">GetTempFileNamePrefix</a></b>: string;</code></td>
</tr>
</table>
<h2 class="description">Description</h2>
<h3 class="detail">Functions and Procedures</h3>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ExeName"></a><code>function <b>ExeName</b>: string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Full (absolute) filename to executable file of this program. If it's impossible to obtain, raises exception <a class="normal" href="CastleFilesUtils.EExeNameNotAvailable.html">EExeNameNotAvailable</a>.
<p>Under Windows this is simply ParamStr(0) (and it never raises exception), but under other OSes it's not so simple to obtain (although it's important to note that usually programs under UNIX should not need this, actually).
<p>Internal implementation notes:
<p>Under UNIXes other than Linux I don't know how to obtain this, so e.g. under FreeBSD this will always raise an exception. Under Linux I'm trying to read file /proc/getpid()/exe, this should work under most Linuxes as long as user compiled Linux kernel with /proc support. So under Linux this may work, but still you should be always prepared that it may raise <a class="normal" href="CastleFilesUtils.EExeNameNotAvailable.html">EExeNameNotAvailable</a>.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ProgramName"></a><code>function <b>ProgramName</b>: string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
The name of our program.
<p> Deprecated, this is equivalent to ApplicationName, and you should just call ApplicationName directly in new code. ApplicationName is included in standard FPC SysUtils unit, had good default and is easily configurable by callback OnGetApplicationName. See <a href="http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigdir.html">http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigdir.html</a> .
<p>This is suitable to show to user. It should also indicate how to run the program, usually it should be the basename of the executable (although we do not depend on it technically). It is used to derive config and data paths for our program, see <a class="normal" href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a> and <a class="normal" href="CastleFilesUtils.html#ApplicationData">ApplicationData</a>.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="NormalFileExists"></a><code>function <b>NormalFileExists</b>(const fileName: string): boolean; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Returns true if file exists and is a normal file. Detects and returns <code>False</code> for special Windows files like 'con', 'c:\con', 'c:\somedir\con' etc. ('con' is a special device name). For all other files (and other OSes) this function returns the same as FileExists.
<p> Deprecated, since we use URLs everywhere, use <a class="normal" href="CastleURIUtils.html#URIFileExists">URIFileExists</a> to check does file exist.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="UserConfigPath"></a><code>function <b>UserConfigPath</b>: string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Path to store user configuration files. This is some directory that should be writeable and that is a standard directory under this OS to put user config files. Always returns absolute (not relative) path. Result contains trailing PathDelim.
<p> Deprecated, use <a class="normal" href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a> instead.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="UserConfigFile"></a><code>function <b>UserConfigFile</b>(const Extension: string): string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Filename to store user configuration. Always returns absolute (not relative) path.
<p>Returns filename that: </p>
<ul class="compact_spacing">
<li><p>is inside <a class="normal" href="CastleFilesUtils.html#UserConfigPath">UserConfigPath</a></p></li>
<li><p>depends on OnGetApplicationName</p></li>
<li><p>has given Extension. Extension should contain beginning dot. E.g. FExtension = '.ini'. This way you can pass FExtension = '' to have a filename without extension.</p></li>
</ul>
<p>
<p> Deprecated, use <a class="normal" href="CastleFilesUtils.html#ApplicationConfig">ApplicationConfig</a>(ApplicationName + Extension) instead.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ProgramDataPath"></a><code>function <b>ProgramDataPath</b>: string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Path to access installed data files. Returns absolute path, containing trailing PathDelim.
<p> Deprecated, use <a class="normal" href="CastleFilesUtils.html#ApplicationData">ApplicationData</a> instead.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ApplicationConfig"></a><code>function <b>ApplicationConfig</b>(const Path: string): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
URL where we should read and write configuration files. This always returns a <code><a href="file://">file://</a>...</code> URL, which is comfortable since our engine operates on URLs most of the time.
<p>Given Path specifies a name of the file (with possible subdirectories) under the user config directory. The Path is a relative URL, so you should always use slashes (regardless of OS), and you can escape characters by %xx. We make sure that the directory (including the subdirectories you specify in Path) exists, creating it if necessary. But we do not create the file. We should have permissions to write inside the given directory (although, as always on multi-process OS, the only 100% way to know if you can write there is to actually try it).
<p>This uses FPC GetAppConfigDir under the hood. Which in turn looks at OnGetApplicationName, and may use OS-specific algorithm to find good config directory, see <a href="http://www.freepascal.org/docs-html/rtl/sysutils/ongetapplicationname.html">http://www.freepascal.org/docs-html/rtl/sysutils/ongetapplicationname.html</a> . On UNIX this follows XDG Base Directory Specification, see <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html</a> (simplifying: looks inside ˜/.config/<application-name>/).</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ApplicationData"></a><code>function <b>ApplicationData</b>(const Path: string): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
URL from which we should read data files. This returns URL, which is comfortable since our engine operates on URLs everywhere. On normal desktops systems this will return a <code><a href="file://">file://</a>...</code> URL. On Android, it will return an URL indicating assets (files packages together inside Android apk) starting with <code>assets:/...</code>.
<p>Given Path specifies a path under the data directory, with possible subdirectories, with possible filename at the end. The Path is a relative URL, so you should always use slashes (regardless of OS), and you can escape characters by %xx. You can use Path = '' to get the URL to whole data directory. Note that files there may be read-only, do not try to write there.
<p>The algorithm to find base data directory (with respect to which Path is resolved) is OS-specific. It looks at ApplicationName, and searches a couple of common locations, using the first location that exists. We try to look first inside user-specific directories, then inside system-wide directories, and as a fallback we use current exe directory (under Windows) or current working directory (under other OSes).
<p>The exact details how we currently look for data directory (specified here so that you know how to install your program):
<p></p>
<dl class="paragraph_spacing">
<dt>Windows</dt>
<dd><p></p>
<ol class="paragraph_spacing">
<li value="1"><p><code>data</code> subdirectory inside our exe directory, if exists.</p></li>
<li value="2"><p>Last resort fallback: just our exe directory.</p></li>
</ol>
<p></p></dd>
<dt>Mac OS X</dt>
<dd><p></p>
<ol class="paragraph_spacing">
<li value="1"><p><code>Contents/Resources/data</code> subdirectory inside our bundle directory, if we are inside a bundle and such subdirectory exists.</p></li>
<li value="2"><p>Otherwise, algorithm on Mac OS X follows algorithm on other Unixes, see below.</p></li>
</ol>
<p></p></dd>
<dt>Android</dt>
<dd><p></p>
<ol class="paragraph_spacing">
<li value="1"><p>We always return <code>assets:/</code> directory, to read assets from the apk.</p></li>
</ol>
<p></p></dd>
<dt>Unix (Linux, Mac OS X, FreeBSD etc.)</dt>
<dd><p></p>
<ol class="paragraph_spacing">
<li value="1"><p><code>˜/.local/share/</code> + ApplicationName. This is nice user-specific data directory, following the default dictated by <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html</a> . If such directory exists, it is returned.
<p>This is checked first, to allow user to always override system-wide installation of a program with his own installation. E.g. consider the situation when an old version of a program is installed system-wide in /usr/local/share/my_program/, but some user (with no access to root account) wants to install a newer version of it for himself. Now he can do it, because ˜/.local/share/my_program/ is checked 1st, before system-wide paths.</p></li>
<li value="2"><p><code><a class="normal" href="CastleFilesUtils.html#HomePath">HomePath</a> +'.' +ApplicationName+'.data/'</code>. If such directory exists, it is returned.
<p>This is another location of user-specific data directory, deprecated now. You should instead use more standard <code>˜/.local/share/</code> + ApplicationName.</p></li>
<li value="3"><p><code>'/usr/local/share/' +ApplicationName+ '/'</code>. If such directory exists, it is returned.
<p>This is suitable for system-wide installations without package manager.</p></li>
<li value="4"><p><code>'/usr/share/' +ApplicationName+ '/'</code>. If such directory exists, it is returned.
<p>This is suitable for system-wide installations with package manager.</p></li>
<li value="5"><p><code>data</code> subdirectory of current directory, if exists. Using <code>data</code> subdirectory is usually comfortable, it allows you to separate code from data better.</p></li>
<li value="6"><p>As a last resort, we just return the current directory. So you can just place data files inside the current directory, and if user will run your game from it's own directory — it will work without any fuss.</p></li>
</ol>
<p> </p></dd>
</dl>
<p></p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="HomePath"></a><code>function <b>HomePath</b>: string;</code></td>
</tr>
<tr><td colspan="1">
<p>
User's home directory, with trailing PathDelim.
<p>Taken from environment variable $HOME, unless it's empty or unset, in which case we take this from Unix user database by real uid. This is what bash does (more-or-less, when home directory does not exist strange things happen), that's what programs should do according to `info libc' and Kambi preferences.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ExpandHomePath"></a><code>function <b>ExpandHomePath</b>(const FileName: string): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Expand tilde (˜) in path, just like shell. Expands ˜ to <a class="normal" href="CastleUtils.html#ExclPathDelim">ExclPathDelim</a>(<a class="normal" href="CastleFilesUtils.html#HomePath">HomePath</a>) under UNIX. Under Windows, does nothing.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckDeleteFile"></a><code>procedure <b>CheckDeleteFile</b>(const FileName: string; const Warn: boolean = false);</code></td>
</tr>
<tr><td colspan="1">
<p>
Call SysUtils.DeleteFile and check result. When Warn = <code>False</code> (default) raises an exception on failure, otherwise (when Warn = <code>True</code>) makes only <a class="normal" href="CastleWarnings.html#OnWarning">OnWarning</a> on failure. </p>
<h6 class="description_section">Exceptions raised</h6>
<dl class="exceptions_raised">
<dt><code>Exception</code></dt>
<dd>If delete failed, and Warn = <code>False</code>.</dd>
</dl>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckRemoveDir"></a><code>procedure <b>CheckRemoveDir</b>(const DirFileName: string);</code></td>
</tr>
<tr><td colspan="1">
<p>
Call RemoveDir and check result. </p>
<h6 class="description_section">Exceptions raised</h6>
<dl class="exceptions_raised">
<dt><code>Exception</code></dt>
<dd>If delete failed.</dd>
</dl>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckForceDirectories"></a><code>procedure <b>CheckForceDirectories</b>(const Dir: string);</code></td>
</tr>
<tr><td colspan="1">
<p>
Make sure directory exists, eventually creating it, recursively, checking result.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CheckRenameFile"></a><code>procedure <b>CheckRenameFile</b>(const Source, Dest: string);</code></td>
</tr>
<tr><td colspan="1">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="RemoveNonEmptyDir"></a><code>procedure <b>RemoveNonEmptyDir</b>(const DirName: string);</code></td>
</tr>
<tr><td colspan="1">
<p>
Remove the directory DirName, <i>recursively, unconditionally, with all the files and subdirectories inside</i>. DirName may but doesn't have to end with PathDelim.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="FileNameAutoInc"></a><code>function <b>FileNameAutoInc</b>(const FileNamePattern: string): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Substitute %d in given filename pattern with successive numbers, until the filename doesn't exist.
<p>The idea is to start with number = 0 and do <code>Format(FileNamePattern, [number])</code>, until you find non-existing filename. Example filename pattern is <code>screenshot_%d.png</code>, by saving to this filename you're relatively sure that each save goes to a new file. Since we use standard <code>Format</code> function, you can use e.g. <code>screenshot_%04d.png</code> to have a number inside the filename always at least 4 digits long.
<p>Note that it's possible on every OS that some other program, or a second copy of your own program, will write to the filename between <code>FileNameAutoInc</code> determined it doesn't exist and you opened the file. So using this cannot guarantee that you really always write to a new file (use proper file open modes for this).</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="FnameAutoInc"></a><code>function <b>FnameAutoInc</b>(const FileNamePattern: string): string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Deprecated name for <a class="normal" href="CastleFilesUtils.html#FileNameAutoInc">FileNameAutoInc</a>. </p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="ParentPath"></a><code>function <b>ParentPath</b>(DirName: string; DoExpandDirName: boolean = true): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Parent directory name.
<p>Given DirName may be absolute or relative. Given DirName may but doesn't have to include trailing PathDelim. Result is always absolute filename, and contains trailing PathDelim.
<p>Returns the same DirName if there's no parent directory.
<p>When DoExpandDirName = false then it is assumed that DirName already is absolute path. Then this function is pure string-operation (no actual reading of any filesystem info), so it works faster and DirName does not need to exist.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="CombinePaths"></a><code>function <b>CombinePaths</b>(BasePath, RelPath: string): string; deprecated;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p><p>
Combines BasePath with RelPath into complete path. BasePath MUST be an absolute path, on Windows it must contain at least drive specifier (like 'c:'), on Unix it must begin with "/". RelPath can be relative and can be absolute. If RelPath is absolute, result is RelPath. Else the result is an absolute path calculated by combining RelPath with BasePath.
<p> This is deprecated, you should instead operate on URLs and combine them using CastleURIUtils.Combines.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="PathFileSearch"></a><code>Function <b>PathFileSearch</b>(Const Name : String; ImplicitCurrentDir : Boolean = True) : String;</code></td>
</tr>
<tr><td colspan="1">
<p>
Search a file on $PATH. Works with double quotes around components of path list, avoiding this bug: <a href="http://bugs.freepascal.org/view.php?id=19279">http://bugs.freepascal.org/view.php?id=19279</a>. See <a href="http://www.freepascal.org/docs-html/rtl/sysutils/filesearch.html">http://www.freepascal.org/docs-html/rtl/sysutils/filesearch.html</a> for original FileSearch docs.
<p>In FPC >= 2.5.1, you should instead use just ExeSearch(Name). It also will use $PATH and avoid double quotes problems on Windows. See <a href="http://bugs.freepascal.org/view.php?id=19282">http://bugs.freepascal.org/view.php?id=19282</a> and fix on <a href="http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&revision=17717">http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&revision=17717</a> .</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="FindExe"></a><code>function <b>FindExe</b>(const ExeName: string): string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Find program on $PATH. Automatically adds <a class="normal" href="CastleUtils.html#ExeExtension">ExeExtension</a>, so don't add it yourself. Searches in $PATH (and, if OS does this, in current directory — this is standard on Windows but not on Unix). Returns '' (if not found) or absolute filename.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="GetTempFileNameCheck"></a><code>function <b>GetTempFileNameCheck</b>: string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Get temporary filename, suitable for ApplicationName, checking that it doesn't exist.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><a name="GetTempFileNamePrefix"></a><code>function <b>GetTempFileNamePrefix</b>: string;</code></td>
</tr>
<tr><td colspan="1">
<p>
Return a prefix (beginning of an absolute filename) to save a series of temporary files.</p>
</td></tr>
</table>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://michalis.ii.uni.wroc.pl/piwik-castle-engine/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "1"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
<noscript>
<!-- Piwik Image Tracker -->
<img src="http://michalis.ii.uni.wroc.pl/piwik-castle-engine/piwik.php?idsite=1&rec=1" style="border:0" alt="" />
<!-- End Piwik -->
</noscript>
<hr noshade size="1"><span class="appinfo"><em>Generated by <a href="http://pasdoc.sourceforge.net/">PasDoc 0.13.0</a> on 2015-06-15 04:43:09</em>
</span>
</td></tr></table></body></html>
|