<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- jsextension-binaryfile.qdoc --> <title>BinaryFile Service | Qbs Manual</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td ><a href="index.html">Qbs Manual</a></td><td ><a href="list-of-builtin-services.html">List of Built-in Services</a></td><td >BinaryFile Service</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qbs 1.12.2</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <p class="naviNextPrevious headerNavi"> </p><p/> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#related-declarations">Related Declarations</a></li> <li class="level2"><a href="#binaryfile-openmode">BinaryFile.OpenMode</a></li> <li class="level1"><a href="#available-operations">Available operations</a></li> <li class="level2"><a href="#constructor">Constructor</a></li> <li class="level2"><a href="#ateof">atEof</a></li> <li class="level2"><a href="#close">close</a></li> <li class="level2"><a href="#filepath">filePath</a></li> <li class="level2"><a href="#size">size</a></li> <li class="level2"><a href="#resize">resize</a></li> <li class="level2"><a href="#pos">pos</a></li> <li class="level2"><a href="#seek">seek</a></li> <li class="level2"><a href="#read">read</a></li> <li class="level2"><a href="#write">write</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">BinaryFile Service</h1> <span class="subtitle"></span> <!-- $$$jsextension-binaryfile.html-description --> <div class="descr"> <a name="details"></a> <p>The <code>BinaryFile</code> service allows you to read from and write into binary files.</p> <a name="related-declarations"></a> <h2 id="related-declarations">Related Declarations</h2> <a name="binaryfile-openmode"></a> <h3 >BinaryFile.OpenMode</h3> <pre class="cpp"> <span class="keyword">enum</span> BinaryFile<span class="operator">.</span>OpenMode { ReadOnly<span class="operator">,</span> WriteOnly<span class="operator">,</span> ReadWrite } </pre> <p>List of modes that a file may be opened in.</p> <p>The OpenMode values can be combined with the bitwise or operator.</p> <a name="available-operations"></a> <h2 id="available-operations">Available operations</h2> <a name="constructor"></a> <h3 >Constructor</h3> <pre class="cpp"> BinaryFile(filePath: string<span class="operator">,</span> openMode: OpenMode <span class="operator">=</span> BinaryFile<span class="operator">.</span>ReadOnly) </pre> <p>Opens the file at <code>filePath</code> in the given mode and returns the object representing the file.</p> <p><b>Note: </b>The mode influences which of the operations listed below can actually be used on the file.</p><a name="ateof"></a> <h3 >atEof</h3> <pre class="cpp"> atEof(): boolean </pre> <p>Returns <code>true</code> if no more data can be read from the file, <code>false</code> otherwise.</p> <a name="close"></a> <h3 >close</h3> <pre class="cpp"> close(): <span class="type">void</span> </pre> <p>Closes the file. It is recommended to always call this function as soon as you are finished with the file, in order to keep the number of in-flight file descriptors as low as possible.</p> <a name="filepath"></a> <h3 >filePath</h3> <pre class="cpp"> filePath(): string </pre> <p>The absolute path of the file represented by this object.</p> <a name="size"></a> <h3 >size</h3> <pre class="cpp"> size(): number </pre> <p>Returns the size of the file (in bytes).</p> <a name="resize"></a> <h3 >resize</h3> <pre class="cpp"> resize(size: number): <span class="type">void</span> </pre> <p>Sets the file <code>size</code> (in bytes). If <code>size</code> is larger than the file currently is, the new bytes will be set to 0; if <code>size</code> is smaller, the file is truncated.</p> <a name="pos"></a> <h3 >pos</h3> <pre class="cpp"> pos(): number </pre> <p>Returns the position that data is written to or read from.</p> <a name="seek"></a> <h3 >seek</h3> <pre class="cpp"> seek(pos: number): <span class="type">void</span> </pre> <p>Sets the current position to <code>pos</code>.</p> <a name="read"></a> <h3 >read</h3> <pre class="cpp"> read(size: number): number<span class="operator">[</span><span class="operator">]</span> </pre> <p>Reads at most <code>size</code> bytes of data from the file and returns it as an array.</p> <a name="write"></a> <h3 >write</h3> <pre class="cpp"> write(data: number<span class="operator">[</span><span class="operator">]</span>): <span class="type">void</span> </pre> <p>Writes <code>data</code> into the file at the current position.</p> </div> <!-- @@@jsextension-binaryfile.html --> <p class="naviNextPrevious footerNavi"> </p> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>