os.html 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/os</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/os</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  51. </li>
  52. <li>
  53. <details open>
  54. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  55. <ul class="simple simple-toc-section">
  56. <li><a class="reference" href="#DeviceId" title="DeviceId = Dev">DeviceId</a></li>
  57. <li><a class="reference" href="#FileId" title="FileId = Ino">FileId</a></li>
  58. <li><a class="reference" href="#FileInfo" title="FileInfo = object
  59. id*: tuple[device: DeviceId, file: FileId] ## Device and file id.
  60. kind*: PathComponent ## Kind of file object - directory, symlink, etc.
  61. size*: BiggestInt ## Size of file.
  62. permissions*: set[FilePermission] ## File permissions
  63. linkCount*: BiggestInt ## Number of hard links the file object has.
  64. lastAccessTime*: times.Time ## Time file was last accessed.
  65. lastWriteTime*: times.Time ## Time file was last modified/written to.
  66. creationTime*: times.Time ## Time file was created. Not supported on all systems!
  67. blockSize*: int ## Preferred I/O block size for this object.
  68. ## In some filesystems, this may vary from file to file.
  69. isSpecial*: bool ## Is file special? (on Unix some &quot;files&quot;
  70. ## can be special=non-regular like FIFOs,
  71. ## devices); for directories `isSpecial`
  72. ## is always `false`, for symlinks it is
  73. ## the same as for the link's target.">FileInfo</a></li>
  74. </ul>
  75. </details>
  76. </li>
  77. <li>
  78. <details open>
  79. <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
  80. <ul class="simple simple-toc-section">
  81. <li><a class="reference" href="#ExeExts" title="ExeExts = [&quot;&quot;]">ExeExts</a></li>
  82. <li><a class="reference" href="#invalidFilenameChars" title="invalidFilenameChars = {'/', '\\', ':', '*', '?', '\&quot;', '&lt;', '&gt;', '|', '^',
  83. '\x00'}">invalidFilenameChars</a></li>
  84. <li><a class="reference" href="#invalidFilenames" title="invalidFilenames = [&quot;CON&quot;, &quot;PRN&quot;, &quot;AUX&quot;, &quot;NUL&quot;, &quot;COM0&quot;, &quot;COM1&quot;, &quot;COM2&quot;, &quot;COM3&quot;,
  85. &quot;COM4&quot;, &quot;COM5&quot;, &quot;COM6&quot;, &quot;COM7&quot;, &quot;COM8&quot;, &quot;COM9&quot;, &quot;LPT0&quot;,
  86. &quot;LPT1&quot;, &quot;LPT2&quot;, &quot;LPT3&quot;, &quot;LPT4&quot;, &quot;LPT5&quot;, &quot;LPT6&quot;, &quot;LPT7&quot;,
  87. &quot;LPT8&quot;, &quot;LPT9&quot;]">invalidFilenames</a></li>
  88. </ul>
  89. </details>
  90. </li>
  91. <li>
  92. <details open>
  93. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  94. <ul class="simple simple-toc-section">
  95. <ul class="simple nested-toc-section">createHardlink
  96. <li><a class="reference" href="#createHardlink%2Cstring%2Cstring" title="createHardlink(src, dest: string)">createHardlink(src, dest: string)</a></li>
  97. </ul>
  98. <ul class="simple nested-toc-section">exclFilePermissions
  99. <li><a class="reference" href="#exclFilePermissions%2Cstring%2Cset%5BFilePermission%5D" title="exclFilePermissions(filename: string; permissions: set[FilePermission])">exclFilePermissions(filename: string; permissions: set[FilePermission])</a></li>
  100. </ul>
  101. <ul class="simple nested-toc-section">execShellCmd
  102. <li><a class="reference" href="#execShellCmd%2Cstring" title="execShellCmd(command: string): int">execShellCmd(command: string): int</a></li>
  103. </ul>
  104. <ul class="simple nested-toc-section">exitStatusLikeShell
  105. <li><a class="reference" href="#exitStatusLikeShell%2Ccint" title="exitStatusLikeShell(status: cint): cint">exitStatusLikeShell(status: cint): cint</a></li>
  106. </ul>
  107. <ul class="simple nested-toc-section">expandFilename
  108. <li><a class="reference" href="#expandFilename%2Cstring" title="expandFilename(filename: string): string">expandFilename(filename: string): string</a></li>
  109. </ul>
  110. <ul class="simple nested-toc-section">expandTilde
  111. <li><a class="reference" href="#expandTilde%2Cstring" title="expandTilde(path: string): string">expandTilde(path: string): string</a></li>
  112. </ul>
  113. <ul class="simple nested-toc-section">fileNewer
  114. <li><a class="reference" href="#fileNewer%2Cstring%2Cstring" title="fileNewer(a, b: string): bool">fileNewer(a, b: string): bool</a></li>
  115. </ul>
  116. <ul class="simple nested-toc-section">findExe
  117. <li><a class="reference" href="#findExe%2Cstring%2Cbool%2CopenArray%5Bstring%5D" title="findExe(exe: string; followSymlinks: bool = true;
  118. extensions: openArray[string] = ExeExts): string">findExe(exe: string; followSymlinks: bool = true;
  119. extensions: openArray[string] = ExeExts): string</a></li>
  120. </ul>
  121. <ul class="simple nested-toc-section">getAppDir
  122. <li><a class="reference" href="#getAppDir" title="getAppDir(): string">getAppDir(): string</a></li>
  123. </ul>
  124. <ul class="simple nested-toc-section">getAppFilename
  125. <li><a class="reference" href="#getAppFilename" title="getAppFilename(): string">getAppFilename(): string</a></li>
  126. </ul>
  127. <ul class="simple nested-toc-section">getCreationTime
  128. <li><a class="reference" href="#getCreationTime%2Cstring" title="getCreationTime(file: string): times.Time">getCreationTime(file: string): times.Time</a></li>
  129. </ul>
  130. <ul class="simple nested-toc-section">getCurrentCompilerExe
  131. <li><a class="reference" href="#getCurrentCompilerExe" title="getCurrentCompilerExe(): string">getCurrentCompilerExe(): string</a></li>
  132. </ul>
  133. <ul class="simple nested-toc-section">getCurrentProcessId
  134. <li><a class="reference" href="#getCurrentProcessId" title="getCurrentProcessId(): int">getCurrentProcessId(): int</a></li>
  135. </ul>
  136. <ul class="simple nested-toc-section">getFileInfo
  137. <li><a class="reference" href="#getFileInfo%2CFile" title="getFileInfo(file: File): FileInfo">getFileInfo(file: File): FileInfo</a></li>
  138. <li><a class="reference" href="#getFileInfo%2CFileHandle" title="getFileInfo(handle: FileHandle): FileInfo">getFileInfo(handle: FileHandle): FileInfo</a></li>
  139. <li><a class="reference" href="#getFileInfo%2Cstring" title="getFileInfo(path: string; followSymlink = true): FileInfo">getFileInfo(path: string; followSymlink = true): FileInfo</a></li>
  140. </ul>
  141. <ul class="simple nested-toc-section">getFileSize
  142. <li><a class="reference" href="#getFileSize%2Cstring" title="getFileSize(file: string): BiggestInt">getFileSize(file: string): BiggestInt</a></li>
  143. </ul>
  144. <ul class="simple nested-toc-section">getLastAccessTime
  145. <li><a class="reference" href="#getLastAccessTime%2Cstring" title="getLastAccessTime(file: string): times.Time">getLastAccessTime(file: string): times.Time</a></li>
  146. </ul>
  147. <ul class="simple nested-toc-section">getLastModificationTime
  148. <li><a class="reference" href="#getLastModificationTime%2Cstring" title="getLastModificationTime(file: string): times.Time">getLastModificationTime(file: string): times.Time</a></li>
  149. </ul>
  150. <ul class="simple nested-toc-section">inclFilePermissions
  151. <li><a class="reference" href="#inclFilePermissions%2Cstring%2Cset%5BFilePermission%5D" title="inclFilePermissions(filename: string; permissions: set[FilePermission])">inclFilePermissions(filename: string; permissions: set[FilePermission])</a></li>
  152. </ul>
  153. <ul class="simple nested-toc-section">isAdmin
  154. <li><a class="reference" href="#isAdmin" title="isAdmin(): bool">isAdmin(): bool</a></li>
  155. </ul>
  156. <ul class="simple nested-toc-section">isHidden
  157. <li><a class="reference" href="#isHidden%2Cstring" title="isHidden(path: string): bool">isHidden(path: string): bool</a></li>
  158. </ul>
  159. <ul class="simple nested-toc-section">isValidFilename
  160. <li><a class="reference" href="#isValidFilename%2Cstring" title="isValidFilename(filename: string; maxLen = 259.Positive): bool">isValidFilename(filename: string; maxLen = 259.Positive): bool</a></li>
  161. </ul>
  162. <ul class="simple nested-toc-section">quoteShell
  163. <li><a class="reference" href="#quoteShell%2Cstring" title="quoteShell(s: string): string">quoteShell(s: string): string</a></li>
  164. </ul>
  165. <ul class="simple nested-toc-section">quoteShellCommand
  166. <li><a class="reference" href="#quoteShellCommand%2CopenArray%5Bstring%5D" title="quoteShellCommand(args: openArray[string]): string">quoteShellCommand(args: openArray[string]): string</a></li>
  167. </ul>
  168. <ul class="simple nested-toc-section">quoteShellPosix
  169. <li><a class="reference" href="#quoteShellPosix%2Cstring" title="quoteShellPosix(s: string): string">quoteShellPosix(s: string): string</a></li>
  170. </ul>
  171. <ul class="simple nested-toc-section">quoteShellWindows
  172. <li><a class="reference" href="#quoteShellWindows%2Cstring" title="quoteShellWindows(s: string): string">quoteShellWindows(s: string): string</a></li>
  173. </ul>
  174. <ul class="simple nested-toc-section">sameFileContent
  175. <li><a class="reference" href="#sameFileContent%2Cstring%2Cstring" title="sameFileContent(path1, path2: string): bool">sameFileContent(path1, path2: string): bool</a></li>
  176. </ul>
  177. <ul class="simple nested-toc-section">setLastModificationTime
  178. <li><a class="reference" href="#setLastModificationTime%2Cstring%2C" title="setLastModificationTime(file: string; t: times.Time)">setLastModificationTime(file: string; t: times.Time)</a></li>
  179. </ul>
  180. <ul class="simple nested-toc-section">sleep
  181. <li><a class="reference" href="#sleep%2Cint" title="sleep(milsecs: int)">sleep(milsecs: int)</a></li>
  182. </ul>
  183. </ul>
  184. </details>
  185. </li>
  186. <li>
  187. <details open>
  188. <summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
  189. <ul class="simple simple-toc-section">
  190. <ul class="simple nested-toc-section">existsDir
  191. <li><a class="reference" href="#existsDir.t%2Cvarargs%5Buntyped%5D" title="existsDir(args: varargs[untyped]): untyped">existsDir(args: varargs[untyped]): untyped</a></li>
  192. </ul>
  193. <ul class="simple nested-toc-section">existsFile
  194. <li><a class="reference" href="#existsFile.t%2Cvarargs%5Buntyped%5D" title="existsFile(args: varargs[untyped]): untyped">existsFile(args: varargs[untyped]): untyped</a></li>
  195. </ul>
  196. </ul>
  197. </details>
  198. </li>
  199. </ul>
  200. </div>
  201. <div class="nine columns" id="content">
  202. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  203. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  204. <div id="tocRoot"></div>
  205. <p class="module-desc">This module contains basic operating system facilities like retrieving environment variables, working with directories, running shell commands, etc.
  206. <p><strong class="examples_text">Example:</strong></p>
  207. <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">os</span>
  208. <span class="Keyword">let</span> <span class="Identifier">myFile</span> <span class="Operator">=</span> <span class="StringLit">&quot;/path/to/my/file.nim&quot;</span>
  209. <span class="Identifier">assert</span> <span class="Identifier">splitPath</span><span class="Punctuation">(</span><span class="Identifier">myFile</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Punctuation">(</span><span class="Identifier">head</span><span class="Punctuation">:</span> <span class="StringLit">&quot;/path/to/my&quot;</span><span class="Punctuation">,</span> <span class="Identifier">tail</span><span class="Punctuation">:</span> <span class="StringLit">&quot;file.nim&quot;</span><span class="Punctuation">)</span>
  210. <span class="Keyword">when</span> <span class="Identifier">defined</span><span class="Punctuation">(</span><span class="Identifier">posix</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  211. <span class="Identifier">assert</span> <span class="Identifier">parentDir</span><span class="Punctuation">(</span><span class="Identifier">myFile</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;/path/to/my&quot;</span>
  212. <span class="Identifier">assert</span> <span class="Identifier">splitFile</span><span class="Punctuation">(</span><span class="Identifier">myFile</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Punctuation">(</span><span class="Identifier">dir</span><span class="Punctuation">:</span> <span class="StringLit">&quot;/path/to/my&quot;</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">&quot;file&quot;</span><span class="Punctuation">,</span> <span class="Identifier">ext</span><span class="Punctuation">:</span> <span class="StringLit">&quot;.nim&quot;</span><span class="Punctuation">)</span>
  213. <span class="Identifier">assert</span> <span class="Identifier">myFile</span><span class="Operator">.</span><span class="Identifier">changeFileExt</span><span class="Punctuation">(</span><span class="StringLit">&quot;c&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;/path/to/my/file.c&quot;</span></pre><strong>See also:</strong><ul class="simple"><li><a class="reference external" href="paths.html">paths</a> and <a class="reference external" href="files.html">files</a> modules for high-level file manipulation</li>
  214. <li><a class="reference external" href="osproc.html">osproc module</a> for process communication beyond <a class="reference internal nimdoc" title="proc execShellCmd(command: string): int" href="#execShellCmd,string">execShellCmd proc</a></li>
  215. <li><a class="reference external" href="uri.html">uri module</a></li>
  216. <li><a class="reference external" href="distros.html">distros module</a></li>
  217. <li><a class="reference external" href="dynlib.html">dynlib module</a></li>
  218. <li><a class="reference external" href="streams.html">streams module</a></li>
  219. </ul>
  220. </p>
  221. <div class="section" id="6">
  222. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  223. <dl class="item">
  224. <a class="reference external" href="ospaths2.html">ospaths2</a>, <a class="reference external" href="osfiles.html">osfiles</a>, <a class="reference external" href="osdirs.html">osdirs</a>, <a class="reference external" href="ossymlinks.html">ossymlinks</a>, <a class="reference external" href="osappdirs.html">osappdirs</a>, <a class="reference external" href="oscommon.html">oscommon</a>, <a class="reference external" href="since.html">since</a>, <a class="reference external" href="cmdline.html">cmdline</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="pathnorm.html">pathnorm</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="widestrs.html">widestrs</a>, <a class="reference external" href="posix.html">posix</a>, <a class="reference external" href="times.html">times</a>, <a class="reference external" href="oserrors.html">oserrors</a>, <a class="reference external" href="envvars.html">envvars</a>, <a class="reference external" href="osseps.html">osseps</a>
  225. </dl>
  226. </div>
  227. <div class="section" id="7">
  228. <h1><a class="toc-backref" href="#7">Types</a></h1>
  229. <dl class="item">
  230. <div id="DeviceId">
  231. <dt><pre><a href="os.html#DeviceId"><span class="Identifier">DeviceId</span></a> <span class="Other">=</span> <a href="posix.html#Dev"><span class="Identifier">Dev</span></a></pre></dt>
  232. <dd>
  233. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L731" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  234. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L731" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  235. </dd>
  236. </div>
  237. <div id="FileId">
  238. <dt><pre><a href="os.html#FileId"><span class="Identifier">FileId</span></a> <span class="Other">=</span> <a href="posix.html#Ino"><span class="Identifier">Ino</span></a></pre></dt>
  239. <dd>
  240. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L732" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  241. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L732" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  242. </dd>
  243. </div>
  244. <div id="FileInfo">
  245. <dt><pre><a href="os.html#FileInfo"><span class="Identifier">FileInfo</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
  246. <span class="Identifier">id</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">device</span><span class="Other">:</span> <a href="os.html#DeviceId"><span class="Identifier">DeviceId</span></a><span class="Other">,</span> <span class="Identifier">file</span><span class="Other">:</span> <a href="os.html#FileId"><span class="Identifier">FileId</span></a><span class="Other">]</span> <span class="Comment">## Device and file id.</span>
  247. <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <a href="oscommon.html#PathComponent"><span class="Identifier">PathComponent</span></a> <span class="Comment">## Kind of file object - directory, symlink, etc.</span>
  248. <span class="Identifier">size</span><span class="Operator">*</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a> <span class="Comment">## Size of file.</span>
  249. <span class="Identifier">permissions</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="osfiles.html#FilePermission"><span class="Identifier">FilePermission</span></a><span class="Other">]</span> <span class="Comment">## File permissions</span>
  250. <span class="Identifier">linkCount</span><span class="Operator">*</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a> <span class="Comment">## Number of hard links the file object has.</span>
  251. <span class="Identifier">lastAccessTime</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> <span class="Comment">## Time file was last accessed.</span>
  252. <span class="Identifier">lastWriteTime</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> <span class="Comment">## Time file was last modified/written to.</span>
  253. <span class="Identifier">creationTime</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> <span class="Comment">## Time file was created. Not supported on all systems!</span>
  254. <span class="Identifier">blockSize</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Comment">## Preferred I/O block size for this object.</span>
  255. <span class="Comment">## In some filesystems, this may vary from file to file.</span>
  256. <span class="Identifier">isSpecial</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Comment">## Is file special? (on Unix some &quot;files&quot;</span>
  257. <span class="Comment">## can be special=non-regular like FIFOs,</span>
  258. <span class="Comment">## devices); for directories `isSpecial`</span>
  259. <span class="Comment">## is always `false`, for symlinks it is</span>
  260. <span class="Comment">## the same as for the link's target.</span></pre></dt>
  261. <dd>
  262. <p>Contains information associated with a file object.</p>
  263. <p>See also:</p>
  264. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFileInfo(handle: FileHandle): FileInfo" href="#getFileInfo,FileHandle">getFileInfo(handle) proc</a></li>
  265. <li><a class="reference internal nimdoc" title="proc getFileInfo(file: File): FileInfo" href="#getFileInfo,File">getFileInfo(file) proc</a></li>
  266. <li><a class="reference internal nimdoc" title="proc getFileInfo(path: string; followSymlink = true): FileInfo" href="#getFileInfo,string">getFileInfo(path, followSymlink) proc</a></li>
  267. </ul>
  268. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L735" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  269. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L735" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  270. </dd>
  271. </div>
  272. </dl>
  273. </div>
  274. <div class="section" id="10">
  275. <h1><a class="toc-backref" href="#10">Consts</a></h1>
  276. <dl class="item">
  277. <div id="ExeExts">
  278. <dt><pre><a href="os.html#ExeExts"><span class="Identifier">ExeExts</span></a> <span class="Other">=</span> <span class="Other">[</span><span class="StringLit">&quot;&quot;</span><span class="Other">]</span></pre></dt>
  279. <dd>
  280. Platform specific file extension for executables. On Windows <tt class="docutils literal"><span class="pre">[&quot;exe&quot;, &quot;cmd&quot;, &quot;bat&quot;]</span></tt>, on Posix <tt class="docutils literal"><span class="pre">[&quot;&quot;]</span></tt>.
  281. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L220" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  282. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L220" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  283. </dd>
  284. </div>
  285. <div id="invalidFilenameChars">
  286. <dt><pre><a href="os.html#invalidFilenameChars"><span class="Identifier">invalidFilenameChars</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="CharLit">'/'</span><span class="Other">,</span> <span class="CharLit">'\\'</span><span class="Other">,</span> <span class="CharLit">':'</span><span class="Other">,</span> <span class="CharLit">'*'</span><span class="Other">,</span> <span class="CharLit">'?'</span><span class="Other">,</span> <span class="CharLit">'\&quot;'</span><span class="Other">,</span> <span class="CharLit">'&lt;'</span><span class="Other">,</span> <span class="CharLit">'&gt;'</span><span class="Other">,</span> <span class="CharLit">'|'</span><span class="Other">,</span> <span class="CharLit">'^'</span><span class="Other">,</span>
  287. <span class="CharLit">'\x00'</span><span class="Other">}</span></pre></dt>
  288. <dd>
  289. Characters that may produce invalid filenames across Linux, Windows and Mac. You can check if your filename contains any of these chars and strip them for safety. Mac bans <tt class="docutils literal"><span class="pre">':'</span></tt>, Linux bans <tt class="docutils literal"><span class="pre">'/'</span></tt>, Windows bans all others.
  290. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L64" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  291. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L64" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  292. </dd>
  293. </div>
  294. <div id="invalidFilenames">
  295. <dt><pre><a href="os.html#invalidFilenames"><span class="Identifier">invalidFilenames</span></a> <span class="Other">=</span> <span class="Other">[</span><span class="StringLit">&quot;CON&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;PRN&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;AUX&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;NUL&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM0&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM1&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM2&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM3&quot;</span><span class="Other">,</span>
  296. <span class="StringLit">&quot;COM4&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM5&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM6&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM7&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM8&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;COM9&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT0&quot;</span><span class="Other">,</span>
  297. <span class="StringLit">&quot;LPT1&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT2&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT3&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT4&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT5&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT6&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT7&quot;</span><span class="Other">,</span>
  298. <span class="StringLit">&quot;LPT8&quot;</span><span class="Other">,</span> <span class="StringLit">&quot;LPT9&quot;</span><span class="Other">]</span></pre></dt>
  299. <dd>
  300. Filenames that may be invalid across Linux, Windows, Mac, etc. You can check if your filename match these and rename it for safety (Currently all invalid filenames are from Windows only).
  301. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L68" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  302. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L68" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  303. </dd>
  304. </div>
  305. </dl>
  306. </div>
  307. <div class="section" id="12">
  308. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  309. <dl class="item">
  310. <div id="createHardlink-procs-all">
  311. <div id="createHardlink,string,string">
  312. <dt><pre><span class="Keyword">proc</span> <a href="#createHardlink%2Cstring%2Cstring"><span class="Identifier">createHardlink</span></a><span class="Other">(</span><span class="Identifier">src</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  313. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  314. <dd>
  315. Create a hard link at <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> which points to the item specified by <tt class="docutils literal"><span class="pre"><span class="Identifier">src</span></span></tt>.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
  316. Some OS's restrict the creation of hard links to root users (administrators).</div>
  317. <p>See also:</p>
  318. <ul class="simple"><li><a class="reference external" href="./symlinks.html#createSymlink,Path,Path">symlinks: createSymlink proc</a></li>
  319. </ul>
  320. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L466" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  321. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L466" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  322. </dd>
  323. </div>
  324. </div>
  325. <div id="exclFilePermissions-procs-all">
  326. <div id="exclFilePermissions,string,set[FilePermission]">
  327. <dt><pre><span class="Keyword">proc</span> <a href="#exclFilePermissions%2Cstring%2Cset%5BFilePermission%5D"><span class="Identifier">exclFilePermissions</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">permissions</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="osfiles.html#FilePermission"><span class="Identifier">FilePermission</span></a><span class="Other">]</span><span class="Other">)</span> {.
  328. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">,</span> <a href="oscommon.html#WriteDirEffect"><span class="Identifier">WriteDirEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  329. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  330. <dd>
  331. <p>A convenience proc for:</p>
  332. <p><pre class="listing"><span class="Identifier">setFilePermissions</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">,</span> <span class="Identifier">getFilePermissions</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">)</span><span class="Operator">-</span><span class="Identifier">permissions</span><span class="Punctuation">)</span></pre></p>
  333. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L493" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  334. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L493" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  335. </dd>
  336. </div>
  337. </div>
  338. <div id="execShellCmd-procs-all">
  339. <div id="execShellCmd,string">
  340. <dt><pre><span class="Keyword">proc</span> <a href="#execShellCmd%2Cstring"><span class="Identifier">execShellCmd</span></a><span class="Other">(</span><span class="Identifier">command</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  341. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ExecIOEffect"><span class="Identifier">ExecIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  342. <dd>
  343. <p>Executes a <span id="shell-command_1">shell command</span>.</p>
  344. <p>Command has the form 'program args' where args are the command line arguments given to program. The proc returns the error code of the shell when it has finished (zero if there is no error). The proc does not return until the process has finished.</p>
  345. <p>To execute a program without having a shell involved, use <a class="reference external" href="osproc.html#execProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]">osproc.execProcess proc</a>.</p>
  346. <p><strong>Examples:</strong></p>
  347. <p><pre class="listing"><span class="Keyword">discard</span> <span class="Identifier">execShellCmd</span><span class="Punctuation">(</span><span class="StringLit">&quot;ls -la&quot;</span><span class="Punctuation">)</span></pre></p>
  348. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L401" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  349. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L401" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  350. </dd>
  351. </div>
  352. </div>
  353. <div id="exitStatusLikeShell-procs-all">
  354. <div id="exitStatusLikeShell,cint">
  355. <dt><pre><span class="Keyword">proc</span> <a href="#exitStatusLikeShell%2Ccint"><span class="Identifier">exitStatusLikeShell</span></a><span class="Other">(</span><span class="Identifier">status</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  356. <dd>
  357. Converts exit code from <tt class="docutils literal"><span class="pre"><span class="Identifier">c_system</span></span></tt> into a shell exit code.
  358. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L390" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  359. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L390" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  360. </dd>
  361. </div>
  362. </div>
  363. <div id="expandFilename-procs-all">
  364. <div id="expandFilename,string">
  365. <dt><pre><span class="Keyword">proc</span> <a href="#expandFilename%2Cstring"><span class="Identifier">expandFilename</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  366. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  367. <dd>
  368. <p>Returns the full (<span id="absolute_1">absolute</span>) path of an existing file <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.</p>
  369. <p>Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> in case of an error. Follows symlinks.</p>
  370. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L419" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  371. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L419" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  372. </dd>
  373. </div>
  374. </div>
  375. <div id="expandTilde-procs-all">
  376. <div id="expandTilde,string">
  377. <dt><pre><span class="Keyword">proc</span> <a href="#expandTilde%2Cstring"><span class="Identifier">expandTilde</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="envvars.html#ReadEnvEffect"><span class="Identifier">ReadEnvEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  378. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  379. <dd>
  380. <p>Expands <tt class="docutils literal"><span class="pre">~</span></tt> or a path starting with <tt class="docutils literal"><span class="pre">~/</span></tt> to a full path, replacing <tt class="docutils literal"><span class="pre">~</span></tt> with <a class="reference external" href="./appdirs.html#getHomeDir">appdirs: getHomeDir()</a> (otherwise returns <tt class="docutils literal"><span class="pre">path</span></tt> unmodified).</p>
  381. <p>Windows: this is still supported despite the Windows platform not having this convention; also, both <tt class="docutils literal"><span class="pre">~/</span></tt> and <tt class="docutils literal"><span class="pre">~\</span></tt> are handled.</p>
  382. <p>See also:</p>
  383. <ul class="simple"><li><a class="reference external" href="./appdirs.html#getHomeDir">appdirs: getHomeDir proc</a></li>
  384. <li><a class="reference external" href="./appdirs.html#getConfigDir">appdirs: getConfigDir proc</a></li>
  385. <li><a class="reference external" href="./appdirs.html#getTempDir">appdirs: getTempDir proc</a></li>
  386. <li><a class="reference external" href="./ospaths2.html#getCurrentDir">ospaths2: getCurrentDir proc</a></li>
  387. <li><a class="reference external" href="./dirs.html#setCurrentDir,Path">dirs: setCurrentDir proc</a></li>
  388. </ul>
  389. <p><strong class="examples_text">Example:</strong></p>
  390. <pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">expandTilde</span><span class="Punctuation">(</span><span class="StringLit">&quot;~&quot;</span> <span class="Operator">/</span> <span class="StringLit">&quot;appname.cfg&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">getHomeDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="StringLit">&quot;appname.cfg&quot;</span>
  391. <span class="Identifier">assert</span> <span class="Identifier">expandTilde</span><span class="Punctuation">(</span><span class="StringLit">&quot;~/foo/bar&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">getHomeDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="StringLit">&quot;foo/bar&quot;</span>
  392. <span class="Identifier">assert</span> <span class="Identifier">expandTilde</span><span class="Punctuation">(</span><span class="StringLit">&quot;/foo/bar&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;/foo/bar&quot;</span></pre>
  393. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L112" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  394. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L112" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  395. </dd>
  396. </div>
  397. </div>
  398. <div id="fileNewer-procs-all">
  399. <div id="fileNewer,string,string">
  400. <dt><pre><span class="Keyword">proc</span> <a href="#fileNewer%2Cstring%2Cstring"><span class="Identifier">fileNewer</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
  401. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  402. <dd>
  403. <p>Returns true if the file <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is newer than file <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt>, i.e. if <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>'s modification time is later than <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt>'s.</p>
  404. <p>See also:</p>
  405. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getLastModificationTime(file: string): times.Time" href="#getLastModificationTime,string">getLastModificationTime proc</a></li>
  406. <li><a class="reference internal nimdoc" title="proc getLastAccessTime(file: string): times.Time" href="#getLastAccessTime,string">getLastAccessTime proc</a></li>
  407. <li><a class="reference internal nimdoc" title="proc getCreationTime(file: string): times.Time" href="#getCreationTime,string">getCreationTime proc</a></li>
  408. </ul>
  409. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L340" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  410. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L340" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  411. </dd>
  412. </div>
  413. </div>
  414. <div id="findExe-procs-all">
  415. <div id="findExe,string,bool,openArray[string]">
  416. <dt><pre><span class="Keyword">proc</span> <a href="#findExe%2Cstring%2Cbool%2CopenArray%5Bstring%5D"><span class="Identifier">findExe</span></a><span class="Other">(</span><span class="Identifier">exe</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">followSymlinks</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
  417. <span class="Identifier">extensions</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Identifier">ExeExts</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
  418. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">,</span> <a href="envvars.html#ReadEnvEffect"><span class="Identifier">ReadEnvEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
  419. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  420. <dd>
  421. <p>Searches for <tt class="docutils literal"><span class="pre"><span class="Identifier">exe</span></span></tt> in the current working directory and then in directories listed in the <tt class="docutils literal"><span class="pre">PATH</span></tt> environment variable.</p>
  422. <p>Returns <tt class="docutils literal"><span class="pre"><span class="StringLit">&quot;&quot;</span></span></tt> if the <tt class="docutils literal"><span class="pre"><span class="Identifier">exe</span></span></tt> cannot be found. <tt class="docutils literal"><span class="pre"><span class="Identifier">exe</span></span></tt> is added the <a class="reference internal nimdoc" title="const ExeExts" href="#ExeExts">ExeExts</a> file extensions if it has none.</p>
  423. <p>If the system supports symlinks it also resolves them until it meets the actual file. This behavior can be disabled if desired by setting <tt class="docutils literal"><span class="pre"><span class="Identifier">followSymlinks</span> <span class="Operator">=</span> <span class="Identifier">false</span></span></tt>.</p>
  424. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L224" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  425. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L224" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  426. </dd>
  427. </div>
  428. </div>
  429. <div id="getAppDir-procs-all">
  430. <div id="getAppDir">
  431. <dt><pre><span class="Keyword">proc</span> <a href="#getAppDir"><span class="Identifier">getAppDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  432. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  433. <dd>
  434. <p>Returns the directory of the application's executable.</p>
  435. <p>See also:</p>
  436. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getAppFilename(): string" href="#getAppFilename">getAppFilename proc</a></li>
  437. </ul>
  438. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L689" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  439. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L689" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  440. </dd>
  441. </div>
  442. </div>
  443. <div id="getAppFilename-procs-all">
  444. <div id="getAppFilename">
  445. <dt><pre><span class="Keyword">proc</span> <a href="#getAppFilename"><span class="Identifier">getAppFilename</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  446. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  447. <dd>
  448. <p>Returns the filename of the application's executable. This proc will resolve symlinks.</p>
  449. <p>Returns empty string when name is unavailable</p>
  450. <p>See also:</p>
  451. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getAppDir(): string" href="#getAppDir">getAppDir proc</a></li>
  452. <li><a class="reference internal nimdoc" title="proc getCurrentCompilerExe(): string" href="#getCurrentCompilerExe">getCurrentCompilerExe proc</a></li>
  453. </ul>
  454. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L630" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  455. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L630" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  456. </dd>
  457. </div>
  458. </div>
  459. <div id="getCreationTime-procs-all">
  460. <div id="getCreationTime,string">
  461. <dt><pre><span class="Keyword">proc</span> <a href="#getCreationTime%2Cstring"><span class="Identifier">getCreationTime</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  462. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  463. <dd>
  464. <p>Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>'s creation time.</p>
  465. <p><strong>Note:</strong> Under POSIX OS's, the returned time may actually be the time at which the file's attribute's were last modified. See <a class="reference external" href="https://github.com/nim-lang/Nim/issues/1058">here</a> for details.</p>
  466. <p>See also:</p>
  467. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getLastModificationTime(file: string): times.Time" href="#getLastModificationTime,string">getLastModificationTime proc</a></li>
  468. <li><a class="reference internal nimdoc" title="proc getLastAccessTime(file: string): times.Time" href="#getLastAccessTime,string">getLastAccessTime proc</a></li>
  469. <li><a class="reference internal nimdoc" title="proc fileNewer(a, b: string): bool" href="#fileNewer,string,string">fileNewer proc</a></li>
  470. </ul>
  471. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L318" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  472. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L318" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  473. </dd>
  474. </div>
  475. </div>
  476. <div id="getCurrentCompilerExe-procs-all">
  477. <div id="getCurrentCompilerExe">
  478. <dt><pre><span class="Keyword">proc</span> <a href="#getCurrentCompilerExe"><span class="Identifier">getCurrentCompilerExe</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">compileTime</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  479. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  480. <dd>
  481. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L456" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  482. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L456" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  483. </dd>
  484. </div>
  485. </div>
  486. <div id="getCurrentProcessId-procs-all">
  487. <div id="getCurrentProcessId">
  488. <dt><pre><span class="Keyword">proc</span> <a href="#getCurrentProcessId"><span class="Identifier">getCurrentProcessId</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  489. <dd>
  490. <p>Return current process ID.</p>
  491. <p>See also:</p>
  492. <ul class="simple"><li><a class="reference external" href="osproc.html#processID,Process">osproc.processID(p: Process)</a></li>
  493. </ul>
  494. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L970" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  495. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L970" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  496. </dd>
  497. </div>
  498. </div>
  499. <div id="getFileInfo-procs-all">
  500. <div id="getFileInfo,File">
  501. <dt><pre><span class="Keyword">proc</span> <a href="#getFileInfo%2CFile"><span class="Identifier">getFileInfo</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">)</span><span class="Other">:</span> <a href="os.html#FileInfo"><span class="Identifier">FileInfo</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  502. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  503. <dd>
  504. <p>Retrieves file information for the file object.</p>
  505. <p>See also:</p>
  506. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFileInfo(handle: FileHandle): FileInfo" href="#getFileInfo,FileHandle">getFileInfo(handle) proc</a></li>
  507. <li><a class="reference internal nimdoc" title="proc getFileInfo(path: string; followSymlink = true): FileInfo" href="#getFileInfo,string">getFileInfo(path, followSymlink) proc</a></li>
  508. </ul>
  509. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L859" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  510. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L859" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  511. </dd>
  512. </div>
  513. <div id="getFileInfo,FileHandle">
  514. <dt><pre><span class="Keyword">proc</span> <a href="#getFileInfo%2CFileHandle"><span class="Identifier">getFileInfo</span></a><span class="Other">(</span><span class="Identifier">handle</span><span class="Other">:</span> <a href="syncio.html#FileHandle"><span class="Identifier">FileHandle</span></a><span class="Other">)</span><span class="Other">:</span> <a href="os.html#FileInfo"><span class="Identifier">FileInfo</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  515. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  516. <dd>
  517. <p>Retrieves file information for the file object represented by the given handle.</p>
  518. <p>If the information cannot be retrieved, such as when the file handle is invalid, <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised.</p>
  519. <p>See also:</p>
  520. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFileInfo(file: File): FileInfo" href="#getFileInfo,File">getFileInfo(file) proc</a></li>
  521. <li><a class="reference internal nimdoc" title="proc getFileInfo(path: string; followSymlink = true): FileInfo" href="#getFileInfo,string">getFileInfo(path, followSymlink) proc</a></li>
  522. </ul>
  523. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L832" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  524. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L832" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  525. </dd>
  526. </div>
  527. <div id="getFileInfo,string">
  528. <dt><pre><span class="Keyword">proc</span> <a href="#getFileInfo%2Cstring"><span class="Identifier">getFileInfo</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">followSymlink</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <a href="os.html#FileInfo"><span class="Identifier">FileInfo</span></a> {.
  529. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  530. <dd>
  531. <p>Retrieves file information for the file object pointed to by <tt class="docutils literal"><span class="pre"><span class="Identifier">path</span></span></tt>.</p>
  532. <p>Due to intrinsic differences between operating systems, the information contained by the returned <a class="reference internal nimdoc" title="object FileInfo" href="#FileInfo">FileInfo object</a> will be slightly different across platforms, and in some cases, incomplete or inaccurate.</p>
  533. <p>When <tt class="docutils literal"><span class="pre"><span class="Identifier">followSymlink</span></span></tt> is true (default), symlinks are followed and the information retrieved is information related to the symlink's target. Otherwise, information on the symlink itself is retrieved (however, field <tt class="docutils literal"><span class="pre"><span class="Identifier">isSpecial</span></span></tt> is still determined from the target on Unix).</p>
  534. <p>If the information cannot be retrieved, such as when the path doesn't exist, or when permission restrictions prevent the program from retrieving file information, <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised.</p>
  535. <p>See also:</p>
  536. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFileInfo(handle: FileHandle): FileInfo" href="#getFileInfo,FileHandle">getFileInfo(handle) proc</a></li>
  537. <li><a class="reference internal nimdoc" title="proc getFileInfo(file: File): FileInfo" href="#getFileInfo,File">getFileInfo(file) proc</a></li>
  538. </ul>
  539. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L869" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  540. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L869" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  541. </dd>
  542. </div>
  543. </div>
  544. <div id="getFileSize-procs-all">
  545. <div id="getFileSize,string">
  546. <dt><pre><span class="Keyword">proc</span> <a href="#getFileSize%2Cstring"><span class="Identifier">getFileSize</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  547. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  548. <dd>
  549. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L709" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  550. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L709" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  551. </dd>
  552. </div>
  553. </div>
  554. <div id="getLastAccessTime-procs-all">
  555. <div id="getLastAccessTime,string">
  556. <dt><pre><span class="Keyword">proc</span> <a href="#getLastAccessTime%2Cstring"><span class="Identifier">getLastAccessTime</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  557. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  558. <dd>
  559. <p>Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>'s last read or write access time.</p>
  560. <p>See also:</p>
  561. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getLastModificationTime(file: string): times.Time" href="#getLastModificationTime,string">getLastModificationTime proc</a></li>
  562. <li><a class="reference internal nimdoc" title="proc getCreationTime(file: string): times.Time" href="#getCreationTime,string">getCreationTime proc</a></li>
  563. <li><a class="reference internal nimdoc" title="proc fileNewer(a, b: string): bool" href="#fileNewer,string,string">fileNewer proc</a></li>
  564. </ul>
  565. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L300" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  566. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L300" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  567. </dd>
  568. </div>
  569. </div>
  570. <div id="getLastModificationTime-procs-all">
  571. <div id="getLastModificationTime,string">
  572. <dt><pre><span class="Keyword">proc</span> <a href="#getLastModificationTime%2Cstring"><span class="Identifier">getLastModificationTime</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  573. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  574. <dd>
  575. <p>Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>'s last modification time.</p>
  576. <p>See also:</p>
  577. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getLastAccessTime(file: string): times.Time" href="#getLastAccessTime,string">getLastAccessTime proc</a></li>
  578. <li><a class="reference internal nimdoc" title="proc getCreationTime(file: string): times.Time" href="#getCreationTime,string">getCreationTime proc</a></li>
  579. <li><a class="reference internal nimdoc" title="proc fileNewer(a, b: string): bool" href="#fileNewer,string,string">fileNewer proc</a></li>
  580. </ul>
  581. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L282" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  582. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L282" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  583. </dd>
  584. </div>
  585. </div>
  586. <div id="inclFilePermissions-procs-all">
  587. <div id="inclFilePermissions,string,set[FilePermission]">
  588. <dt><pre><span class="Keyword">proc</span> <a href="#inclFilePermissions%2Cstring%2Cset%5BFilePermission%5D"><span class="Identifier">inclFilePermissions</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">permissions</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="osfiles.html#FilePermission"><span class="Identifier">FilePermission</span></a><span class="Other">]</span><span class="Other">)</span> {.
  589. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">,</span> <a href="oscommon.html#WriteDirEffect"><span class="Identifier">WriteDirEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  590. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  591. <dd>
  592. <p>A convenience proc for:</p>
  593. <p><pre class="listing"><span class="Identifier">setFilePermissions</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">,</span> <span class="Identifier">getFilePermissions</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">)</span><span class="Operator">+</span><span class="Identifier">permissions</span><span class="Punctuation">)</span></pre></p>
  594. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L484" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  595. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L484" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  596. </dd>
  597. </div>
  598. </div>
  599. <div id="isAdmin-procs-all">
  600. <div id="isAdmin">
  601. <dt><pre><span class="Keyword">proc</span> <a href="#isAdmin"><span class="Identifier">isAdmin</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  602. <dd>
  603. Returns whether the caller's process is a member of the Administrators local group (on Windows) or a root (on POSIX), via <tt class="docutils literal"><span class="pre"><span class="Identifier">geteuid</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span></span></tt>.
  604. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L358" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  605. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L358" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  606. </dd>
  607. </div>
  608. </div>
  609. <div id="isHidden-procs-all">
  610. <div id="isHidden,string">
  611. <dt><pre><span class="Keyword">proc</span> <a href="#isHidden%2Cstring"><span class="Identifier">isHidden</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  612. <dd>
  613. <p>Determines whether <tt class="docutils literal"><span class="pre">path</span></tt> is hidden or not, using <a class="reference external" href="https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory">this reference</a>.</p>
  614. <p>On Windows: returns true if it exists and its &quot;hidden&quot; attribute is set.</p>
  615. <p>On posix: returns true if <tt class="docutils literal"><span class="pre">lastPathPart(path)</span></tt> starts with <tt class="docutils literal"><span class="pre">.</span></tt> and is not <tt class="docutils literal"><span class="pre">.</span></tt> or <tt class="docutils literal"><span class="pre">..</span></tt>.</p>
  616. <p><strong>Note</strong>: paths are not normalized to determine <tt class="docutils literal"><span class="pre"><span class="Identifier">isHidden</span></span></tt>.</p>
  617. <p><strong class="examples_text">Example:</strong></p>
  618. <pre class="listing"><span class="Keyword">when</span> <span class="Identifier">defined</span><span class="Punctuation">(</span><span class="Identifier">posix</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  619. <span class="Identifier">assert</span> <span class="StringLit">&quot;.foo&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span>
  620. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="StringLit">&quot;.foo/bar&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span>
  621. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="StringLit">&quot;.&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span>
  622. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="StringLit">&quot;..&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span>
  623. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="StringLit">&quot;&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span>
  624. <span class="Identifier">assert</span> <span class="StringLit">&quot;.foo/&quot;</span><span class="Operator">.</span><span class="Identifier">isHidden</span></pre>
  625. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L943" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  626. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L943" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  627. </dd>
  628. </div>
  629. </div>
  630. <div id="isValidFilename-procs-all">
  631. <div id="isValidFilename,string">
  632. <dt><pre><span class="Keyword">func</span> <a href="#isValidFilename%2Cstring"><span class="Identifier">isValidFilename</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">259</span><span class="Other">.</span><span class="Identifier">Positive</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
  633. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  634. <dd>
  635. <p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> if <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> is valid for crossplatform use.</p>
  636. <p>This is useful if you want to copy or save files across Windows, Linux, Mac, etc. It uses <tt class="docutils literal"><span class="pre"><span class="Identifier">invalidFilenameChars</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">invalidFilenames</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">maxLen</span></span></tt> to verify the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.</p>
  637. <p>See also:</p>
  638. <ul class="simple"><li><a class="reference external" href="https://docs.microsoft.com/en-us/dotnet/api/system.io.pathtoolongexception">https://docs.microsoft.com/en-us/dotnet/api/system.io.pathtoolongexception</a></li>
  639. <li><a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file">https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file</a></li>
  640. <li><a class="reference external" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx</a></li>
  641. </ul>
  642. <div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
  643. This only checks filenames, not whole paths (because basically you can mount anything as a path on Linux).</div>
  644. <p><strong class="examples_text">Example:</strong></p>
  645. <pre class="listing"><span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot; foo&quot;</span><span class="Punctuation">)</span> <span class="Comment"># Leading white space</span>
  646. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;foo &quot;</span><span class="Punctuation">)</span> <span class="Comment"># Trailing white space</span>
  647. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;foo.&quot;</span><span class="Punctuation">)</span> <span class="Comment"># Ends with dot</span>
  648. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;con.txt&quot;</span><span class="Punctuation">)</span> <span class="Comment"># &quot;CON&quot; is invalid (Windows)</span>
  649. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;OwO:UwU&quot;</span><span class="Punctuation">)</span> <span class="Comment"># &quot;:&quot; is invalid (Mac)</span>
  650. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;aux.bat&quot;</span><span class="Punctuation">)</span> <span class="Comment"># &quot;AUX&quot; is invalid (Windows)</span>
  651. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;&quot;</span><span class="Punctuation">)</span> <span class="Comment"># Empty string</span>
  652. <span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">isValidFilename</span><span class="Punctuation">(</span><span class="StringLit">&quot;foo/&quot;</span><span class="Punctuation">)</span> <span class="Comment"># Filename is empty</span></pre>
  653. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L1000" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  654. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L1000" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  655. </dd>
  656. </div>
  657. </div>
  658. <div id="quoteShell-procs-all">
  659. <div id="quoteShell,string">
  660. <dt><pre><span class="Keyword">proc</span> <a href="#quoteShell%2Cstring"><span class="Identifier">quoteShell</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nosp$1&quot;</span><span class="Other">,</span>
  661. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  662. <dd>
  663. <p>Quote <tt class="docutils literal"><span class="pre">s</span></tt>, so it can be safely passed to shell.</p>
  664. <p>When on Windows, it calls <a class="reference internal nimdoc" title="proc quoteShellWindows(s: string): string" href="#quoteShellWindows,string">quoteShellWindows proc</a>. Otherwise, calls <a class="reference internal nimdoc" title="proc quoteShellPosix(s: string): string" href="#quoteShellPosix,string">quoteShellPosix proc</a>.</p>
  665. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L186" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  666. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L186" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  667. </dd>
  668. </div>
  669. </div>
  670. <div id="quoteShellCommand-procs-all">
  671. <div id="quoteShellCommand,openArray[string]">
  672. <dt><pre><span class="Keyword">proc</span> <a href="#quoteShellCommand%2CopenArray%5Bstring%5D"><span class="Identifier">quoteShellCommand</span></a><span class="Other">(</span><span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  673. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  674. <dd>
  675. Concatenates and quotes shell arguments <tt class="docutils literal"><span class="pre"><span class="Identifier">args</span></span></tt>.
  676. <p><strong class="examples_text">Example:</strong></p>
  677. <pre class="listing"><span class="Keyword">when</span> <span class="Identifier">defined</span><span class="Punctuation">(</span><span class="Identifier">posix</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  678. <span class="Identifier">assert</span> <span class="Identifier">quoteShellCommand</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">&quot;aaa&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;c d&quot;</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;aaa '' 'c d'&quot;</span>
  679. <span class="Keyword">when</span> <span class="Identifier">defined</span><span class="Punctuation">(</span><span class="Identifier">windows</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  680. <span class="Identifier">assert</span> <span class="Identifier">quoteShellCommand</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">&quot;aaa&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;c d&quot;</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;aaa </span><span class="EscapeSequence">\&quot;</span><span class="EscapeSequence">\&quot;</span><span class="StringLit"> </span><span class="EscapeSequence">\&quot;</span><span class="StringLit">c d</span><span class="EscapeSequence">\&quot;</span><span class="StringLit">&quot;</span></pre>
  681. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L196" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  682. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L196" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  683. </dd>
  684. </div>
  685. </div>
  686. <div id="quoteShellPosix-procs-all">
  687. <div id="quoteShellPosix,string">
  688. <dt><pre><span class="Keyword">proc</span> <a href="#quoteShellPosix%2Cstring"><span class="Identifier">quoteShellPosix</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  689. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nosp$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  690. <dd>
  691. Quote <tt class="docutils literal"><span class="pre">s</span></tt>, so it can be safely passed to POSIX shell.
  692. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L174" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  693. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L174" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  694. </dd>
  695. </div>
  696. </div>
  697. <div id="quoteShellWindows-procs-all">
  698. <div id="quoteShellWindows,string">
  699. <dt><pre><span class="Keyword">proc</span> <a href="#quoteShellWindows%2Cstring"><span class="Identifier">quoteShellWindows</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  700. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nosp$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  701. <dd>
  702. <p>Quote <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>, so it can be safely passed to Windows API.</p>
  703. <p>Based on Python's <tt class="docutils literal"><span class="pre"><span class="Identifier">subprocess</span><span class="Operator">.</span><span class="Identifier">list2cmdline</span></span></tt>. See <a class="reference external" href="https://msdn.microsoft.com/en-us/library/17w5ykft.aspx">this link</a> for more details.</p>
  704. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L141" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  705. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L141" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  706. </dd>
  707. </div>
  708. </div>
  709. <div id="sameFileContent-procs-all">
  710. <div id="sameFileContent,string,string">
  711. <dt><pre><span class="Keyword">proc</span> <a href="#sameFileContent%2Cstring%2Cstring"><span class="Identifier">sameFileContent</span></a><span class="Other">(</span><span class="Identifier">path1</span><span class="Other">,</span> <span class="Identifier">path2</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span>
  712. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  713. <dd>
  714. <p>Returns true if both pathname arguments refer to files with identical binary content.</p>
  715. <p>See also:</p>
  716. <ul class="simple"><li><a class="reference external" href="./ospaths2.html#sameFile,string,string">ospaths2: sameFile proc</a></li>
  717. </ul>
  718. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L909" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  719. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L909" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  720. </dd>
  721. </div>
  722. </div>
  723. <div id="setLastModificationTime-procs-all">
  724. <div id="setLastModificationTime,string,">
  725. <dt><pre><span class="Keyword">proc</span> <a href="#setLastModificationTime%2Cstring%2C"><span class="Identifier">setLastModificationTime</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">times</span><span class="Other">.</span><span class="Identifier">Time</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
  726. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  727. <dd>
  728. Sets the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>'s last modification time. <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised in case of an error.
  729. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L982" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  730. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L982" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  731. </dd>
  732. </div>
  733. </div>
  734. <div id="sleep-procs-all">
  735. <div id="sleep,int">
  736. <dt><pre><span class="Keyword">proc</span> <a href="#sleep%2Cint"><span class="Identifier">sleep</span></a><span class="Other">(</span><span class="Identifier">milsecs</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#TimeEffect"><span class="Identifier">TimeEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  737. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  738. <dd>
  739. Sleeps <tt class="docutils literal"><span class="pre"><span class="Identifier">milsecs</span></span></tt> milliseconds. A negative <tt class="docutils literal"><span class="pre"><span class="Identifier">milsecs</span></span></tt> causes sleep to return immediately.
  740. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L696" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  741. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L696" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  742. </dd>
  743. </div>
  744. </div>
  745. </dl>
  746. </div>
  747. <div class="section" id="18">
  748. <h1><a class="toc-backref" href="#18">Templates</a></h1>
  749. <dl class="item">
  750. <div id="existsDir-templates-all">
  751. <div id="existsDir.t,varargs[untyped]">
  752. <dt><pre><span class="Keyword">template</span> <a href="#existsDir.t%2Cvarargs%5Buntyped%5D"><span class="Identifier">existsDir</span></a><span class="Other">(</span><span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a> {.
  753. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use dirExists&quot;</span></span>.}</pre></dt>
  754. <dd>
  755. <div class="deprecation-message">
  756. <b>Deprecated:</b> use dirExists
  757. </div>
  758. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L1037" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  759. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L1037" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  760. </dd>
  761. </div>
  762. </div>
  763. <div id="existsFile-templates-all">
  764. <div id="existsFile.t,varargs[untyped]">
  765. <dt><pre><span class="Keyword">template</span> <a href="#existsFile.t%2Cvarargs%5Buntyped%5D"><span class="Identifier">existsFile</span></a><span class="Other">(</span><span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a> {.
  766. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use fileExists&quot;</span></span>.}</pre></dt>
  767. <dd>
  768. <div class="deprecation-message">
  769. <b>Deprecated:</b> use fileExists
  770. </div>
  771. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/os.nim#L1035" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  772. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/os.nim#L1035" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  773. </dd>
  774. </div>
  775. </div>
  776. </dl>
  777. </div>
  778. </div>
  779. </div>
  780. <div class="twelve-columns footer">
  781. <span class="nim-sprite"></span>
  782. <br>
  783. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 08:36:03 UTC</small>
  784. </div>
  785. </div>
  786. </div>
  787. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  788. </body>
  789. </html>