\hypertarget{class_qore_1_1_file}{}\section{Qore\+:\+:File Class Reference}
\label{class_qore_1_1_file}\index{Qore\+::\+File@{Qore\+::\+File}}


The File class allows Qore programs to read, write, and create files.  




Inheritance diagram for Qore\+:\+:File\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=189pt]{class_qore_1_1_file__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_ad8c43bffafd92c6c9f98d2b96f479a58}{chown}} (softint uid, softint gid=-\/1)
\begin{DoxyCompactList}\small\item\em Changes the user and group owners of the file on the filesystem (if the current user has sufficient permission to do so) \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{constructor}} (\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Creates the File object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_file_accc587603a5e808a19bf9bc2b2956a4a}{copy}} ()
\begin{DoxyCompactList}\small\item\em Creates a new File object with the same \mbox{\hyperlink{character_encoding}{character encoding}} specification as the original, otherwise no other information is copied. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_file_a7f26852fbfef444bd2a44c82b8b2cb01}{destructor}} ()
\begin{DoxyCompactList}\small\item\em Closes the File if it is open and destroys the File object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a168a65a3e6767edc4b32137a1cd00462}{f\+\_\+printf}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} fmt,...)
\begin{DoxyCompactList}\small\item\em Writes a formatted string with hard field widths to the file. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_aa0124826c6cc0c6cfa2a81a4612d4844}{f\+\_\+printf}} ()
\begin{DoxyCompactList}\small\item\em This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a256fede5b478ecd18605a0039f9d82b6}{f\+\_\+vprintf}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} fmt, any fmt\+\_\+args)
\begin{DoxyCompactList}\small\item\em Writes a formatted string with hard field widths to a file, where the second argument is the formatting argument list. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a04172f5443b2e559269849bf7e653219}{f\+\_\+vprintf}} ()
\begin{DoxyCompactList}\small\item\em This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_file_a5fee3fe037914f2bec02518ac2514ee7}{get\+Charset}} ()
\begin{DoxyCompactList}\small\item\em Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the File. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga5182bb860e3837e1eb337e85a9b3ebd6}{hash}} \mbox{\hyperlink{class_qore_1_1_file_ac32ae5bd28039dadd4daeae6a28c3ef0}{get\+Lock\+Info}} ()
\begin{DoxyCompactList}\small\item\em Returns a hash of lock information. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_a28d636b7b8931b499027cd4eef2526ee}{get\+Terminal\+Attributes}} (\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} termios)
\begin{DoxyCompactList}\small\item\em Saves the current terminal attributes for the file in the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object passed; changes the object passed as an argument to reflect the terminal attributes as set for the \mbox{\hyperlink{class_qore_1_1_file}{File}}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} \mbox{\hyperlink{class_qore_1_1_file_a0a9d380a83dc9e70f143c8ad1f85c7b4}{get\+Terminal\+Attributes}} ()
\begin{DoxyCompactList}\small\item\em Returns the current terminal attributes for the file as a \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object returned as the return value. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_ae2ab9eceb9375c60e71b3b3dd46bee0a}{lock}} (softint \mbox{\hyperlink{group__type__conversion__functions_ga181e32c9bc8075431e88bb9bb56285a9}{type}}=\mbox{\hyperlink{group__file__locking__constants_gaf9d120de60979f848d7d145db05c4403}{F\+\_\+\+R\+D\+L\+CK}}, softint start=0, softint len=0, softint whence=\mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{S\+E\+E\+K\+\_\+\+S\+ET}})
\begin{DoxyCompactList}\small\item\em Attempts to lock the file according to the arguments passed, does not block. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_a4ec71933b105ae9b13ef5c84a7b4975a}{lock\+Blocking}} (softint \mbox{\hyperlink{group__type__conversion__functions_ga181e32c9bc8075431e88bb9bb56285a9}{type}}=\mbox{\hyperlink{group__file__locking__constants_gaf9d120de60979f848d7d145db05c4403}{F\+\_\+\+R\+D\+L\+CK}}, softint start=0, softint len=0, softint whence=\mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{S\+E\+E\+K\+\_\+\+S\+ET}})
\begin{DoxyCompactList}\small\item\em Attempts to lock the file according to the arguments passed, blocking. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{open}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} path, softint flags=\mbox{\hyperlink{group__file__open__constants_ga1ab351549a0b39d1492dc0a48d199f64}{O\+\_\+\+R\+D\+O\+N\+LY}}, softint mode=0666, \+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Opens a File in a particular mode, returns an error code on failure. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_acb397de36027a83129823742ac97c157}{open2}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} path, softint flags=\mbox{\hyperlink{group__file__open__constants_ga1ab351549a0b39d1492dc0a48d199f64}{O\+\_\+\+R\+D\+O\+N\+LY}}, softint mode=0666, \+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Opens a file in a particular mode; throws an exception on failure. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a96b440e3903aa9099cc312ea8c649beb}{print}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} data)
\begin{DoxyCompactList}\small\item\em Writes string data to a file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a3de02cd9abd35f71dd3d1f24f8ee3af1}{printf}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} fmt,...)
\begin{DoxyCompactList}\small\item\em Writes a formatted string with soft field widths to the file. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a7fb81ceed3597d9424e9bbd5dd2e55c0}{printf}} ()
\begin{DoxyCompactList}\small\item\em This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_a8ce1cf401892b56a61bbb16754366079}{redirect}} (\mbox{\hyperlink{class_qore_1_1_file}{Qore\+::\+File}} file)
\begin{DoxyCompactList}\small\item\em redirects an existing file to another file \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_a91953edb4d6d768fb72ee73f7c4dd04d}{set\+Charset}} (\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Sets the \mbox{\hyperlink{character_encoding}{character encoding}} for the file; if called with no argument, the \mbox{\hyperlink{character_encoding_default_encoding}{default encoding}} is set. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_file_aa1d7a62aa8f383cad5b8bdee78c350dd}{set\+Terminal\+Attributes}} (softint action=\mbox{\hyperlink{group__tattr__term__setting__constants_ga1e9c9ecc5ab9180c3665ba2115c792a0}{T\+C\+S\+A\+N\+OW}}, \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} termios)
\begin{DoxyCompactList}\small\item\em Sets the current terminal attributes for the File from the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object passed; does not change the object passed. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a05a4b62c74f2424fff8bb6446f1c8eff}{sync}} ()
\begin{DoxyCompactList}\small\item\em Flushes the file\textquotesingle{}s buffer to disk. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a3aaa41c4e29e2589c4dc122b749308ef}{vprintf}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} fmt, any fmt\+\_\+args)
\begin{DoxyCompactList}\small\item\em Writes a formatted string with soft field widths to a file, where the second argument is the formatting argument list. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a8e508aabefedf9fa70c42d0e5fab5959}{vprintf}} ()
\begin{DoxyCompactList}\small\item\em This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_acd30e6f14435bae0393b1ed52bec502d}{write}} (\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} data)
\begin{DoxyCompactList}\small\item\em Writes binary data to a file. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a34282b14e6bafab669b452e8b0fbacd6}{write}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} data)
\begin{DoxyCompactList}\small\item\em Writes string data to a file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_ad4f67c2a247f4b7fb9c6e26b51106aba}{writei1}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} c)
\begin{DoxyCompactList}\small\item\em Writes a 1-\/byte integer to the file. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_adcf79ce346b63b85ff517580fd96d0b0}{writei2}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} s)
\begin{DoxyCompactList}\small\item\em Writes a 2-\/byte (16 bit) integer to the file in binary big-\/endian format. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a9004f5ff77ea368263121c33f95c87c5}{writei2\+L\+SB}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} s)
\begin{DoxyCompactList}\small\item\em Writes a 2-\/byte (16 bit) integer to the file in binary little-\/endian format. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a82dee19cad26e011ba1a0970d42b2130}{writei4}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} i)
\begin{DoxyCompactList}\small\item\em Writes a 4-\/byte (32 bit) integer to the file in binary big-\/endian format. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a6788f0f1bd5b015dd726a6b2d06077bf}{writei4\+L\+SB}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} i)
\begin{DoxyCompactList}\small\item\em Writes a 4-\/byte (32 bit) integer to the file in binary little-\/endian format. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_a9de545742fe95945677bb3049a1900fc}{writei8}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} i)
\begin{DoxyCompactList}\small\item\em Writes an 8-\/byte (64 bit) integer to the file in binary big-\/endian format. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_file_aab6932b3995a5b0963e41ef41bdd0b36}{writei8\+L\+SB}} (\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} i)
\begin{DoxyCompactList}\small\item\em Writes an 8-\/byte (64 bit) integer to the file in binary little-\/endian format. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Additional Inherited Members}


\subsection{Detailed Description}
The File class allows Qore programs to read, write, and create files. 

\begin{DoxyParagraph}{Restrictions\+:}
\mbox{\hyperlink{group__parse__options_ga5e466ed886222f0b57b0a399b455be71}{Qore\+::\+P\+O\+\_\+\+N\+O\+\_\+\+F\+I\+L\+E\+S\+Y\+S\+T\+EM}}
\end{DoxyParagraph}
\begin{DoxyNote}{Note}
This class is not available with the \mbox{\hyperlink{group__parse__options_ga5e466ed886222f0b57b0a399b455be71}{P\+O\+\_\+\+N\+O\+\_\+\+F\+I\+L\+E\+S\+Y\+S\+T\+EM}} parse option
\end{DoxyNote}
File objects are created and/or opened with a specific \mbox{\hyperlink{character_encoding}{character encoding}}, meaning that any string read from the file will be tagged with the file\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}}, and any string data written to the file will be transparently converted to that \mbox{\hyperlink{character_encoding}{character encoding}} before being written (if necessary). If no \mbox{\hyperlink{character_encoding}{character encoding}} is specified, then the \mbox{\hyperlink{character_encoding_default_encoding}{default character encoding}} is assumed for the file.

This class supports posting events to a \mbox{\hyperlink{class_qore_1_1_thread_1_1_queue}{Queue}}. See \mbox{\hyperlink{event_handling}{I/O Event Handling}} for more information.

The events raised by this object are listed in the following table\+:

\label{class_qore_1_1_file_file_events}%
\Hypertarget{class_qore_1_1_file_file_events}%
 {\bfseries \mbox{\hyperlink{class_qore_1_1_file}{File}} Events}  \tabulinesep=1mm
\begin{longtabu} spread 0pt [c]{*{2}{|X[-1]}|}
\hline
{\bfseries Name} &{\bfseries Description}  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_DATA_READ}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+R\+E\+AD}} &Raised when data is read from the file  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}} &Raised when data is written to the file  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_CHANNEL_CLOSED}{E\+V\+E\+N\+T\+\_\+\+C\+H\+A\+N\+N\+E\+L\+\_\+\+C\+L\+O\+S\+ED}} &Raised when the file is closed  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_DELETED}{E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+E\+T\+ED}} &Raised when the object being monitored is deleted  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{E\+V\+E\+N\+T\+\_\+\+O\+P\+E\+N\+\_\+\+F\+I\+LE}} &Raised right before an attempt to open a file is made  \\\cline{1-2}
\mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{E\+V\+E\+N\+T\+\_\+\+F\+I\+L\+E\+\_\+\+O\+P\+E\+N\+ED}} &Raised when the file has been successfully opened  \\\cline{1-2}
\end{longtabu}


\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_file_ad8c43bffafd92c6c9f98d2b96f479a58}\label{class_qore_1_1_file_ad8c43bffafd92c6c9f98d2b96f479a58}} 
\index{Qore\+::\+File@{Qore\+::\+File}!chown@{chown}}
\index{chown@{chown}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{chown()}{chown()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::chown (\begin{DoxyParamCaption}\item[{softint}]{uid,  }\item[{softint}]{gid = {\ttfamily -\/1} }\end{DoxyParamCaption})}



Changes the user and group owners of the file on the filesystem (if the current user has sufficient permission to do so) 

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_gaac007b653cdc3acf169c9cc76ce4a928}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+U\+N\+I\+X\+\_\+\+F\+I\+L\+E\+M\+GT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.chown(0, 0);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em uid} & The user id of the user to change to; -\/1 means do not change uid \\
\hline
{\em gid} & The group id of the user to change to; -\/1 means do not change gid\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+C\+H\+O\+W\+N-\/\+E\+R\+R\+OR} & File is not open or the chown operation failed \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_gaac007b653cdc3acf169c9cc76ce4a928}{Option\+::\+H\+A\+V\+E\+\_\+\+U\+N\+I\+X\+\_\+\+F\+I\+L\+E\+M\+GT}} before calling this method to avoid this exception \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}\label{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}} 
\index{Qore\+::\+File@{Qore\+::\+File}!constructor@{constructor}}
\index{constructor@{constructor}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{constructor()}{constructor()}}
{\footnotesize\ttfamily Qore\+::\+File\+::constructor (\begin{DoxyParamCaption}\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Creates the File object. 

It accepts one optional argument that will set the default \mbox{\hyperlink{character_encoding}{character encoding}} for the file (only affects reading and writing string data) To open the file, call \mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{File\+::open()}} or \mbox{\hyperlink{class_qore_1_1_file_acb397de36027a83129823742ac97c157}{File\+::open2()}}; the \mbox{\hyperlink{character_encoding}{character encoding}} can also be set or changed by the \mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{File\+::open()}}, \mbox{\hyperlink{class_qore_1_1_file_acb397de36027a83129823742ac97c157}{File\+::open2()}}, or \mbox{\hyperlink{class_qore_1_1_read_only_file_ac5ed072e0e98c0b8f497724423be5ecd}{File\+::set\+Encoding()}} methods.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
File f();
f.open2(\textcolor{stringliteral}{"/tmp/my-file.txt"});
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em encoding} & The \mbox{\hyperlink{character_encoding}{character encoding}} for the File. Any strings written to the File will be converted to this \mbox{\hyperlink{character_encoding}{character encoding}} if necessary; if this argument is not given then the File will receive the \mbox{\hyperlink{character_encoding_default_encoding}{default encoding}}\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{File\+::constructor()}} cannot be called with a T\+TY target when \mbox{\hyperlink{parse_directives_no-terminal-io}{\%no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{File\+::open()}}, \mbox{\hyperlink{class_qore_1_1_file_acb397de36027a83129823742ac97c157}{File\+::open2()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_file_accc587603a5e808a19bf9bc2b2956a4a}\label{class_qore_1_1_file_accc587603a5e808a19bf9bc2b2956a4a}} 
\index{Qore\+::\+File@{Qore\+::\+File}!copy@{copy}}
\index{copy@{copy}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily Qore\+::\+File\+::copy (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates a new File object with the same \mbox{\hyperlink{character_encoding}{character encoding}} specification as the original, otherwise no other information is copied. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
File f1 = f.copy();
\end{DoxyCode}
 
\end{DoxyParagraph}
\mbox{\Hypertarget{class_qore_1_1_file_a7f26852fbfef444bd2a44c82b8b2cb01}\label{class_qore_1_1_file_a7f26852fbfef444bd2a44c82b8b2cb01}} 
\index{Qore\+::\+File@{Qore\+::\+File}!destructor@{destructor}}
\index{destructor@{destructor}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{destructor()}{destructor()}}
{\footnotesize\ttfamily Qore\+::\+File\+::destructor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Closes the File if it is open and destroys the File object. 

Closes the File if it is open and destroys the File object \mbox{\Hypertarget{class_qore_1_1_file_a168a65a3e6767edc4b32137a1cd00462}\label{class_qore_1_1_file_a168a65a3e6767edc4b32137a1cd00462}} 
\index{Qore\+::\+File@{Qore\+::\+File}!f\+\_\+printf@{f\+\_\+printf}}
\index{f\+\_\+printf@{f\+\_\+printf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{f\+\_\+printf()}{f\_printf()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::f\+\_\+printf (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{fmt,  }\item[{}]{... }\end{DoxyParamCaption})}



Writes a formatted string with hard field widths to the file. 

This method does not allow arguments to overrun field width specifiers in the format string.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.f\_printf(\textcolor{stringliteral}{"%5s\(\backslash\)n"}, \textcolor{stringliteral}{"hello there"}); \textcolor{comment}{# outputs "hello\(\backslash\)n", enforcing the field width}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em fmt} & the format string; see \mbox{\hyperlink{group__string__functions_string_formatting}{String Formatting}} for more information about the format string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a7fb81ceed3597d9424e9bbd5dd2e55c0}{File\+::printf()}} for a similar method that does not enforce field widths
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_aa0124826c6cc0c6cfa2a81a4612d4844}\label{class_qore_1_1_file_aa0124826c6cc0c6cfa2a81a4612d4844}} 
\index{Qore\+::\+File@{Qore\+::\+File}!f\+\_\+printf@{f\+\_\+printf}}
\index{f\+\_\+printf@{f\+\_\+printf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{f\+\_\+printf()}{f\_printf()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::f\+\_\+printf (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RUNTIME_NOOP}{R\+U\+N\+T\+I\+M\+E\+\_\+\+N\+O\+OP}}
\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a constant 0 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_file_a256fede5b478ecd18605a0039f9d82b6}\label{class_qore_1_1_file_a256fede5b478ecd18605a0039f9d82b6}} 
\index{Qore\+::\+File@{Qore\+::\+File}!f\+\_\+vprintf@{f\+\_\+vprintf}}
\index{f\+\_\+vprintf@{f\+\_\+vprintf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{f\+\_\+vprintf()}{f\_vprintf()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::f\+\_\+vprintf (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{fmt,  }\item[{any}]{fmt\+\_\+args }\end{DoxyParamCaption})}



Writes a formatted string with hard field widths to a file, where the second argument is the formatting argument list. 

This method will not allow arguments to overrun field width specifiers in the format string.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.f\_vprintf(\textcolor{stringliteral}{"%5s: %d\(\backslash\)n"}, (\textcolor{stringliteral}{"hello there"}, 2)); \textcolor{comment}{# outputs "hello: 2\(\backslash\)n", enforcing the field width}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em fmt} & the format string; see \mbox{\hyperlink{group__string__functions_string_formatting}{String Formatting}} for more information about the format string \\
\hline
{\em fmt\+\_\+args} & the single argument or list of arguments that will be used as the argument list or the format string. If a single argument is passed instead of a list, it will be used as the first argument as if a list were passed\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a8e508aabefedf9fa70c42d0e5fab5959}{File\+::vprintf()}} for a similar method that does not enforce field widths
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a04172f5443b2e559269849bf7e653219}\label{class_qore_1_1_file_a04172f5443b2e559269849bf7e653219}} 
\index{Qore\+::\+File@{Qore\+::\+File}!f\+\_\+vprintf@{f\+\_\+vprintf}}
\index{f\+\_\+vprintf@{f\+\_\+vprintf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{f\+\_\+vprintf()}{f\_vprintf()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::f\+\_\+vprintf (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RUNTIME_NOOP}{R\+U\+N\+T\+I\+M\+E\+\_\+\+N\+O\+OP}}
\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a constant 0 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_file_a5fee3fe037914f2bec02518ac2514ee7}\label{class_qore_1_1_file_a5fee3fe037914f2bec02518ac2514ee7}} 
\index{Qore\+::\+File@{Qore\+::\+File}!get\+Charset@{get\+Charset}}
\index{get\+Charset@{get\+Charset}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{get\+Charset()}{getCharset()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+File\+::get\+Charset (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the File. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
A method synonym for \mbox{\hyperlink{class_qore_1_1_read_only_file_a75abf43a49da44da7095c8f467834ffe}{Qore\+::\+Read\+Only\+File\+::get\+Encoding()}}, kept for backwards-\/compatibility

\begin{DoxyReturn}{Returns}
the \mbox{\hyperlink{character_encoding}{character encoding}} for the File 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_file_ac32ae5bd28039dadd4daeae6a28c3ef0}\label{class_qore_1_1_file_ac32ae5bd28039dadd4daeae6a28c3ef0}} 
\index{Qore\+::\+File@{Qore\+::\+File}!get\+Lock\+Info@{get\+Lock\+Info}}
\index{get\+Lock\+Info@{get\+Lock\+Info}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{get\+Lock\+Info()}{getLockInfo()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga5182bb860e3837e1eb337e85a9b3ebd6}{hash}} Qore\+::\+File\+::get\+Lock\+Info (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns a hash of lock information. 

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{R\+E\+T\+\_\+\+V\+A\+L\+U\+E\+\_\+\+O\+N\+LY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
hash hash = f.getLockInfo();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a hash with the following keys\+:
\begin{DoxyItemize}
\item {\ttfamily start\+:} starting byte of the lock
\item {\ttfamily len\+:} the length in bytes of the locked region
\item {\ttfamily pid\+:} the P\+ID of the process holding the lock
\item {\ttfamily type\+:} see \mbox{\hyperlink{group__file__locking__constants}{File Locking Constants}}; if no lock is set on the file, the key type has the value {\ttfamily F\+\_\+\+U\+N\+L\+CK}.
\item {\ttfamily whence\+:} always returned as {\ttfamily S\+E\+E\+K\+\_\+\+S\+ET} when the call is successful
\end{DoxyItemize}
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+L\+O\+C\+K-\/\+E\+R\+R\+OR} & File is not open or the internal fcntl operation failed \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant \mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}} before calling this function. \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_a28d636b7b8931b499027cd4eef2526ee}\label{class_qore_1_1_file_a28d636b7b8931b499027cd4eef2526ee}} 
\index{Qore\+::\+File@{Qore\+::\+File}!get\+Terminal\+Attributes@{get\+Terminal\+Attributes}}
\index{get\+Terminal\+Attributes@{get\+Terminal\+Attributes}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{get\+Terminal\+Attributes()}{getTerminalAttributes()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::get\+Terminal\+Attributes (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}}}]{termios }\end{DoxyParamCaption})}



Saves the current terminal attributes for the file in the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object passed; changes the object passed as an argument to reflect the terminal attributes as set for the \mbox{\hyperlink{class_qore_1_1_file}{File}}. 

Do not pass a reference to the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object; pass the object itself as an argument.

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
TermIOS termios();
stdin.getTerminalAttributes(termios);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em termios} & The method writes the current terminal attributes for the file to the object passed\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+O\+P\+E\+R\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the File is not open \\
\hline
{\em T\+E\+R\+M\+I\+O\+S-\/\+G\+E\+T-\/\+E\+R\+R\+OR} & error reading terminal attributes from the file descriptor (ex\+: not a T\+TY) \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}} before calling this method to avoid this exception \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_a0a9d380a83dc9e70f143c8ad1f85c7b4}\label{class_qore_1_1_file_a0a9d380a83dc9e70f143c8ad1f85c7b4}} 
\index{Qore\+::\+File@{Qore\+::\+File}!get\+Terminal\+Attributes@{get\+Terminal\+Attributes}}
\index{get\+Terminal\+Attributes@{get\+Terminal\+Attributes}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{get\+Terminal\+Attributes()}{getTerminalAttributes()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} Qore\+::\+File\+::get\+Terminal\+Attributes (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the current terminal attributes for the file as a \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object returned as the return value. 

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
TermIOS termios = stdin.getTerminalAttributes();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
the current terminal attributes for the \mbox{\hyperlink{class_qore_1_1_file}{File}}
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+O\+P\+E\+R\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the File is not open \\
\hline
{\em T\+E\+R\+M\+I\+O\+S-\/\+G\+E\+T-\/\+E\+R\+R\+OR} & error reading terminal attributes from the file descriptor (ex\+: not a T\+TY) \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}} before calling this method to avoid this exception \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_ae2ab9eceb9375c60e71b3b3dd46bee0a}\label{class_qore_1_1_file_ae2ab9eceb9375c60e71b3b3dd46bee0a}} 
\index{Qore\+::\+File@{Qore\+::\+File}!lock@{lock}}
\index{lock@{lock}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{lock()}{lock()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::lock (\begin{DoxyParamCaption}\item[{softint}]{type = {\ttfamily \mbox{\hyperlink{group__file__locking__constants_gaf9d120de60979f848d7d145db05c4403}{F\+\_\+\+R\+D\+L\+CK}}},  }\item[{softint}]{start = {\ttfamily 0},  }\item[{softint}]{len = {\ttfamily 0},  }\item[{softint}]{whence = {\ttfamily \mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{S\+E\+E\+K\+\_\+\+S\+ET}}} }\end{DoxyParamCaption})}



Attempts to lock the file according to the arguments passed, does not block. 

Locks or unlocks a portion of the file or the entire file, for reading or writing, non-\/blocking. The file must be opened in the appropriate mode before this call or the call will fail with an exception.

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{comment}{# lock the entire file exclusively}
f.lock(F\_WRLCK);

\textcolor{comment}{# lock a section of the file for reading, start byte 512, 2K range}
f.lock(F\_RDLCK, 512, 2048);

\textcolor{comment}{# release all locks}
f.lock(F\_UNLCK);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em type} & Type of lock (or unlock); see \mbox{\hyperlink{group__file__locking__constants}{File Locking Constants}} \\
\hline
{\em start} & Start byte for lock, 0 is the default (start of file) \\
\hline
{\em len} & Length in bytes for range to lock, 0 is the default (rest of file) \\
\hline
{\em whence} & Indicates how the relative offset of the file should be calculated for the lock; see \mbox{\hyperlink{group__file__seek__constants}{File Seek Constants}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success, \mbox{\hyperlink{group__error__constants_gaaeedce0a1d7a729ba543d954f10ea349}{E\+A\+C\+C\+ES}} if the lock would block (only in the case that the lock would block is no exception thrown and \mbox{\hyperlink{group__error__constants_gaaeedce0a1d7a729ba543d954f10ea349}{E\+A\+C\+C\+ES}} returned)
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+L\+O\+C\+K-\/\+E\+R\+R\+OR} & File is not open, lock length is negative, or the fcntl operation failed \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant \mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}} before calling this function. \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a4ec71933b105ae9b13ef5c84a7b4975a}{File\+::lock\+Blocking()}} for a blocking version of this method 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_file_a4ec71933b105ae9b13ef5c84a7b4975a}\label{class_qore_1_1_file_a4ec71933b105ae9b13ef5c84a7b4975a}} 
\index{Qore\+::\+File@{Qore\+::\+File}!lock\+Blocking@{lock\+Blocking}}
\index{lock\+Blocking@{lock\+Blocking}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{lock\+Blocking()}{lockBlocking()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::lock\+Blocking (\begin{DoxyParamCaption}\item[{softint}]{type = {\ttfamily \mbox{\hyperlink{group__file__locking__constants_gaf9d120de60979f848d7d145db05c4403}{F\+\_\+\+R\+D\+L\+CK}}},  }\item[{softint}]{start = {\ttfamily 0},  }\item[{softint}]{len = {\ttfamily 0},  }\item[{softint}]{whence = {\ttfamily \mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{S\+E\+E\+K\+\_\+\+S\+ET}}} }\end{DoxyParamCaption})}



Attempts to lock the file according to the arguments passed, blocking. 

Locks or unlocks a portion of the file or the entire file, for reading or writing, blocking. The file must be opened in the appropriate mode before this call or the call will fail with an exception.

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{comment}{# lock the entire file exclusively}
f.lockBlocking(F\_WRLCK);

\textcolor{comment}{# lock a section of the file for reading, start byte 512, 2K range}
f.lockBlocking(F\_RDLCK, 512, 2048);

\textcolor{comment}{# release all locks}
f.lockBlocking(F\_UNLCK);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em type} & Type of lock (or unlock); see \mbox{\hyperlink{group__file__locking__constants}{File Locking Constants}} \\
\hline
{\em start} & Start byte for lock, 0 is the default (start of file) \\
\hline
{\em len} & Length in bytes for range to lock, 0 is the default (rest of file) \\
\hline
{\em whence} & Indicates how the relative offset of the file should be calculated for the lock; see \mbox{\hyperlink{group__file__seek__constants}{File Seek Constants}}\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+L\+O\+C\+K-\/\+E\+R\+R\+OR} & File is not open, lock length is negative, or the fcntl operation failed \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant \mbox{\hyperlink{group__option__constants_ga55da76844b58de539c47e3fe28bdeb26}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+F\+I\+L\+E\+\_\+\+L\+O\+C\+K\+I\+NG}} before calling this function. \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a4ec71933b105ae9b13ef5c84a7b4975a}{File\+::lock\+Blocking()}} for a blocking version of this method 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}\label{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}} 
\index{Qore\+::\+File@{Qore\+::\+File}!open@{open}}
\index{open@{open}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{open()}{open()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::open (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{path,  }\item[{softint}]{flags = {\ttfamily \mbox{\hyperlink{group__file__open__constants_ga1ab351549a0b39d1492dc0a48d199f64}{O\+\_\+\+R\+D\+O\+N\+LY}}},  }\item[{softint}]{mode = {\ttfamily 0666},  }\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Opens a File in a particular mode, returns an error code on failure. 

Opens the File in the mode given; if the File was previously open, it is closed first. Additionally, the file permissions can be given if the file is to be created, and optionally the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} can be specified.

Note that if no encoding is specified, the File will be tagged with the \mbox{\hyperlink{character_encoding}{character encoding}} set in the File\textquotesingle{}s \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{constructor}}. Any string data written to the File will be converted to the File\textquotesingle{}s encoding, and any string data read from the File will be automatically tagged with the File\textquotesingle{}s encoding.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{comment}{# open a file for writing, truncate data if already exists, create the file if doesn't exist}
\textcolor{comment}{# set 0644 permissions, and convert all string data to ISO-8859-1 encoding}
\textcolor{keywordflow}{if} (f.open(fn, O\_CREAT | O\_TRUNC | O\_WRONLY, 0644, \textcolor{stringliteral}{"ISO-8859-1"}))
    \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"%s: %s\(\backslash\)n"}, fn, \mbox{\hyperlink{group__library__functions_ga13d9bb498eef9caffe641130bd8a1c73}{strerror}}(\mbox{\hyperlink{group__library__functions_gabcf45c25ca1234fc8c54761750324cda}{errno}}()));
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{E\+V\+E\+N\+T\+\_\+\+O\+P\+E\+N\+\_\+\+F\+I\+LE}}, \mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{E\+V\+E\+N\+T\+\_\+\+F\+I\+L\+E\+\_\+\+O\+P\+E\+N\+ED}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em path} & the path to the file \\
\hline
{\em flags} & flags that determine the way the file is accessed, see \mbox{\hyperlink{group__file__open__constants}{File Open Constants}} for more information; if this argument is not given, {\ttfamily O\+\_\+\+R\+D\+O\+N\+LY} will be used as the default value. \\
\hline
{\em mode} & permission bits for when the file is to be created (default\+: 0666) \\
\hline
{\em encoding} & the name of the \mbox{\hyperlink{character_encoding}{character encoding}} for the File; if this argument is not given, the file will be tagged with the \mbox{\hyperlink{character_encoding}{character encoding}} given in the \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{constructor}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 = no error, -\/1 = see \mbox{\hyperlink{group__library__functions_gabcf45c25ca1234fc8c54761750324cda}{errno()}} and \mbox{\hyperlink{group__library__functions_ga13d9bb498eef9caffe641130bd8a1c73}{strerror()}} for the error message
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_acb397de36027a83129823742ac97c157}{File\+::open2()}} for a version of this method that throws an exception when errors occur opening the file 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_file_acb397de36027a83129823742ac97c157}\label{class_qore_1_1_file_acb397de36027a83129823742ac97c157}} 
\index{Qore\+::\+File@{Qore\+::\+File}!open2@{open2}}
\index{open2@{open2}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{open2()}{open2()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::open2 (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{path,  }\item[{softint}]{flags = {\ttfamily \mbox{\hyperlink{group__file__open__constants_ga1ab351549a0b39d1492dc0a48d199f64}{O\+\_\+\+R\+D\+O\+N\+LY}}},  }\item[{softint}]{mode = {\ttfamily 0666},  }\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Opens a file in a particular mode; throws an exception on failure. 

Opens the file in the mode given; if the File was previously open, it is closed first. Additionally, the file permissions can be given if the file is to be created, and optionally the File\textquotesingle{}s default character encoding can be specified.

Note that if no encoding is specified, the File will be tagged with the \mbox{\hyperlink{character_encoding}{character encoding}} set in the File\textquotesingle{}s \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{constructor}}. Any string data written to the File will be converted to the File\textquotesingle{}s encoding, and any string data read from the File will be automatically tagged with the File\textquotesingle{}s encoding.

If an error occurs, a {\ttfamily F\+I\+L\+E-\/\+O\+P\+E\+N2-\/\+E\+R\+R\+OR} exception is thrown. For a version of this method that returns an error code, see \mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{File\+::open()}}.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{comment}{# open a file for writing, truncate data if already exists, create the file if doesn't exist}
\textcolor{comment}{# set 0644 permissions, and convert all string data to ISO-8859-1 encoding}
\textcolor{keywordflow}{try} \{
    f.open2(fn, O\_CREAT | O\_TRUNC | O\_WRONLY, 0644, \textcolor{stringliteral}{"ISO-8859-1"});
\}
catch (hash ex) \{
    \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"%s: %s: %s\(\backslash\)n"}, fn, ex.err, ex.desc);
\}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{E\+V\+E\+N\+T\+\_\+\+O\+P\+E\+N\+\_\+\+F\+I\+LE}}, \mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{E\+V\+E\+N\+T\+\_\+\+F\+I\+L\+E\+\_\+\+O\+P\+E\+N\+ED}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em path} & the path to the file \\
\hline
{\em flags} & flags that determine the way the file is accessed, see \mbox{\hyperlink{group__file__open__constants}{File Open Constants}} for more information; if this argument is not given, {\ttfamily O\+\_\+\+R\+D\+O\+N\+LY} will be used as the default value. \\
\hline
{\em mode} & permission bits for when the file is to be created (default\+: 0666) \\
\hline
{\em encoding} & the name of the \mbox{\hyperlink{character_encoding}{character encoding}} for the File; if this argument is not given, the File will be tagged with the \mbox{\hyperlink{character_encoding}{character encoding}} given in the \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{constructor}}\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+O\+P\+E\+N2-\/\+E\+R\+R\+OR} & an error occurred opening the file \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a0f0e402ebce26412fa854b3647a13c15}{File\+::open()}} for a version of this method that returns an error code instead of throwing an exception when errors occur opening the File 
\end{DoxySeeAlso}
\mbox{\Hypertarget{class_qore_1_1_file_a96b440e3903aa9099cc312ea8c649beb}\label{class_qore_1_1_file_a96b440e3903aa9099cc312ea8c649beb}} 
\index{Qore\+::\+File@{Qore\+::\+File}!print@{print}}
\index{print@{print}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{print()}{print()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::print (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{data }\end{DoxyParamCaption})}



Writes string data to a file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.print(data);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em data} & the data to be written to the file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em E\+N\+C\+O\+D\+I\+N\+G-\/\+C\+O\+N\+V\+E\+R\+S\+I\+O\+N-\/\+E\+R\+R\+OR} & error converting from the string\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxyNote}{Note}
this method is equivalent to \mbox{\hyperlink{class_qore_1_1_file_a34282b14e6bafab669b452e8b0fbacd6}{File\+::write(string)}}
\end{DoxyNote}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a3de02cd9abd35f71dd3d1f24f8ee3af1}\label{class_qore_1_1_file_a3de02cd9abd35f71dd3d1f24f8ee3af1}} 
\index{Qore\+::\+File@{Qore\+::\+File}!printf@{printf}}
\index{printf@{printf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{printf()}{printf()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::printf (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{fmt,  }\item[{}]{... }\end{DoxyParamCaption})}



Writes a formatted string with soft field widths to the file. 

This method will allow arguments to overrun field width specifiers in the format string.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.printf(\textcolor{stringliteral}{"%5s\(\backslash\)n"}, \textcolor{stringliteral}{"hello there"}); \textcolor{comment}{# outputs "hello there\(\backslash\)n", exceeding field width}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em fmt} & the format string; see \mbox{\hyperlink{group__string__functions_string_formatting}{String Formatting}} for more information about the format string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_aa0124826c6cc0c6cfa2a81a4612d4844}{File\+::f\+\_\+printf()}} for a similar method that enforces field widths
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a7fb81ceed3597d9424e9bbd5dd2e55c0}\label{class_qore_1_1_file_a7fb81ceed3597d9424e9bbd5dd2e55c0}} 
\index{Qore\+::\+File@{Qore\+::\+File}!printf@{printf}}
\index{printf@{printf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{printf()}{printf()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::printf (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RUNTIME_NOOP}{R\+U\+N\+T\+I\+M\+E\+\_\+\+N\+O\+OP}}
\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a constant 0 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_file_a8ce1cf401892b56a61bbb16754366079}\label{class_qore_1_1_file_a8ce1cf401892b56a61bbb16754366079}} 
\index{Qore\+::\+File@{Qore\+::\+File}!redirect@{redirect}}
\index{redirect@{redirect}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{redirect()}{redirect()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::redirect (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_file}{Qore\+::\+File}}}]{file }\end{DoxyParamCaption})}



redirects an existing file to another file 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
File my\_file(\textcolor{stringliteral}{"/tmp/my\_stderr.txt"}, O\_CREAT|O\_TRUNC|O\_WRONLY);
stderr.redirect(my\_file);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em file} & the file that the current object will be redirected to\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+R\+E\+D\+I\+R\+E\+C\+T-\/\+E\+R\+R\+OR} & the underlying call to {\ttfamily dup2()} failed \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called on or with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxyNote}{Note}
Once this method has been successfully executed, the file descriptor of the current object mirrors all operations of the argument\textquotesingle{}s file descriptor and vice-\/versa, however the internal state and file path information is not kept synchronized between the linked objects in Qore, which must be taken into consideration when performing operations on objects linked through calls to this method.
\end{DoxyNote}
\begin{DoxySince}{Since}
\mbox{\hyperlink{namespace_qore}{Qore}} 0.\+9 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a91953edb4d6d768fb72ee73f7c4dd04d}\label{class_qore_1_1_file_a91953edb4d6d768fb72ee73f7c4dd04d}} 
\index{Qore\+::\+File@{Qore\+::\+File}!set\+Charset@{set\+Charset}}
\index{set\+Charset@{set\+Charset}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{set\+Charset()}{setCharset()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::set\+Charset (\begin{DoxyParamCaption}\item[{\+\_\+\+\_\+7\+\_\+ \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Sets the \mbox{\hyperlink{character_encoding}{character encoding}} for the file; if called with no argument, the \mbox{\hyperlink{character_encoding_default_encoding}{default encoding}} is set. 

A method synonym for \mbox{\hyperlink{class_qore_1_1_read_only_file_ac5ed072e0e98c0b8f497724423be5ecd}{Qore\+::\+Read\+Only\+File\+::set\+Encoding()}}, kept for backwards-\/compatibility 
\begin{DoxyParams}{Parameters}
{\em encoding} & the \mbox{\hyperlink{character_encoding}{character encoding}} for the file; if called with no argument, the \mbox{\hyperlink{character_encoding_default_encoding}{default encoding}} is set\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_aa1d7a62aa8f383cad5b8bdee78c350dd}\label{class_qore_1_1_file_aa1d7a62aa8f383cad5b8bdee78c350dd}} 
\index{Qore\+::\+File@{Qore\+::\+File}!set\+Terminal\+Attributes@{set\+Terminal\+Attributes}}
\index{set\+Terminal\+Attributes@{set\+Terminal\+Attributes}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{set\+Terminal\+Attributes()}{setTerminalAttributes()}}
{\footnotesize\ttfamily nothing Qore\+::\+File\+::set\+Terminal\+Attributes (\begin{DoxyParamCaption}\item[{softint}]{action = {\ttfamily \mbox{\hyperlink{group__tattr__term__setting__constants_ga1e9c9ecc5ab9180c3665ba2115c792a0}{T\+C\+S\+A\+N\+OW}}},  }\item[{\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}}}]{termios }\end{DoxyParamCaption})}



Sets the current terminal attributes for the File from the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} object passed; does not change the object passed. 

\begin{DoxyParagraph}{Platform Availability\+:}
\mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
TermIOS termios();
stdin.getTerminalAttributes(termios);
TermIOS orig = termios.copy();
on\_exit
    stdin.setTerminalAttributes(TCSADRAIN, orig);

int lflag = termios.getLFlag();
lflag &= ~ICANON;
lflag &= ~ECHO;
lflag &= ~ISIG;
termios.setLFlag(lflag);
termios.setCC(VMIN, 1);
termios.setCC(VTIME, 0);
stdin.setTerminalAttributes(TCSADRAIN, termios);
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em action} & a binary or\textquotesingle{}ed value of the following actions\+:
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__tattr__term__setting__constants_ga1e9c9ecc5ab9180c3665ba2115c792a0}{T\+C\+S\+A\+N\+OW}}\+: the change occurs immediately
\item \mbox{\hyperlink{group__tattr__term__setting__constants_ga9d4186bd3d8efad89a2d5ef9a1bdac32}{T\+C\+S\+A\+D\+R\+A\+IN}}\+: the change occurs after all output written to the File has been transmitted to the terminal
\item \mbox{\hyperlink{group__tattr__term__setting__constants_gacd2d752948b9057a27b85af7cea541e0}{T\+C\+S\+A\+F\+L\+U\+SH}}\+: the change occurs after all output written to the File has been transmitted to the terminal
\item \mbox{\hyperlink{group__tattr__term__setting__constants_ga4c49895599ee5a5dcb84d600e17559d2}{T\+C\+S\+A\+S\+O\+FT}}\+: the values of the {\ttfamily c\+\_\+cflag}, {\ttfamily c\+\_\+ispeed}, and {\ttfamily c\+\_\+ospeed} fields are ignored 
\end{DoxyItemize}\\
\hline
{\em termios} & the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+I\+OS}} to use\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+O\+P\+E\+R\+A\+T\+I\+O\+N-\/\+E\+R\+R\+OR} & the File is not open \\
\hline
{\em T\+E\+R\+M\+I\+O\+S-\/\+S\+E\+T-\/\+E\+R\+R\+OR} & error setting terminal attributes on the file descriptor \\
\hline
{\em M\+I\+S\+S\+I\+N\+G-\/\+F\+E\+A\+T\+U\+R\+E-\/\+E\+R\+R\+OR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+H\+A\+V\+E\+\_\+\+T\+E\+R\+M\+I\+OS}} before calling this method to avoid this exception \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_a05a4b62c74f2424fff8bb6446f1c8eff}\label{class_qore_1_1_file_a05a4b62c74f2424fff8bb6446f1c8eff}} 
\index{Qore\+::\+File@{Qore\+::\+File}!sync@{sync}}
\index{sync@{sync}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{sync()}{sync()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::sync (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Flushes the file\textquotesingle{}s buffer to disk. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{keywordflow}{if} (f.sync())
    \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"error in File::sync(): %s\(\backslash\)n"}, \mbox{\hyperlink{group__library__functions_ga13d9bb498eef9caffe641130bd8a1c73}{strerror}}(\mbox{\hyperlink{group__library__functions_gabcf45c25ca1234fc8c54761750324cda}{errno}}()));
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
0 for success, -\/1 for error (see \mbox{\hyperlink{group__library__functions_gabcf45c25ca1234fc8c54761750324cda}{errno()}} and \mbox{\hyperlink{group__library__functions_ga13d9bb498eef9caffe641130bd8a1c73}{strerror()}} for the error information)
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_file_a3aaa41c4e29e2589c4dc122b749308ef}\label{class_qore_1_1_file_a3aaa41c4e29e2589c4dc122b749308ef}} 
\index{Qore\+::\+File@{Qore\+::\+File}!vprintf@{vprintf}}
\index{vprintf@{vprintf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{vprintf()}{vprintf()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::vprintf (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{fmt,  }\item[{any}]{fmt\+\_\+args }\end{DoxyParamCaption})}



Writes a formatted string with soft field widths to a file, where the second argument is the formatting argument list. 

This method will allow arguments to overrun field width specifiers in the format string.

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.vprintf(\textcolor{stringliteral}{"%5s: %d\(\backslash\)n"}, (\textcolor{stringliteral}{"hello there"}, 2)); \textcolor{comment}{# outputs "hello there: 2\(\backslash\)n", exceeding field width}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em fmt} & the format string; see \mbox{\hyperlink{group__string__functions_string_formatting}{String Formatting}} for more information about the format string \\
\hline
{\em fmt\+\_\+args} & the single argument or list of arguments that will be used as the argument list or the format string. If a single argument is passed instead of a list, it will be used as the first argument as if a list were passed\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_file_a04172f5443b2e559269849bf7e653219}{File\+::f\+\_\+vprintf()}} for a similar method that enforces field widths
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a8e508aabefedf9fa70c42d0e5fab5959}\label{class_qore_1_1_file_a8e508aabefedf9fa70c42d0e5fab5959}} 
\index{Qore\+::\+File@{Qore\+::\+File}!vprintf@{vprintf}}
\index{vprintf@{vprintf}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{vprintf()}{vprintf()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::vprintf (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



This method variant does nothing except return a constant 0; it is only included for backwards-\/compatibility with qore prior to version 0.\+8.\+0 for functions that would ignore type errors in arguments. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RUNTIME_NOOP}{R\+U\+N\+T\+I\+M\+E\+\_\+\+N\+O\+OP}}
\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
a constant 0 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_file_acd30e6f14435bae0393b1ed52bec502d}\label{class_qore_1_1_file_acd30e6f14435bae0393b1ed52bec502d}} 
\index{Qore\+::\+File@{Qore\+::\+File}!write@{write}}
\index{write@{write}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{write()}{write()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}}}]{data }\end{DoxyParamCaption})}



Writes binary data to a file. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.write(data);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em data} & the data to be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a34282b14e6bafab669b452e8b0fbacd6}\label{class_qore_1_1_file_a34282b14e6bafab669b452e8b0fbacd6}} 
\index{Qore\+::\+File@{Qore\+::\+File}!write@{write}}
\index{write@{write}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{write()}{write()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{data }\end{DoxyParamCaption})}



Writes string data to a file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.write(data);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em data} & the data to be written to the file; string data is converted to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} if necessary before writing\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em E\+N\+C\+O\+D\+I\+N\+G-\/\+C\+O\+N\+V\+E\+R\+S\+I\+O\+N-\/\+E\+R\+R\+OR} & error converting from the string\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} to the File\textquotesingle{}s \mbox{\hyperlink{character_encoding}{character encoding}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxyNote}{Note}
this variant of this method is equivalent to \mbox{\hyperlink{class_qore_1_1_file_a96b440e3903aa9099cc312ea8c649beb}{File\+::print()}}
\end{DoxyNote}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_ad4f67c2a247f4b7fb9c6e26b51106aba}\label{class_qore_1_1_file_ad4f67c2a247f4b7fb9c6e26b51106aba}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei1@{writei1}}
\index{writei1@{writei1}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei1()}{writei1()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei1 (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{c }\end{DoxyParamCaption})}



Writes a 1-\/byte integer to the file. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei1(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em c} & the integer to write; only the least-\/significant 8 bits will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_adcf79ce346b63b85ff517580fd96d0b0}\label{class_qore_1_1_file_adcf79ce346b63b85ff517580fd96d0b0}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei2@{writei2}}
\index{writei2@{writei2}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei2()}{writei2()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei2 (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{s }\end{DoxyParamCaption})}



Writes a 2-\/byte (16 bit) integer to the file in binary big-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei2(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em s} & the integer to write in binary big-\/endian format; only the least-\/significant 16 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a9004f5ff77ea368263121c33f95c87c5}\label{class_qore_1_1_file_a9004f5ff77ea368263121c33f95c87c5}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei2\+L\+SB@{writei2\+L\+SB}}
\index{writei2\+L\+SB@{writei2\+L\+SB}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei2\+L\+S\+B()}{writei2LSB()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei2\+L\+SB (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{s }\end{DoxyParamCaption})}



Writes a 2-\/byte (16 bit) integer to the file in binary little-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei2LSB(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em s} & the integer to write in binary little-\/endian format; only the least-\/significant 16 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a82dee19cad26e011ba1a0970d42b2130}\label{class_qore_1_1_file_a82dee19cad26e011ba1a0970d42b2130}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei4@{writei4}}
\index{writei4@{writei4}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei4()}{writei4()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei4 (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{i }\end{DoxyParamCaption})}



Writes a 4-\/byte (32 bit) integer to the file in binary big-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei4(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em i} & the integer to write in binary big-\/endian format; only the least-\/significant 32 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a6788f0f1bd5b015dd726a6b2d06077bf}\label{class_qore_1_1_file_a6788f0f1bd5b015dd726a6b2d06077bf}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei4\+L\+SB@{writei4\+L\+SB}}
\index{writei4\+L\+SB@{writei4\+L\+SB}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei4\+L\+S\+B()}{writei4LSB()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei4\+L\+SB (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{i }\end{DoxyParamCaption})}



Writes a 4-\/byte (32 bit) integer to the file in binary little-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei4LSB(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em i} & the integer to write in binary little-\/endian format; only the least-\/significant 32 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_a9de545742fe95945677bb3049a1900fc}\label{class_qore_1_1_file_a9de545742fe95945677bb3049a1900fc}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei8@{writei8}}
\index{writei8@{writei8}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei8()}{writei8()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei8 (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{i }\end{DoxyParamCaption})}



Writes an 8-\/byte (64 bit) integer to the file in binary big-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei8(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em i} & the integer to write in binary big-\/endian format; only the least-\/significant 64 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
\mbox{\Hypertarget{class_qore_1_1_file_aab6932b3995a5b0963e41ef41bdd0b36}\label{class_qore_1_1_file_aab6932b3995a5b0963e41ef41bdd0b36}} 
\index{Qore\+::\+File@{Qore\+::\+File}!writei8\+L\+SB@{writei8\+L\+SB}}
\index{writei8\+L\+SB@{writei8\+L\+SB}!Qore\+::\+File@{Qore\+::\+File}}
\subsubsection{\texorpdfstring{writei8\+L\+S\+B()}{writei8LSB()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei8\+L\+SB (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}}}]{i }\end{DoxyParamCaption})}



Writes an 8-\/byte (64 bit) integer to the file in binary little-\/endian format. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
f.writei8LSB(val);
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyParagraph}{Events\+:}
\mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{E\+V\+E\+N\+T\+\_\+\+D\+A\+T\+A\+\_\+\+W\+R\+I\+T\+T\+EN}}
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em i} & the integer to write in binary little-\/endian format; only the least-\/significant 64 bits of the integer will be written to the file\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success
\end{DoxyReturn}

\begin{DoxyExceptions}{Exceptions}
{\em F\+I\+L\+E-\/\+W\+R\+I\+T\+E-\/\+E\+R\+R\+OR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\
\hline
{\em I\+L\+L\+E\+G\+A\+L-\/\+E\+X\+P\+R\+E\+S\+S\+I\+ON} & this exception is only thrown if called with a system constant object (\mbox{\hyperlink{group__io__constants_ga0cfa7aea34f3c921036623600e42b21f}{stdin}}, \mbox{\hyperlink{group__io__constants_ga44ab38fe66ed7aa87731a2de976017c6}{stdout}}, \mbox{\hyperlink{group__io__constants_ga697e4968984d273562f14bfed155b4a8}{stderr}}) when \mbox{\hyperlink{parse_directives_no-terminal-io}{no-\/terminal-\/io}} is set\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+7 this method throws exceptions on I/O errors to avoid silent write errors in \mbox{\hyperlink{namespace_qore}{Qore}} code 
\end{DoxySince}
