Files
Nim/syncio.html
github-actions[bot] ef3d9e7b38 Deploy to GitHub pages
2025-12-28 15:55:52 +00:00

1014 lines
110 KiB
HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>std/syncio</title>
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- Favicon -->
<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=="/>
<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=">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
<!-- JS -->
<script type="text/javascript" src="dochack.js?v=2.3.1"></script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">std/syncio</h1>
<div class="row">
<div class="three columns">
<div class="theme-select-wrapper">
<label for="theme-select">Theme:&nbsp;</label>
<select id="theme-select" onchange="setTheme(this.value)">
<option value="auto">🌗 Match OS</option>
<option value="dark">🌑 Dark</option>
<option value="light">🌕 Light</option>
</select>
</div>
<div id="global-links">
<ul class="simple-boot">
<li><a href="manual.html">Manual</a></li>
<li><a href="lib.html">Standard library</a></li>
<li> <a id="indexLink" href="theindex.html">Index</a></li>
<li><a href="compiler/theindex.html">Compiler docs</a></li>
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="search" id="searchInput"
oninput="search()" />
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#File" title="File = ptr CFile">File</a></li>
<li><a class="reference" href="#FileHandle" title="FileHandle = cint">FileHandle</a></li>
<li><a class="reference" href="#FileMode" title="FileMode = enum
fmRead, ## Open the file for read access only.
## If the file does not exist, it will not
## be created.
fmWrite, ## Open the file for write access only.
## If the file does not exist, it will be
## created. Existing files will be cleared!
fmReadWrite, ## Open the file for read and write access.
## If the file does not exist, it will be
## created. Existing files will be cleared!
fmReadWriteExisting, ## Open the file for read and write access.
## If the file does not exist, it will not be
## created. The existing file will not be cleared.
fmAppend ## Open the file for writing only; append data
## at the end. If the file does not exist, it
## will be created.">FileMode</a></li>
<li><a class="reference" href="#FileSeekPos" title="FileSeekPos = enum
fspSet, ## Seek to absolute value
fspCur, ## Seek relative to current position
fspEnd ## Seek relative to end">FileSeekPos</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#8" id="58">Vars</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#stderr" title="stderr {.importc: &quot;stderr&quot;, header: &quot;&lt;stdio.h&gt;&quot;.}: File">stderr</a></li>
<li><a class="reference" href="#stdin" title="stdin {.importc: &quot;stdin&quot;, header: &quot;&lt;stdio.h&gt;&quot;.}: File">stdin</a></li>
<li><a class="reference" href="#stdout" title="stdout {.importc: &quot;stdout&quot;, header: &quot;&lt;stdio.h&gt;&quot;.}: File">stdout</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">close
<li><a class="reference" href="#close%2CFile" title="close(f: File)">close(f: File)</a></li>
</ul>
<ul class="simple nested-toc-section">endOfFile
<li><a class="reference" href="#endOfFile%2CFile" title="endOfFile(f: File): bool">endOfFile(f: File): bool</a></li>
</ul>
<ul class="simple nested-toc-section">flushFile
<li><a class="reference" href="#flushFile%2CFile" title="flushFile(f: File)">flushFile(f: File)</a></li>
</ul>
<ul class="simple nested-toc-section">getFileHandle
<li><a class="reference" href="#getFileHandle%2CFile" title="getFileHandle(f: File): FileHandle">getFileHandle(f: File): FileHandle</a></li>
</ul>
<ul class="simple nested-toc-section">getFilePos
<li><a class="reference" href="#getFilePos%2CFile" title="getFilePos(f: File): int64">getFilePos(f: File): int64</a></li>
</ul>
<ul class="simple nested-toc-section">getFileSize
<li><a class="reference" href="#getFileSize%2CFile" title="getFileSize(f: File): int64">getFileSize(f: File): int64</a></li>
</ul>
<ul class="simple nested-toc-section">getOsFileHandle
<li><a class="reference" href="#getOsFileHandle%2CFile" title="getOsFileHandle(f: File): FileHandle">getOsFileHandle(f: File): FileHandle</a></li>
</ul>
<ul class="simple nested-toc-section">open
<li><a class="reference" href="#open%2CFile%2CFileHandle%2CFileMode" title="open(f: var File; filehandle: FileHandle; mode: FileMode = fmRead): bool">open(f: var File; filehandle: FileHandle; mode: FileMode = fmRead): bool</a></li>
<li><a class="reference" href="#open%2CFile%2Cstring%2CFileMode%2Cint" title="open(f: var File; filename: string; mode: FileMode = fmRead; bufSize: int = -1): bool">open(f: var File; filename: string; mode: FileMode = fmRead; bufSize: int = -1): bool</a></li>
<li><a class="reference" href="#open%2Cstring%2CFileMode%2Cint" title="open(filename: string; mode: FileMode = fmRead; bufSize: int = -1): File">open(filename: string; mode: FileMode = fmRead; bufSize: int = -1): File</a></li>
</ul>
<ul class="simple nested-toc-section">readAll
<li><a class="reference" href="#readAll%2CFile" title="readAll(file: File): string">readAll(file: File): string</a></li>
</ul>
<ul class="simple nested-toc-section">readBuffer
<li><a class="reference" href="#readBuffer%2CFile%2Cpointer%2CNatural" title="readBuffer(f: File; buffer: pointer; len: Natural): int">readBuffer(f: File; buffer: pointer; len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">readBytes
<li><a class="reference" href="#readBytes%2CFile%2CopenArray%5B%5D%2CNatural%2CNatural" title="readBytes(f: File; a: var openArray[int8 | uint8]; start, len: Natural): int">readBytes(f: File; a: var openArray[int8 | uint8]; start, len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">readChar
<li><a class="reference" href="#readChar%2CFile" title="readChar(f: File): char">readChar(f: File): char</a></li>
</ul>
<ul class="simple nested-toc-section">readChars
<li><a class="reference" href="#readChars%2CFile%2CopenArray%5Bchar%5D" title="readChars(f: File; a: var openArray[char]): int">readChars(f: File; a: var openArray[char]): int</a></li>
<li><a class="reference" href="#readChars%2CFile%2CopenArray%5Bchar%5D%2CNatural%2CNatural" title="readChars(f: File; a: var openArray[char]; start, len: Natural): int">readChars(f: File; a: var openArray[char]; start, len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">readFile
<li><a class="reference" href="#readFile%2Cstring" title="readFile(filename: string): string">readFile(filename: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">readLine
<li><a class="reference" href="#readLine%2CFile" title="readLine(f: File): string">readLine(f: File): string</a></li>
<li><a class="reference" href="#readLine%2CFile%2Cstring" title="readLine(f: File; line: var string): bool">readLine(f: File; line: var string): bool</a></li>
</ul>
<ul class="simple nested-toc-section">readLines
<li><a class="reference" href="#readLines%2Cstring%2CNatural" title="readLines(filename: string; n: Natural): seq[string]">readLines(filename: string; n: Natural): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">reopen
<li><a class="reference" href="#reopen%2CFile%2Cstring%2CFileMode" title="reopen(f: File; filename: string; mode: FileMode = fmRead): bool">reopen(f: File; filename: string; mode: FileMode = fmRead): bool</a></li>
</ul>
<ul class="simple nested-toc-section">setFilePos
<li><a class="reference" href="#setFilePos%2CFile%2Cint64%2CFileSeekPos" title="setFilePos(f: File; pos: int64; relativeTo: FileSeekPos = fspSet)">setFilePos(f: File; pos: int64; relativeTo: FileSeekPos = fspSet)</a></li>
</ul>
<ul class="simple nested-toc-section">setInheritable
<li><a class="reference" href="#setInheritable%2CFileHandle%2Cbool" title="setInheritable(f: FileHandle; inheritable: bool): bool">setInheritable(f: FileHandle; inheritable: bool): bool</a></li>
</ul>
<ul class="simple nested-toc-section">setStdIoUnbuffered
<li><a class="reference" href="#setStdIoUnbuffered" title="setStdIoUnbuffered()">setStdIoUnbuffered()</a></li>
</ul>
<ul class="simple nested-toc-section">write
<li><a class="reference" href="#write%2CFile%2Cvarargs%5Bstring%2C%5D" title="write(f: File; a: varargs[string, `$`])">write(f: File; a: varargs[string, `$`])</a></li>
<li><a class="reference" href="#write%2CFile%2Cbool" title="write(f: File; b: bool)">write(f: File; b: bool)</a></li>
<li><a class="reference" href="#write%2CFile%2Cchar" title="write(f: File; c: char)">write(f: File; c: char)</a></li>
<li><a class="reference" href="#write%2CFile%2Ccstring" title="write(f: File; c: cstring)">write(f: File; c: cstring)</a></li>
<li><a class="reference" href="#write%2CFile%2CBiggestInt" title="write(f: File; i: BiggestInt)">write(f: File; i: BiggestInt)</a></li>
<li><a class="reference" href="#write%2CFile%2Cint" title="write(f: File; i: int)">write(f: File; i: int)</a></li>
<li><a class="reference" href="#write%2CFile%2CBiggestFloat" title="write(f: File; r: BiggestFloat)">write(f: File; r: BiggestFloat)</a></li>
<li><a class="reference" href="#write%2CFile%2Cfloat32" title="write(f: File; r: float32)">write(f: File; r: float32)</a></li>
<li><a class="reference" href="#write%2CFile%2Cstring" title="write(f: File; s: string)">write(f: File; s: string)</a></li>
</ul>
<ul class="simple nested-toc-section">writeBuffer
<li><a class="reference" href="#writeBuffer%2CFile%2Cpointer%2CNatural" title="writeBuffer(f: File; buffer: pointer; len: Natural): int">writeBuffer(f: File; buffer: pointer; len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">writeBytes
<li><a class="reference" href="#writeBytes%2CFile%2CopenArray%5B%5D%2CNatural%2CNatural" title="writeBytes(f: File; a: openArray[int8 | uint8]; start, len: Natural): int">writeBytes(f: File; a: openArray[int8 | uint8]; start, len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">writeChars
<li><a class="reference" href="#writeChars%2CFile%2CopenArray%5Bchar%5D%2CNatural%2CNatural" title="writeChars(f: File; a: openArray[char]; start, len: Natural): int">writeChars(f: File; a: openArray[char]; start, len: Natural): int</a></li>
</ul>
<ul class="simple nested-toc-section">writeFile
<li><a class="reference" href="#writeFile%2Cstring%2Cstring" title="writeFile(filename, content: string)">writeFile(filename, content: string)</a></li>
<li><a class="reference" href="#writeFile%2Cstring%2CopenArray%5Bbyte%5D" title="writeFile(filename: string; content: openArray[byte])">writeFile(filename: string; content: openArray[byte])</a></li>
</ul>
<ul class="simple nested-toc-section">writeLine
<li><a class="reference" href="#writeLine%2CFile%2Cvarargs%5BTy%2C%5D" title="writeLine[Ty](f: File; x: varargs[Ty, `$`])">writeLine[Ty](f: File; x: varargs[Ty, `$`])</a></li>
</ul>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">lines
<li><a class="reference" href="#lines.i%2CFile" title="lines(f: File): string">lines(f: File): string</a></li>
<li><a class="reference" href="#lines.i%2Cstring" title="lines(filename: string): string">lines(filename: string): string</a></li>
</ul>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">&=
<li><a class="reference" href="#%26%3D.t%2CFile%2Ctyped" title="`&amp;=`(f: File; x: typed)">`&amp;=`(f: File; x: typed)</a></li>
</ul>
<ul class="simple nested-toc-section">readLines
<li><a class="reference" href="#readLines.t%2Cstring" title="readLines(filename: string): seq[string]">readLines(filename: string): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">stdmsg
<li><a class="reference" href="#stdmsg.t" title="stdmsg(): File">stdmsg(): File</a></li>
</ul>
</ul>
</details>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
<div id="tocRoot"></div>
<p class="module-desc">This module implements various synchronized I/O operations.</p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="since.html">since</a>, <a class="reference external" href="formatfloat.html">formatfloat</a>, <a class="reference external" href="ansi_c.html">ansi_c</a>
</dl>
</div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="File">
<dt><pre><a href="syncio.html#File"><span class="Identifier">File</span></a> <span class="Other">=</span> <span class="Keyword">ptr</span> <span class="Identifier">CFile</span></pre></dt>
<dd>
The type representing a file handle.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L24" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L24" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="FileHandle">
<dt><pre><a href="syncio.html#FileHandle"><span class="Identifier">FileHandle</span></a> <span class="Other">=</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a></pre></dt>
<dd>
The type that represents an OS file handle; this is useful for low-level file access.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L54" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L54" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="FileMode">
<dt><pre><a href="syncio.html#FileMode"><span class="Identifier">FileMode</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">fmRead</span><span class="Other">,</span> <span class="Comment">## Open the file for read access only.</span>
<span class="Comment">## If the file does not exist, it will not</span>
<span class="Comment">## be created.</span>
<span class="Identifier">fmWrite</span><span class="Other">,</span> <span class="Comment">## Open the file for write access only.</span>
<span class="Comment">## If the file does not exist, it will be</span>
<span class="Comment">## created. Existing files will be cleared!</span>
<span class="Identifier">fmReadWrite</span><span class="Other">,</span> <span class="Comment">## Open the file for read and write access.</span>
<span class="Comment">## If the file does not exist, it will be</span>
<span class="Comment">## created. Existing files will be cleared!</span>
<span class="Identifier">fmReadWriteExisting</span><span class="Other">,</span> <span class="Comment">## Open the file for read and write access.</span>
<span class="Comment">## If the file does not exist, it will not be</span>
<span class="Comment">## created. The existing file will not be cleared.</span>
<span class="Identifier">fmAppend</span> <span class="Comment">## Open the file for writing only; append data</span>
<span class="Comment">## at the end. If the file does not exist, it</span>
<span class="Comment">## will be created.</span></pre></dt>
<dd>
The file mode when opening a file.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L26" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L26" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="FileSeekPos">
<dt><pre><a href="syncio.html#FileSeekPos"><span class="Identifier">FileSeekPos</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">fspSet</span><span class="Other">,</span> <span class="Comment">## Seek to absolute value</span>
<span class="Identifier">fspCur</span><span class="Other">,</span> <span class="Comment">## Seek relative to current position</span>
<span class="Identifier">fspEnd</span> <span class="Comment">## Seek relative to end</span></pre></dt>
<dd>
Position relative to which seek should happen.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L43" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L43" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</dl>
</div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<div id="stderr">
<dt><pre><a href="syncio.html#stderr"><span class="Identifier">stderr</span></a> {.<span class="Identifier">importc</span><span class="Other">:</span> <span class="StringLit">&quot;stderr&quot;</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">&quot;&lt;stdio.h&gt;&quot;</span>.}<span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a></pre></dt>
<dd>
The standard error stream.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L71" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L71" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="stdin">
<dt><pre><a href="syncio.html#stdin"><span class="Identifier">stdin</span></a> {.<span class="Identifier">importc</span><span class="Other">:</span> <span class="StringLit">&quot;stdin&quot;</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">&quot;&lt;stdio.h&gt;&quot;</span>.}<span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a></pre></dt>
<dd>
The standard input stream.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L67" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L67" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="stdout">
<dt><pre><a href="syncio.html#stdout"><span class="Identifier">stdout</span></a> {.<span class="Identifier">importc</span><span class="Other">:</span> <span class="StringLit">&quot;stdout&quot;</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">&quot;&lt;stdio.h&gt;&quot;</span>.}<span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a></pre></dt>
<dd>
The standard output stream.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L69" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L69" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</dl>
</div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="close-procs-all">
<div id="close,File">
<dt><pre><span class="Keyword">proc</span> <a href="#close%2CFile"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> </span><span class="Identifier">sideEffect</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">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Closes the file.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L340" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L340" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="endOfFile-procs-all">
<div id="endOfFile,File">
<dt><pre><span class="Keyword">proc</span> <a href="#endOfFile%2CFile"><span class="Identifier">endOfFile</span></a><span class="Other">(</span><span class="Identifier">f</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="system.html#bool"><span class="Identifier">bool</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><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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>
<dd>
Returns true if <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> is at the end.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L582" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L582" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="flushFile-procs-all">
<div id="flushFile,File">
<dt><pre><span class="Keyword">proc</span> <a href="#flushFile%2CFile"><span class="Identifier">flushFile</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">)</span> {.<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="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="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>
<dd>
Flushes <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>'s buffer.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L353" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L353" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="getFileHandle-procs-all">
<div id="getFileHandle,File">
<dt><pre><span class="Keyword">proc</span> <a href="#getFileHandle%2CFile"><span class="Identifier">getFileHandle</span></a><span class="Other">(</span><span class="Identifier">f</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="syncio.html#FileHandle"><span class="Identifier">FileHandle</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>
<dd>
Returns the file handle of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. This is only useful for platform specific programming. Note that on Windows this doesn't return the Windows-specific handle, but the C library's notion of a handle, whatever that means. Use <tt class="docutils literal"><span class="pre"><span class="Identifier">getOsFileHandle</span></span></tt> instead.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L357" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L357" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="getFilePos-procs-all">
<div id="getFilePos,File">
<dt><pre><span class="Keyword">proc</span> <a href="#getFilePos%2CFile"><span class="Identifier">getFilePos</span></a><span class="Other">(</span><span class="Identifier">f</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="system.html#int64"><span class="Identifier">int64</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</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="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>
<dd>
Retrieves the current position of the file pointer that is used to read from the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. The file's first byte has the index zero.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L801" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L801" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="getFileSize-procs-all">
<div id="getFileSize,File">
<dt><pre><span class="Keyword">proc</span> <a href="#getFileSize%2CFile"><span class="Identifier">getFileSize</span></a><span class="Other">(</span><span class="Identifier">f</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="system.html#int64"><span class="Identifier">int64</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="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Retrieves the file size (in bytes) of <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L807" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L807" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="getOsFileHandle-procs-all">
<div id="getOsFileHandle,File">
<dt><pre><span class="Keyword">proc</span> <a href="#getOsFileHandle%2CFile"><span class="Identifier">getOsFileHandle</span></a><span class="Other">(</span><span class="Identifier">f</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="syncio.html#FileHandle"><span class="Identifier">FileHandle</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>
<dd>
Returns the OS file handle of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. This is only useful for platform specific programming.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L365" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L365" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="open-procs-all">
<div id="open,File,FileHandle,FileMode">
<dt><pre><span class="Keyword">proc</span> <a href="#open%2CFile%2CFileHandle%2CFileMode"><span class="Identifier">open</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">filehandle</span><span class="Other">:</span> <a href="syncio.html#FileHandle"><span class="Identifier">FileHandle</span></a><span class="Other">;</span> <span class="Identifier">mode</span><span class="Other">:</span> <a href="syncio.html#FileMode"><span class="Identifier">FileMode</span></a> <span class="Other">=</span> <span class="Identifier">fmRead</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">tags</span><span class="Other">:</span> <span class="Other">[</span><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">gcsafe</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>
<dd>
<p>Creates a <tt class="docutils literal"><span class="pre"><span class="Identifier">File</span></span></tt> from a <tt class="docutils literal"><span class="pre"><span class="Identifier">filehandle</span></span></tt> with given <tt class="docutils literal"><span class="pre"><span class="Identifier">mode</span></span></tt>.</p>
<p>Default mode is readonly. Returns true if the file could be opened.</p>
<p>The passed file handle will no longer be inheritable.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L768" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L768" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="open,File,string,FileMode,int">
<dt><pre><span class="Keyword">proc</span> <a href="#open%2CFile%2Cstring%2CFileMode%2Cint"><span class="Identifier">open</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="syncio.html#File"><span class="Identifier">File</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">mode</span><span class="Other">:</span> <a href="syncio.html#FileMode"><span class="Identifier">FileMode</span></a> <span class="Other">=</span> <span class="Identifier">fmRead</span><span class="Other">;</span>
<span class="Identifier">bufSize</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Other">=</span> <span class="DecNumber">-1</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">tags</span><span class="Other">:</span> <span class="Other">[</span><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">gcsafe</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>
<dd>
<p>Opens a file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> with given <tt class="docutils literal"><span class="pre"><span class="Identifier">mode</span></span></tt>.</p>
<p>Default mode is readonly. Returns true if the file could be opened. This throws no exception if the file could not be opened.</p>
<p>The file handle associated with the resulting <tt class="docutils literal"><span class="pre"><span class="Identifier">File</span></span></tt> is not inheritable.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L714" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L714" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="open,string,FileMode,int">
<dt><pre><span class="Keyword">proc</span> <a href="#open%2Cstring%2CFileMode%2Cint"><span class="Identifier">open</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">mode</span><span class="Other">:</span> <a href="syncio.html#FileMode"><span class="Identifier">FileMode</span></a> <span class="Other">=</span> <span class="Identifier">fmRead</span><span class="Other">;</span> <span class="Identifier">bufSize</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Other">=</span> <span class="DecNumber">-1</span><span class="Other">)</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</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="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>
<dd>
<p>Opens a file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> with given <tt class="docutils literal"><span class="pre"><span class="Identifier">mode</span></span></tt>.</p>
<p>Default mode is readonly. Raises an <tt class="docutils literal"><span class="pre"><span class="Identifier">IOError</span></span></tt> if the file could not be opened.</p>
<p>The file handle associated with the resulting <tt class="docutils literal"><span class="pre"><span class="Identifier">File</span></span></tt> is not inheritable.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L783" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L783" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readAll-procs-all">
<div id="readAll,File">
<dt><pre><span class="Keyword">proc</span> <a href="#readAll%2CFile"><span class="Identifier">readAll</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="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="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Reads all data from the stream <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>.</p>
<p>Raises an IO exception in case of an error. It is an error if the current file position is not at the beginning of the file.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L606" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L606" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readBuffer-procs-all">
<div id="readBuffer,File,pointer,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#readBuffer%2CFile%2Cpointer%2CNatural"><span class="Identifier">readBuffer</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">buffer</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Reads <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> bytes into the buffer pointed to by <tt class="docutils literal"><span class="pre"><span class="Identifier">buffer</span></span></tt>. Returns the actual number of bytes that have been read which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> (if not as many bytes are remaining), but not greater.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L184" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L184" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readBytes-procs-all">
<div id="readBytes,File,openArray[],Natural,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#readBytes%2CFile%2CopenArray%5B%5D%2CNatural%2CNatural"><span class="Identifier">readBytes</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#int8"><span class="Identifier">int8</span></a> <span class="Operator">|</span> <a href="system.html#uint8"><span class="Identifier">uint8</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span><span class="Other">,</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">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">gcsafe</span></span>.}</pre></dt>
<dd>
Reads <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> bytes into the buffer <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">start</span><span class="Punctuation">]</span></span></tt>. Returns the actual number of bytes that have been read which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> (if not as many bytes are remaining), but not greater.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L192" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L192" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readChar-procs-all">
<div id="readChar,File">
<dt><pre><span class="Keyword">proc</span> <a href="#readChar%2CFile"><span class="Identifier">readChar</span></a><span class="Other">(</span><span class="Identifier">f</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="system.html#char"><span class="Identifier">char</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="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">EOFError</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>
<dd>
Reads a single character from the stream <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. Should not be used in performance sensitive code.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L344" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L344" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readChars-procs-all">
<div id="readChars,File,openArray[char]">
<dt><pre><span class="Keyword">proc</span> <a href="#readChars%2CFile%2CopenArray%5Bchar%5D"><span class="Identifier">readChars</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</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">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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Reads up to <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">len</span></span></tt> bytes into the buffer <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>. Returns the actual number of bytes that have been read which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">len</span></span></tt> (if not as many bytes are remaining), but not greater.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L200" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L200" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="readChars,File,openArray[char],Natural,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#readChars%2CFile%2CopenArray%5Bchar%5D%2CNatural%2CNatural"><span class="Identifier">readChars</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span><span class="Other">,</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">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">gcsafe</span><span class="Other">,</span> <span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))&quot;</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<div class="deprecation-message">
<b>Deprecated:</b> use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))
</div>
Reads <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> bytes into the buffer <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">start</span><span class="Punctuation">]</span></span></tt>. Returns the actual number of bytes that have been read which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> (if not as many bytes are remaining), but not greater.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L206" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L206" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readFile-procs-all">
<div id="readFile,string">
<dt><pre><span class="Keyword">proc</span> <a href="#readFile%2Cstring"><span class="Identifier">readFile</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">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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Opens a file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> for reading, calls <a class="reference external" href="#readAll,File">readAll</a> and closes the file afterwards. Returns the string. Raises an IO exception in case of an error. If you need to call this inside a compile time macro you can use <a class="reference external" href="system.html#staticRead,string">staticRead</a>.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L868" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L868" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readLine-procs-all">
<div id="readLine,File">
<dt><pre><span class="Keyword">proc</span> <a href="#readLine%2CFile"><span class="Identifier">readLine</span></a><span class="Other">(</span><span class="Identifier">f</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="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="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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">EOFError</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>
<dd>
Reads a line of text from the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. May throw an IO exception. A line of text may be delimited by <tt class="docutils literal"><span class="pre"><span class="Identifier">LF</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">CRLF</span></span></tt>. The newline character(s) are not part of the returned string.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L522" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L522" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="readLine,File,string">
<dt><pre><span class="Keyword">proc</span> <a href="#readLine%2CFile%2Cstring"><span class="Identifier">readLine</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">line</span><span class="Other">:</span> <span class="Keyword">var</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">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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Reads a line of text from the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt>. May throw an IO exception. A line of text may be delimited by <tt class="docutils literal"><span class="pre"><span class="Identifier">LF</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">CRLF</span></span></tt>. The newline character(s) are not part of the returned string. Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> if the end of the file has been reached, <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> otherwise. If <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> is returned <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt> contains no new data.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L395" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L395" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readLines-procs-all">
<div id="readLines,string,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#readLines%2Cstring%2CNatural"><span class="Identifier">readLines</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">n</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><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">IOError</span><span class="Other">,</span> <span class="Identifier">EOFError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</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>
<dd>
Reads <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> lines from the file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>. Raises an IO exception in case of an error. Raises EOF if file does not contain at least <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> lines. Available at compile time. A line of text may be delimited by <tt class="docutils literal"><span class="pre"><span class="Identifier">LF</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">CRLF</span></span></tt>. The newline character(s) are not part of the returned strings.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L909" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L909" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="reopen-procs-all">
<div id="reopen,File,string,FileMode">
<dt><pre><span class="Keyword">proc</span> <a href="#reopen%2CFile%2Cstring%2CFileMode"><span class="Identifier">reopen</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</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">mode</span><span class="Other">:</span> <a href="syncio.html#FileMode"><span class="Identifier">FileMode</span></a> <span class="Other">=</span> <span class="Identifier">fmRead</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">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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>
<dd>
<p>Reopens the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> with given <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">mode</span></span></tt>. This is often used to redirect the <tt class="docutils literal"><span class="pre"><span class="Identifier">stdin</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">stdout</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">stderr</span></span></tt> file variables.</p>
<p>Default mode is readonly. Returns true if the file could be reopened.</p>
<p>The file handle associated with <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> won't be inheritable.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L749" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L749" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="setFilePos-procs-all">
<div id="setFilePos,File,int64,FileSeekPos">
<dt><pre><span class="Keyword">proc</span> <a href="#setFilePos%2CFile%2Cint64%2CFileSeekPos"><span class="Identifier">setFilePos</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">pos</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">;</span> <span class="Identifier">relativeTo</span><span class="Other">:</span> <a href="syncio.html#FileSeekPos"><span class="Identifier">FileSeekPos</span></a> <span class="Other">=</span> <span class="Identifier">fspSet</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><span class="Identifier">sideEffect</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">IOError</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>
<dd>
Sets the position of the file pointer that is used for read/write operations. The file's first byte has the index zero.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L795" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L795" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="setInheritable-procs-all">
<div id="setInheritable,FileHandle,bool">
<dt><pre><span class="Keyword">proc</span> <a href="#setInheritable%2CFileHandle%2Cbool"><span class="Identifier">setInheritable</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#FileHandle"><span class="Identifier">FileHandle</span></a><span class="Other">;</span> <span class="Identifier">inheritable</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</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>
<dd>
<p>Controls whether a file handle can be inherited by child processes. Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> on success. This requires the OS file handle, which can be retrieved via <a class="reference external" href="#getOsFileHandle,File">getOsFileHandle</a>.</p>
<p>This procedure is not guaranteed to be available for all platforms. Test for availability with <a class="reference external" href="system.html#declared,untyped">declared()</a>.</p>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L374" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L374" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="setStdIoUnbuffered-procs-all">
<div id="setStdIoUnbuffered">
<dt><pre><span class="Keyword">proc</span> <a href="#setStdIoUnbuffered"><span class="Identifier">setStdIoUnbuffered</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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>
<dd>
Configures <tt class="docutils literal"><span class="pre"><span class="Identifier">stdin</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">stdout</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">stderr</span></span></tt> to be unbuffered.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L814" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L814" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="write-procs-all">
<div id="write,File,varargs[string,]">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cvarargs%5Bstring%2C%5D"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</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="Operator">$</span><span class="Other">`</span><span class="Other">]</span><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L558" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L558" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,bool">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cbool"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L541" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L541" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,char">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cchar"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">c</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L555" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L555" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,cstring">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Ccstring"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">c</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Writes a value to the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. May throw an IO exception.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L216" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L216" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,BiggestInt">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2CBiggestInt"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L535" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L535" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,int">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cint"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">i</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">tags</span><span class="Other">:</span> <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">gcsafe</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="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L529" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L529" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,BiggestFloat">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2CBiggestFloat"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L550" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L550" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,float32">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cfloat32"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="system.html#float32"><span class="Identifier">float32</span></a><span class="Other">)</span> {.<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L545" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L545" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="write,File,string">
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2Cstring"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</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><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L267" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L267" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="writeBuffer-procs-all">
<div id="writeBuffer,File,pointer,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#writeBuffer%2CFile%2Cpointer%2CNatural"><span class="Identifier">writeBuffer</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">buffer</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">tags</span><span class="Other">:</span> <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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Writes the bytes of buffer pointed to by the parameter <tt class="docutils literal"><span class="pre"><span class="Identifier">buffer</span></span></tt> to the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. Returns the number of actual written bytes, which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> in case of an error.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L221" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L221" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="writeBytes-procs-all">
<div id="writeBytes,File,openArray[],Natural,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#writeBytes%2CFile%2CopenArray%5B%5D%2CNatural%2CNatural"><span class="Identifier">writeBytes</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#int8"><span class="Identifier">int8</span></a> <span class="Operator">|</span> <a href="system.html#uint8"><span class="Identifier">uint8</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span><span class="Other">,</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">tags</span><span class="Other">:</span> <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">gcsafe</span></span>.}</pre></dt>
<dd>
Writes the bytes of <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">start</span><span class="Operator">..</span><span class="Identifier">start</span><span class="Operator">+</span><span class="Identifier">len</span><span class="Operator">-</span><span class="DecNumber">1</span><span class="Punctuation">]</span></span></tt> to the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. Returns the number of actual written bytes, which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> in case of an error.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L229" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L229" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="writeChars-procs-all">
<div id="writeChars,File,openArray[char],Natural,Natural">
<dt><pre><span class="Keyword">proc</span> <a href="#writeChars%2CFile%2CopenArray%5Bchar%5D%2CNatural%2CNatural"><span class="Identifier">writeChars</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span><span class="Other">,</span> <span class="Identifier">len</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</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">tags</span><span class="Other">:</span> <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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Writes the bytes of <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">start</span><span class="Operator">..</span><span class="Identifier">start</span><span class="Operator">+</span><span class="Identifier">len</span><span class="Operator">-</span><span class="DecNumber">1</span><span class="Punctuation">]</span></span></tt> to the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>. Returns the number of actual written bytes, which may be less than <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> in case of an error.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L237" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L237" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="writeFile-procs-all">
<div id="writeFile,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#writeFile%2Cstring%2Cstring"><span class="Identifier">writeFile</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">,</span> <span class="Identifier">content</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">tags</span><span class="Other">:</span> <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">gcsafe</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="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Opens a file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> for writing. Then writes the <tt class="docutils literal"><span class="pre"><span class="Identifier">content</span></span></tt> completely to the file and closes the file afterwards. Raises an IO exception in case of an error.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L883" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L883" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="writeFile,string,openArray[byte]">
<dt><pre><span class="Keyword">proc</span> <a href="#writeFile%2Cstring%2CopenArray%5Bbyte%5D"><span class="Identifier">writeFile</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">content</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#byte"><span class="Identifier">byte</span></a><span class="Other">]</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">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</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>
<dd>
Opens a file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> for writing. Then writes the <tt class="docutils literal"><span class="pre"><span class="Identifier">content</span></span></tt> completely to the file and closes the file afterwards. Raises an IO exception in case of an error.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L896" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L896" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="writeLine-procs-all">
<div id="writeLine,File,varargs[Ty,]">
<dt><pre><span class="Keyword">proc</span> <a href="#writeLine%2CFile%2Cvarargs%5BTy%2C%5D"><span class="Identifier">writeLine</span></a><span class="Other">[</span><span class="Identifier">Ty</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Identifier">Ty</span><span class="Other">,</span> <span class="Other">`</span><span class="Operator">$</span><span class="Other">`</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
<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="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">gcsafe</span></span>.}</pre></dt>
<dd>
Writes the values <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> and then writes &quot;\n&quot;. May throw an IO exception.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L623" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L623" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
</dl>
</div>
<div class="section" id="15">
<h1><a class="toc-backref" href="#15">Iterators</a></h1>
<dl class="item">
<div id="lines-iterators-all">
<div id="lines.i,File">
<dt><pre><span class="Keyword">iterator</span> <a href="#lines.i%2CFile"><span class="Identifier">lines</span></a><span class="Other">(</span><span class="Identifier">f</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="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="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="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Iterates over any line in the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt>.</p>
<p>The trailing newline character(s) are removed from the iterated lines. </p>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">proc</span> <span class="Identifier">countZeros</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">:</span> <span class="Identifier">File</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Keyword">tuple</span><span class="Punctuation">[</span><span class="Identifier">lines</span><span class="Punctuation">,</span> <span class="Identifier">zeros</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">]</span> <span class="Operator">=</span>
<span class="Keyword">for</span> <span class="Identifier">line</span> <span class="Keyword">in</span> <span class="Identifier">filename</span><span class="Operator">.</span><span class="Identifier">lines</span><span class="Punctuation">:</span>
<span class="Keyword">for</span> <span class="Identifier">letter</span> <span class="Keyword">in</span> <span class="Identifier">line</span><span class="Punctuation">:</span>
<span class="Keyword">if</span> <span class="Identifier">letter</span> <span class="Operator">==</span> <span class="CharLit">'0'</span><span class="Punctuation">:</span>
<span class="Identifier">result</span><span class="Operator">.</span><span class="Identifier">zeros</span> <span class="Operator">+=</span> <span class="DecNumber">1</span>
<span class="Identifier">result</span><span class="Operator">.</span><span class="Identifier">lines</span> <span class="Operator">+=</span> <span class="DecNumber">1</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L951" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L951" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="lines.i,string">
<dt><pre><span class="Keyword">iterator</span> <a href="#lines.i%2Cstring"><span class="Identifier">lines</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">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">IOError</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>
<dd>
<p>Iterates over any line in the file named <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.</p>
<p>If the file does not exist <tt class="docutils literal"><span class="pre"><span class="Identifier">IOError</span></span></tt> is raised. The trailing newline character(s) are removed from the iterated lines. Example: </p>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">strutils</span>
<span class="Keyword">proc</span> <span class="Identifier">transformLetters</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span> <span class="Operator">=</span>
<span class="Keyword">var</span> <span class="Identifier">buffer</span> <span class="Operator">=</span> <span class="StringLit">&quot;&quot;</span>
<span class="Keyword">for</span> <span class="Identifier">line</span> <span class="Keyword">in</span> <span class="Identifier">filename</span><span class="Operator">.</span><span class="Identifier">lines</span><span class="Punctuation">:</span>
<span class="Identifier">buffer</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">line</span><span class="Operator">.</span><span class="Identifier">replace</span><span class="Punctuation">(</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;0&quot;</span><span class="Punctuation">)</span> <span class="Operator">&amp;</span> <span class="CharLit">'\n'</span><span class="Punctuation">)</span>
<span class="Identifier">writeFile</span><span class="Punctuation">(</span><span class="Identifier">filename</span><span class="Punctuation">,</span> <span class="Identifier">buffer</span><span class="Punctuation">)</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L930" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L930" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
</dl>
</div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<div id="&amp;=-templates-all">
<div id="&=.t,File,typed">
<dt><pre><span class="Keyword">template</span> <a href="#%26%3D.t%2CFile%2Ctyped"><span class="Identifier">`&amp;=`</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">)</span></pre></dt>
<dd>
An alias for <tt class="docutils literal"><span class="pre"><span class="Identifier">write</span></span></tt>.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L966" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L966" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="readLines-templates-all">
<div id="readLines.t,string">
<dt><pre><span class="Keyword">template</span> <a href="#readLines.t%2Cstring"><span class="Identifier">readLines</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#seq"><span class="Identifier">seq</span></a><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">deprecated</span><span class="Other">:</span> <span class="StringLit">&quot;use readLines with two arguments&quot;</span></span>.}</pre></dt>
<dd>
<div class="deprecation-message">
<b>Deprecated:</b> use readLines with two arguments
</div>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L926" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L926" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="stdmsg-templates-all">
<div id="stdmsg.t">
<dt><pre><span class="Keyword">template</span> <a href="#stdmsg.t"><span class="Identifier">stdmsg</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a></pre></dt>
<dd>
Template which expands to either stdout or stderr depending on <tt class="docutils literal"><span class="pre"><span class="Identifier">useStdoutAsStdmsg</span></span></tt> compile-time switch.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L77" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L77" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
</dl>
</div>
</div>
</div>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br>
<small style="color: var(--hint);">Made with Nim. Generated: 2025-12-28 15:55:18 UTC</small>
</div>
</div>
</div>
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
</body>
</html>