osfiles.html 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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/private/osfiles</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/private/osfiles</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="#CopyFlag" title="CopyFlag = enum
  57. cfSymlinkAsIs, ## Copy symlinks as symlinks
  58. cfSymlinkFollow, ## Copy the files symlinks point to
  59. cfSymlinkIgnore ## Ignore symlinks">CopyFlag</a></li>
  60. <li><a class="reference" href="#FilePermission" title="FilePermission = enum
  61. fpUserExec, ## execute access for the file owner
  62. fpUserWrite, ## write access for the file owner
  63. fpUserRead, ## read access for the file owner
  64. fpGroupExec, ## execute access for the group
  65. fpGroupWrite, ## write access for the group
  66. fpGroupRead, ## read access for the group
  67. fpOthersExec, ## execute access for others
  68. fpOthersWrite, ## write access for others
  69. fpOthersRead ## read access for others">FilePermission</a></li>
  70. </ul>
  71. </details>
  72. </li>
  73. <li>
  74. <details open>
  75. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  76. <ul class="simple simple-toc-section">
  77. <ul class="simple nested-toc-section">copyFile
  78. <li><a class="reference" href="#copyFile%2Cstring%2Cstring%2Cint" title="copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)">copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)</a></li>
  79. </ul>
  80. <ul class="simple nested-toc-section">copyFileToDir
  81. <li><a class="reference" href="#copyFileToDir%2Cstring%2Cstring%2Cint" title="copyFileToDir(source, dir: string; options = {cfSymlinkFollow};
  82. bufferSize = 16384)">copyFileToDir(source, dir: string; options = {cfSymlinkFollow};
  83. bufferSize = 16384)</a></li>
  84. </ul>
  85. <ul class="simple nested-toc-section">copyFileWithPermissions
  86. <li><a class="reference" href="#copyFileWithPermissions%2Cstring%2Cstring" title="copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  87. options = {cfSymlinkFollow})">copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  88. options = {cfSymlinkFollow})</a></li>
  89. </ul>
  90. <ul class="simple nested-toc-section">getFilePermissions
  91. <li><a class="reference" href="#getFilePermissions%2Cstring" title="getFilePermissions(filename: string): set[FilePermission]">getFilePermissions(filename: string): set[FilePermission]</a></li>
  92. </ul>
  93. <ul class="simple nested-toc-section">moveFile
  94. <li><a class="reference" href="#moveFile%2Cstring%2Cstring" title="moveFile(source, dest: string)">moveFile(source, dest: string)</a></li>
  95. </ul>
  96. <ul class="simple nested-toc-section">removeFile
  97. <li><a class="reference" href="#removeFile%2Cstring" title="removeFile(file: string)">removeFile(file: string)</a></li>
  98. </ul>
  99. <ul class="simple nested-toc-section">setFilePermissions
  100. <li><a class="reference" href="#setFilePermissions%2Cstring%2Cset%5BFilePermission%5D" title="setFilePermissions(filename: string; permissions: set[FilePermission];
  101. followSymlinks = true)">setFilePermissions(filename: string; permissions: set[FilePermission];
  102. followSymlinks = true)</a></li>
  103. </ul>
  104. <ul class="simple nested-toc-section">tryRemoveFile
  105. <li><a class="reference" href="#tryRemoveFile%2Cstring" title="tryRemoveFile(file: string): bool">tryRemoveFile(file: string): bool</a></li>
  106. </ul>
  107. </ul>
  108. </details>
  109. </li>
  110. </ul>
  111. </div>
  112. <div class="nine columns" id="content">
  113. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  114. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  115. <div id="tocRoot"></div>
  116. <p class="module-desc"></p>
  117. <div class="section" id="6">
  118. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  119. <dl class="item">
  120. <a class="reference external" href="since.html">since</a>, <a class="reference external" href="oserrors.html">oserrors</a>, <a class="reference external" href="oscommon.html">oscommon</a>, <a class="reference external" href="ospaths2.html">ospaths2</a>, <a class="reference external" href="ossymlinks.html">ossymlinks</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>
  121. </dl>
  122. </div>
  123. <div class="section" id="7">
  124. <h1><a class="toc-backref" href="#7">Types</a></h1>
  125. <dl class="item">
  126. <div id="CopyFlag">
  127. <dt><pre><a href="osfiles.html#CopyFlag"><span class="Identifier">CopyFlag</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  128. <span class="Identifier">cfSymlinkAsIs</span><span class="Other">,</span> <span class="Comment">## Copy symlinks as symlinks</span>
  129. <span class="Identifier">cfSymlinkFollow</span><span class="Other">,</span> <span class="Comment">## Copy the files symlinks point to</span>
  130. <span class="Identifier">cfSymlinkIgnore</span> <span class="Comment">## Ignore symlinks</span></pre></dt>
  131. <dd>
  132. Copy options.
  133. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L169" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  134. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L169" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  135. </dd>
  136. </div>
  137. <div id="FilePermission">
  138. <dt><pre><a href="osfiles.html#FilePermission"><span class="Identifier">FilePermission</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  139. <span class="Identifier">fpUserExec</span><span class="Other">,</span> <span class="Comment">## execute access for the file owner</span>
  140. <span class="Identifier">fpUserWrite</span><span class="Other">,</span> <span class="Comment">## write access for the file owner</span>
  141. <span class="Identifier">fpUserRead</span><span class="Other">,</span> <span class="Comment">## read access for the file owner</span>
  142. <span class="Identifier">fpGroupExec</span><span class="Other">,</span> <span class="Comment">## execute access for the group</span>
  143. <span class="Identifier">fpGroupWrite</span><span class="Other">,</span> <span class="Comment">## write access for the group</span>
  144. <span class="Identifier">fpGroupRead</span><span class="Other">,</span> <span class="Comment">## read access for the group</span>
  145. <span class="Identifier">fpOthersExec</span><span class="Other">,</span> <span class="Comment">## execute access for others</span>
  146. <span class="Identifier">fpOthersWrite</span><span class="Other">,</span> <span class="Comment">## write access for others</span>
  147. <span class="Identifier">fpOthersRead</span> <span class="Comment">## read access for others</span></pre></dt>
  148. <dd>
  149. <p>File access permission, modelled after UNIX.</p>
  150. <p>See also:</p>
  151. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFilePermissions(filename: string): set[FilePermission]" href="#getFilePermissions,string">getFilePermissions</a></li>
  152. <li><a class="reference internal nimdoc" title="proc setFilePermissions(filename: string; permissions: set[FilePermission];
  153. followSymlinks = true)" href="#setFilePermissions,string,set[FilePermission]">setFilePermissions</a></li>
  154. <li><a class="reference external" href="./os.html#FileInfo">os: FileInfo object</a></li>
  155. </ul>
  156. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L44" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  157. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L44" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  158. </dd>
  159. </div>
  160. </dl>
  161. </div>
  162. <div class="section" id="12">
  163. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  164. <dl class="item">
  165. <div id="copyFile-procs-all">
  166. <div id="copyFile,string,string,int">
  167. <dt><pre><span class="Keyword">proc</span> <a href="#copyFile%2Cstring%2Cstring%2Cint"><span class="Identifier">copyFile</span></a><span class="Other">(</span><span class="Identifier">source</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 class="Identifier">options</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">cfSymlinkFollow</span><span class="Other">}</span><span class="Other">;</span>
  168. <span class="Identifier">bufferSize</span> <span class="Other">=</span> <span class="DecNumber">16384</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;nos$1&quot;</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
  169. <a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">,</span> <a href="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</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="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
  170. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  171. <dd>
  172. <p>Copies a file from <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt>, where <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span><span class="Operator">.</span><span class="Identifier">parentDir</span></span></tt> must exist.</p>
  173. <p>On non-Windows OSes, <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> specify the way file is copied; by default, if <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> is a symlink, copies the file symlink points to. <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> is ignored on Windows: symlinks are skipped.</p>
  174. <p>If this fails, <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised.</p>
  175. <p>On the Windows platform this proc will copy the source file's attributes into dest.</p>
  176. <p>On other platforms you need to use <a class="reference internal nimdoc" title="proc getFilePermissions(filename: string): set[FilePermission]" href="#getFilePermissions,string">getFilePermissions</a> and <a class="reference internal nimdoc" title="proc setFilePermissions(filename: string; permissions: set[FilePermission];
  177. followSymlinks = true)" href="#setFilePermissions,string,set[FilePermission]">setFilePermissions</a> procs to copy them by hand (or use the convenience <a class="reference internal nimdoc" title="proc copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  178. options = {cfSymlinkFollow})" href="#copyFileWithPermissions,string,string">copyFileWithPermissions proc</a>), otherwise <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> will inherit the default permissions of a newly created file for the user.</p>
  179. <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> already exists, the file attributes will be preserved and the content overwritten.</p>
  180. <p>On OSX, <tt class="docutils literal"><span class="pre"><span class="Identifier">copyfile</span></span></tt> C api will be used (available since OSX 10.5) unless <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">nimLegacyCopyFile</span></span></tt> is used.</p>
  181. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">copyFile</span></span></tt> allows to specify <tt class="docutils literal"><span class="pre"><span class="Identifier">bufferSize</span></span></tt> to improve I/O performance.</p>
  182. <p>See also:</p>
  183. <ul class="simple"><li><a class="reference internal nimdoc" title="enum CopyFlag" href="#CopyFlag">CopyFlag enum</a></li>
  184. <li><a class="reference external" href="./osdirs.html#copyDir,string,string">osdirs: copyDir proc</a></li>
  185. <li><a class="reference internal nimdoc" title="proc copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  186. options = {cfSymlinkFollow})" href="#copyFileWithPermissions,string,string">copyFileWithPermissions proc</a></li>
  187. <li><a class="reference internal nimdoc" title="proc tryRemoveFile(file: string): bool" href="#tryRemoveFile,string">tryRemoveFile proc</a></li>
  188. <li><a class="reference internal nimdoc" title="proc removeFile(file: string)" href="#removeFile,string">removeFile proc</a></li>
  189. <li><a class="reference internal nimdoc" title="proc moveFile(source, dest: string)" href="#moveFile,string,string">moveFile proc</a></li>
  190. </ul>
  191. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L176" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  192. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L176" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  193. </dd>
  194. </div>
  195. </div>
  196. <div id="copyFileToDir-procs-all">
  197. <div id="copyFileToDir,string,string,int">
  198. <dt><pre><span class="Keyword">proc</span> <a href="#copyFileToDir%2Cstring%2Cstring%2Cint"><span class="Identifier">copyFileToDir</span></a><span class="Other">(</span><span class="Identifier">source</span><span class="Other">,</span> <span class="Identifier">dir</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">options</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">cfSymlinkFollow</span><span class="Other">}</span><span class="Other">;</span>
  199. <span class="Identifier">bufferSize</span> <span class="Other">=</span> <span class="DecNumber">16384</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">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
  200. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</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>
  201. <dd>
  202. <p>Copies a file <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> into directory <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt>, which must exist.</p>
  203. <p>On non-Windows OSes, <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> specify the way file is copied; by default, if <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> is a symlink, copies the file symlink points to. <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> is ignored on Windows: symlinks are skipped.</p>
  204. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">copyFileToDir</span></span></tt> allows to specify <tt class="docutils literal"><span class="pre"><span class="Identifier">bufferSize</span></span></tt> to improve I/O performance.</p>
  205. <p>See also:</p>
  206. <ul class="simple"><li><a class="reference internal nimdoc" title="enum CopyFlag" href="#CopyFlag">CopyFlag enum</a></li>
  207. <li><a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a></li>
  208. </ul>
  209. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L270" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  210. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L270" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  211. </dd>
  212. </div>
  213. </div>
  214. <div id="copyFileWithPermissions-procs-all">
  215. <div id="copyFileWithPermissions,string,string">
  216. <dt><pre><span class="Keyword">proc</span> <a href="#copyFileWithPermissions%2Cstring%2Cstring"><span class="Identifier">copyFileWithPermissions</span></a><span class="Other">(</span><span class="Identifier">source</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>
  217. <span class="Identifier">ignorePermissionErrors</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
  218. <span class="Identifier">options</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">cfSymlinkFollow</span><span class="Other">}</span><span class="Other">)</span> {.
  219. <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="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
  220. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteDirEffect</span><span class="Other">]</span><span class="Other">,</span>
  221. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  222. <dd>
  223. <p>Copies a file from <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> preserving file permissions.</p>
  224. <p>On non-Windows OSes, <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> specify the way file is copied; by default, if <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> is a symlink, copies the file symlink points to. <tt class="docutils literal"><span class="pre"><span class="Identifier">options</span></span></tt> is ignored on Windows: symlinks are skipped.</p>
  225. <p>This is a wrapper proc around <a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile</a>, <a class="reference internal nimdoc" title="proc getFilePermissions(filename: string): set[FilePermission]" href="#getFilePermissions,string">getFilePermissions</a> and <a class="reference internal nimdoc" title="proc setFilePermissions(filename: string; permissions: set[FilePermission];
  226. followSymlinks = true)" href="#setFilePermissions,string,set[FilePermission]">setFilePermissions</a> procs on non-Windows platforms.</p>
  227. <p>On Windows this proc is just a wrapper for <a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a> since that proc already copies attributes.</p>
  228. <p>On non-Windows systems permissions are copied after the file itself has been copied, which won't happen atomically and could lead to a race condition. If <tt class="docutils literal"><span class="pre"><span class="Identifier">ignorePermissionErrors</span></span></tt> is true (default), errors while reading/setting file attributes will be ignored, otherwise will raise <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt>.</p>
  229. <p>See also:</p>
  230. <ul class="simple"><li><a class="reference internal nimdoc" title="enum CopyFlag" href="#CopyFlag">CopyFlag enum</a></li>
  231. <li><a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a></li>
  232. <li><a class="reference external" href="./osdirs.html#copyDir,string,string">osdirs: copyDir proc</a></li>
  233. <li><a class="reference internal nimdoc" title="proc tryRemoveFile(file: string): bool" href="#tryRemoveFile,string">tryRemoveFile proc</a></li>
  234. <li><a class="reference internal nimdoc" title="proc removeFile(file: string)" href="#removeFile,string">removeFile proc</a></li>
  235. <li><a class="reference internal nimdoc" title="proc moveFile(source, dest: string)" href="#moveFile,string,string">moveFile proc</a></li>
  236. <li><a class="reference external" href="./osdirs.html#copyDirWithPermissions,string,string">osdirs: copyDirWithPermissions proc</a></li>
  237. </ul>
  238. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L288" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  239. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L288" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  240. </dd>
  241. </div>
  242. </div>
  243. <div id="getFilePermissions-procs-all">
  244. <div id="getFilePermissions,string">
  245. <dt><pre><span class="Keyword">proc</span> <a href="#getFilePermissions%2Cstring"><span class="Identifier">getFilePermissions</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#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><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  246. <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><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>
  247. <dd>
  248. <p>Retrieves file permissions for <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.</p>
  249. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised in case of an error. On Windows, only the <tt class="docutils literal"><span class="pre">readonly</span></tt> flag is checked, every other permission is available in any case.</p>
  250. <p>See also:</p>
  251. <ul class="simple"><li><a class="reference internal nimdoc" title="proc setFilePermissions(filename: string; permissions: set[FilePermission];
  252. followSymlinks = true)" href="#setFilePermissions,string,set[FilePermission]">setFilePermissions proc</a></li>
  253. <li><a class="reference internal nimdoc" title="enum FilePermission" href="#FilePermission">FilePermission enum</a></li>
  254. </ul>
  255. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L60" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  256. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L60" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  257. </dd>
  258. </div>
  259. </div>
  260. <div id="moveFile-procs-all">
  261. <div id="moveFile,string,string">
  262. <dt><pre><span class="Keyword">proc</span> <a href="#moveFile%2Cstring%2Cstring"><span class="Identifier">moveFile</span></a><span class="Other">(</span><span class="Identifier">source</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">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>
  263. <a href="oscommon.html#ReadDirEffect"><span class="Identifier">ReadDirEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">,</span> <a href="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</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="Identifier">IOError</span><span class="Other">,</span>
  264. <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">Exception</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>
  265. <dd>
  266. <p>Moves a file from <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt>.</p>
  267. <p>Symlinks are not followed: if <tt class="docutils literal"><span class="pre"><span class="Identifier">source</span></span></tt> is a symlink, it is itself moved, not its target.</p>
  268. <p>If this fails, <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised. If <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> already exists, it will be overwritten.</p>
  269. <p>Can be used to <span id="rename-files_1">rename files</span>.</p>
  270. <p>See also:</p>
  271. <ul class="simple"><li><a class="reference external" href="./osdirs.html#moveDir,string,string">osdirs: moveDir proc</a></li>
  272. <li><a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a></li>
  273. <li><a class="reference internal nimdoc" title="proc copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  274. options = {cfSymlinkFollow})" href="#copyFileWithPermissions,string,string">copyFileWithPermissions proc</a></li>
  275. <li><a class="reference internal nimdoc" title="proc removeFile(file: string)" href="#removeFile,string">removeFile proc</a></li>
  276. <li><a class="reference internal nimdoc" title="proc tryRemoveFile(file: string): bool" href="#tryRemoveFile,string">tryRemoveFile proc</a></li>
  277. </ul>
  278. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L387" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  279. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L387" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  280. </dd>
  281. </div>
  282. </div>
  283. <div id="removeFile-procs-all">
  284. <div id="removeFile,string">
  285. <dt><pre><span class="Keyword">proc</span> <a href="#removeFile%2Cstring"><span class="Identifier">removeFile</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><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#WriteDirEffect"><span class="Identifier">WriteDirEffect</span></a><span class="Other">]</span><span class="Other">,</span>
  286. <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>
  287. <dd>
  288. <p>Removes the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>.</p>
  289. <p>If this fails, <tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised. This does not fail if the file never existed in the first place.</p>
  290. <p>On Windows, ignores the read-only attribute.</p>
  291. <p>See also:</p>
  292. <ul class="simple"><li><a class="reference external" href="./osdirs.html#removeDir,string">osdirs: removeDir proc</a></li>
  293. <li><a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a></li>
  294. <li><a class="reference internal nimdoc" title="proc copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  295. options = {cfSymlinkFollow})" href="#copyFileWithPermissions,string,string">copyFileWithPermissions proc</a></li>
  296. <li><a class="reference internal nimdoc" title="proc tryRemoveFile(file: string): bool" href="#tryRemoveFile,string">tryRemoveFile proc</a></li>
  297. <li><a class="reference internal nimdoc" title="proc moveFile(source, dest: string)" href="#moveFile,string,string">moveFile proc</a></li>
  298. </ul>
  299. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L370" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  300. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L370" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  301. </dd>
  302. </div>
  303. </div>
  304. <div id="setFilePermissions-procs-all">
  305. <div id="setFilePermissions,string,set[FilePermission]">
  306. <dt><pre><span class="Keyword">proc</span> <a href="#setFilePermissions%2Cstring%2Cset%5BFilePermission%5D"><span class="Identifier">setFilePermissions</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>
  307. <span class="Identifier">followSymlinks</span> <span class="Other">=</span> <span class="Identifier">true</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;nos$1&quot;</span><span class="Other">,</span>
  308. <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> <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>
  309. <dd>
  310. <p>Sets the file permissions for <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.</p>
  311. <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">followSymlinks</span></span></tt> set to true (default) and <tt class="docutils literal"><span class="pre">filename</span></tt> points to a symlink, permissions are set to the file symlink points to. <tt class="docutils literal"><span class="pre"><span class="Identifier">followSymlinks</span></span></tt> set to false is a noop on Windows and some POSIX systems (including Linux) on which <tt class="docutils literal"><span class="pre"><span class="Identifier">lchmod</span></span></tt> is either unavailable or always fails, given that symlinks permissions there are not observed.</p>
  312. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">OSError</span></span></tt> is raised in case of an error. On Windows, only the <tt class="docutils literal"><span class="pre">readonly</span></tt> flag is changed, depending on <tt class="docutils literal"><span class="pre">fpUserWrite</span></tt> permission.</p>
  313. <p>See also:</p>
  314. <ul class="simple"><li><a class="reference internal nimdoc" title="proc getFilePermissions(filename: string): set[FilePermission]" href="#getFilePermissions,string">getFilePermissions proc</a></li>
  315. <li><a class="reference internal nimdoc" title="enum FilePermission" href="#FilePermission">FilePermission enum</a></li>
  316. </ul>
  317. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L95" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  318. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L95" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  319. </dd>
  320. </div>
  321. </div>
  322. <div id="tryRemoveFile-procs-all">
  323. <div id="tryRemoveFile,string">
  324. <dt><pre><span class="Keyword">proc</span> <a href="#tryRemoveFile%2Cstring"><span class="Identifier">tryRemoveFile</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="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>
  325. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="oscommon.html#WriteDirEffect"><span class="Identifier">WriteDirEffect</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>
  326. <dd>
  327. <p>Removes the <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>.</p>
  328. <p>If this fails, returns <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt>. This does not fail if the file never existed in the first place.</p>
  329. <p>On Windows, ignores the read-only attribute.</p>
  330. <p>See also:</p>
  331. <ul class="simple"><li><a class="reference internal nimdoc" title="proc copyFile(source, dest: string; options = {cfSymlinkFollow}; bufferSize = 16384)" href="#copyFile,string,string,int">copyFile proc</a></li>
  332. <li><a class="reference internal nimdoc" title="proc copyFileWithPermissions(source, dest: string; ignorePermissionErrors = true;
  333. options = {cfSymlinkFollow})" href="#copyFileWithPermissions,string,string">copyFileWithPermissions proc</a></li>
  334. <li><a class="reference internal nimdoc" title="proc removeFile(file: string)" href="#removeFile,string">removeFile proc</a></li>
  335. <li><a class="reference internal nimdoc" title="proc moveFile(source, dest: string)" href="#moveFile,string,string">moveFile proc</a></li>
  336. </ul>
  337. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/osfiles.nim#L341" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  338. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/osfiles.nim#L341" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  339. </dd>
  340. </div>
  341. </div>
  342. </dl>
  343. </div>
  344. </div>
  345. </div>
  346. <div class="twelve-columns footer">
  347. <span class="nim-sprite"></span>
  348. <br>
  349. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:27 UTC</small>
  350. </div>
  351. </div>
  352. </div>
  353. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  354. </body>
  355. </html>