123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014 |
- <?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: </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: "stderr", header: "<stdio.h>".}: File">stderr</a></li>
- <li><a class="reference" href="#stdin" title="stdin {.importc: "stdin", header: "<stdio.h>".}: File">stdin</a></li>
- <li><a class="reference" href="#stdout" title="stdout {.importc: "stdout", header: "<stdio.h>".}: 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="`&=`(f: File; x: typed)">`&=`(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>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <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>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L24" class="link-seesrc" target="_blank" >Edit</a>
- </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#L43" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L43" class="link-seesrc" target="_blank" >Edit</a>
- </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>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L26" class="link-seesrc" target="_blank" >Edit</a>
- </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#L46" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L46" class="link-seesrc" target="_blank" >Edit</a>
- </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">"stderr"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<stdio.h>"</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#L67" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L67" class="link-seesrc" target="_blank" >Edit</a>
- </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">"stdin"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<stdio.h>"</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#L63" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L63" class="link-seesrc" target="_blank" >Edit</a>
- </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">"stdout"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<stdio.h>"</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#L65" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L65" class="link-seesrc" target="_blank" >Edit</a>
- </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#L341" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L341" class="link-seesrc" target="_blank" >Edit</a>
- </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#L577" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L577" class="link-seesrc" target="_blank" >Edit</a>
- </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#L354" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L354" class="link-seesrc" target="_blank" >Edit</a>
- </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#L358" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L358" class="link-seesrc" target="_blank" >Edit</a>
- </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#L796" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L796" class="link-seesrc" target="_blank" >Edit</a>
- </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#L802" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L802" class="link-seesrc" target="_blank" >Edit</a>
- </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#L366" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L366" class="link-seesrc" target="_blank" >Edit</a>
- </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#L763" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L763" class="link-seesrc" target="_blank" >Edit</a>
- </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#L709" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L709" class="link-seesrc" target="_blank" >Edit</a>
- </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#L778" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L778" class="link-seesrc" target="_blank" >Edit</a>
- </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#L601" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L601" class="link-seesrc" target="_blank" >Edit</a>
- </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#L180" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L180" class="link-seesrc" target="_blank" >Edit</a>
- </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#L188" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L188" class="link-seesrc" target="_blank" >Edit</a>
- </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#L345" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L345" class="link-seesrc" target="_blank" >Edit</a>
- </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#L196" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L196" class="link-seesrc" target="_blank" >Edit</a>
- </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">"use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))"</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#L202" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L202" class="link-seesrc" target="_blank" >Edit</a>
- </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#L863" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L863" class="link-seesrc" target="_blank" >Edit</a>
- </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#L517" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L517" class="link-seesrc" target="_blank" >Edit</a>
- </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#L396" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L396" class="link-seesrc" target="_blank" >Edit</a>
- </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#L904" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L904" class="link-seesrc" target="_blank" >Edit</a>
- </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#L744" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L744" class="link-seesrc" target="_blank" >Edit</a>
- </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#L790" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L790" class="link-seesrc" target="_blank" >Edit</a>
- </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#L375" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L375" class="link-seesrc" target="_blank" >Edit</a>
- </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#L809" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L809" class="link-seesrc" target="_blank" >Edit</a>
- </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#L553" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L553" class="link-seesrc" target="_blank" >Edit</a>
- </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#L536" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L536" class="link-seesrc" target="_blank" >Edit</a>
- </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#L550" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L550" class="link-seesrc" target="_blank" >Edit</a>
- </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#L212" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L212" class="link-seesrc" target="_blank" >Edit</a>
- </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#L530" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L530" class="link-seesrc" target="_blank" >Edit</a>
- </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#L524" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L524" class="link-seesrc" target="_blank" >Edit</a>
- </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#L545" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L545" class="link-seesrc" target="_blank" >Edit</a>
- </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#L540" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L540" class="link-seesrc" target="_blank" >Edit</a>
- </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#L263" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L263" class="link-seesrc" target="_blank" >Edit</a>
- </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#L217" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L217" class="link-seesrc" target="_blank" >Edit</a>
- </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#L225" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L225" class="link-seesrc" target="_blank" >Edit</a>
- </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#L233" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L233" class="link-seesrc" target="_blank" >Edit</a>
- </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#L878" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L878" class="link-seesrc" target="_blank" >Edit</a>
- </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#L891" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L891" class="link-seesrc" target="_blank" >Edit</a>
- </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 "\n". May throw an IO exception.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/syncio.nim#L618" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L618" class="link-seesrc" target="_blank" >Edit</a>
- </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#L946" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L946" class="link-seesrc" target="_blank" >Edit</a>
- </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">""</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">"a"</span><span class="Punctuation">,</span> <span class="StringLit">"0"</span><span class="Punctuation">)</span> <span class="Operator">&</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#L925" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L925" class="link-seesrc" target="_blank" >Edit</a>
- </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="&=-templates-all">
- <div id="&=.t,File,typed">
- <dt><pre><span class="Keyword">template</span> <a href="#%26%3D.t%2CFile%2Ctyped"><span class="Identifier">`&=`</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#L961" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L961" class="link-seesrc" target="_blank" >Edit</a>
- </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">"use readLines with two arguments"</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#L921" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L921" class="link-seesrc" target="_blank" >Edit</a>
- </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#L73" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/syncio.nim#L73" class="link-seesrc" target="_blank" >Edit</a>
- </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-02-06 22:28:23 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|