\hypertarget{class_qore_1_1_file}{}\doxysection{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\+: % FIG 0 \doxysubsection*{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_ga0231dbb472dd230310af7c7c34f56e92}{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\+IOS}} 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\+IOS}} 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\+IOS}} \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\+IOS}} 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\+\_\+\+RDLCK}}, softint start=0, softint len=0, softint whence=\mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{SEEK\+\_\+\+SET}}) \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\+\_\+\+RDLCK}}, softint start=0, softint len=0, softint whence=\mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{SEEK\+\_\+\+SET}}) \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\+\_\+\+RDONLY}}, 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\+\_\+\+RDONLY}}, 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}{TCSANOW}}, \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}} 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\+IOS}} 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\+LSB}} (\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\+LSB}} (\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\+LSB}} (\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} \doxysubsection*{Additional Inherited Members} \doxysubsection{Detailed Description} The File class allows Qore programs to read, write, and create files. \begin{DoxyParagraph}{Restrictions\+:} \mbox{\hyperlink{group__parse__options_ga5e466ed886222f0b57b0a399b455be71}{Qore\+::\+PO\+\_\+\+NO\+\_\+\+FILESYSTEM}} \end{DoxyParagraph} \begin{DoxyNote}{Note} This class is not available with the \mbox{\hyperlink{group__parse__options_ga5e466ed886222f0b57b0a399b455be71}{PO\+\_\+\+NO\+\_\+\+FILESYSTEM}} 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}{EVENT\+\_\+\+DATA\+\_\+\+READ}} &Raised when data is read from the file \\\cline{1-2} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} &Raised when data is written to the file \\\cline{1-2} \mbox{\hyperlink{event_handling_EVENT_CHANNEL_CLOSED}{EVENT\+\_\+\+CHANNEL\+\_\+\+CLOSED}} &Raised when the file is closed \\\cline{1-2} \mbox{\hyperlink{event_handling_EVENT_DELETED}{EVENT\+\_\+\+DELETED}} &Raised when the object being monitored is deleted \\\cline{1-2} \mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{EVENT\+\_\+\+OPEN\+\_\+\+FILE}} &Raised right before an attempt to open a file is made \\\cline{1-2} \mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{EVENT\+\_\+\+FILE\+\_\+\+OPENED}} &Raised when the file has been successfully opened \\\cline{1-2} \end{longtabu} \doxysubsection{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}} \doxysubsubsection{\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\+::\+HAVE\+\_\+\+UNIX\+\_\+\+FILEMGT}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{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 FILE-\/\+CHOWN-\/\+ERROR} & File is not open or the chown operation failed \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_gaac007b653cdc3acf169c9cc76ce4a928}{Option\+::\+HAVE\+\_\+\+UNIX\+\_\+\+FILEMGT}} before calling this method to avoid this exception \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{File f();} \DoxyCodeLine{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 ILLEGAL-\/\+EXPRESSION} & \mbox{\hyperlink{class_qore_1_1_file_a3ebb12df5983eddf42394bce5033aa75}{File\+::constructor()}} cannot be called with a TTY 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{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}} \doxysubsubsection{\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_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}} \doxysubsubsection{\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}{ }\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}{RUNTIME\+\_\+\+NOOP}} \end{DoxyParagraph} \begin{DoxyReturn}{Returns} a constant 0 \end{DoxyReturn} \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}} \doxysubsubsection{\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}\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}{0} \DoxyCodeLine{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}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_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}} \doxysubsubsection{\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}{ }\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}{RUNTIME\+\_\+\+NOOP}} \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}} \doxysubsubsection{\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}\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}{0} \DoxyCodeLine{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}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_a5fee3fe037914f2bec02518ac2514ee7}\label{class_qore_1_1_file_a5fee3fe037914f2bec02518ac2514ee7}} \index{Qore::File@{Qore::File}!getCharset@{getCharset}} \index{getCharset@{getCharset}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{getCharset()}{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}{CONSTANT}} \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}!getLockInfo@{getLockInfo}} \index{getLockInfo@{getLockInfo}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{getLockInfo()}{getLockInfo()}} {\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} \end{DoxyParagraph} \begin{DoxyParagraph}{Code Flags\+:} \mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{RET\+\_\+\+VALUE\+\_\+\+ONLY}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{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 PID 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\+\_\+\+UNLCK}. \item {\ttfamily whence\+:} always returned as {\ttfamily SEEK\+\_\+\+SET} when the call is successful \end{DoxyItemize} \end{DoxyReturn} \begin{DoxyExceptions}{Exceptions} {\em FILE-\/\+LOCK-\/\+ERROR} & File is not open or the internal fcntl operation failed \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & 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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} before calling this function. \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!getTerminalAttributes@{getTerminalAttributes}} \index{getTerminalAttributes@{getTerminalAttributes}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{getTerminalAttributes()}{getTerminalAttributes()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}} {\footnotesize\ttfamily \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}} 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\+IOS}} object returned as the return value. \begin{DoxyParagraph}{Platform Availability\+:} \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+HAVE\+\_\+\+TERMIOS}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{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 FILE-\/\+OPERATION-\/\+ERROR} & the File is not open \\ \hline {\em TERMIOS-\/\+GET-\/\+ERROR} & error reading terminal attributes from the file descriptor (ex\+: not a TTY) \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+HAVE\+\_\+\+TERMIOS}} before calling this method to avoid this exception \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_a28d636b7b8931b499027cd4eef2526ee}\label{class_qore_1_1_file_a28d636b7b8931b499027cd4eef2526ee}} \index{Qore::File@{Qore::File}!getTerminalAttributes@{getTerminalAttributes}} \index{getTerminalAttributes@{getTerminalAttributes}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{getTerminalAttributes()}{getTerminalAttributes()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}} {\footnotesize\ttfamily nothing Qore\+::\+File\+::get\+Terminal\+Attributes (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}}}]{termios }\end{DoxyParamCaption})} Saves the current terminal attributes for the file in the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}} 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\+IOS}} object; pass the object itself as an argument. \begin{DoxyParagraph}{Platform Availability\+:} \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+HAVE\+\_\+\+TERMIOS}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{TermIOS termios();} \DoxyCodeLine{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 FILE-\/\+OPERATION-\/\+ERROR} & the File is not open \\ \hline {\em TERMIOS-\/\+GET-\/\+ERROR} & error reading terminal attributes from the file descriptor (ex\+: not a TTY) \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+HAVE\+\_\+\+TERMIOS}} before calling this method to avoid this exception \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_ae2ab9eceb9375c60e71b3b3dd46bee0a}\label{class_qore_1_1_file_ae2ab9eceb9375c60e71b3b3dd46bee0a}} \index{Qore::File@{Qore::File}!lock@{lock}} \index{lock@{lock}!Qore::File@{Qore::File}} \doxysubsubsection{\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\+\_\+\+RDLCK}}}, }\item[{softint}]{start = {\ttfamily 0}, }\item[{softint}]{len = {\ttfamily 0}, }\item[{softint}]{whence = {\ttfamily \mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{SEEK\+\_\+\+SET}}} }\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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{comment}{\# lock the entire file exclusively}} \DoxyCodeLine{f.lock(F\_WRLCK);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{\# lock a section of the file for reading, start byte 512, 2K range}} \DoxyCodeLine{f.lock(F\_RDLCK, 512, 2048);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{\# release all locks}} \DoxyCodeLine{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}{EACCES}} 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}{EACCES}} returned) \end{DoxyReturn} \begin{DoxyExceptions}{Exceptions} {\em FILE-\/\+LOCK-\/\+ERROR} & File is not open, lock length is negative, or the fcntl operation failed \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & 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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} before calling this function. \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!lockBlocking@{lockBlocking}} \index{lockBlocking@{lockBlocking}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{lockBlocking()}{lockBlocking()}} {\footnotesize\ttfamily nothing Qore\+::\+File\+::lock\+Blocking (\begin{DoxyParamCaption}\item[{softint}]{type = {\ttfamily \mbox{\hyperlink{group__file__locking__constants_gaf9d120de60979f848d7d145db05c4403}{F\+\_\+\+RDLCK}}}, }\item[{softint}]{start = {\ttfamily 0}, }\item[{softint}]{len = {\ttfamily 0}, }\item[{softint}]{whence = {\ttfamily \mbox{\hyperlink{group__file__seek__constants_gaf3418d7771017bd7551b14aad79900f3}{SEEK\+\_\+\+SET}}} }\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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{comment}{\# lock the entire file exclusively}} \DoxyCodeLine{f.lockBlocking(F\_WRLCK);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{\# lock a section of the file for reading, start byte 512, 2K range}} \DoxyCodeLine{f.lockBlocking(F\_RDLCK, 512, 2048);} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{comment}{\# release all locks}} \DoxyCodeLine{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 FILE-\/\+LOCK-\/\+ERROR} & File is not open, lock length is negative, or the fcntl operation failed \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & 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\+::\+HAVE\+\_\+\+FILE\+\_\+\+LOCKING}} before calling this function. \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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\+\_\+\+RDONLY}}}, }\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}{0} \DoxyCodeLine{\textcolor{comment}{\# open a file for writing, truncate data if already exists, create the file if doesn't exist}} \DoxyCodeLine{\textcolor{comment}{\# set 0644 permissions, and convert all string data to ISO-\/8859-\/1 encoding}} \DoxyCodeLine{\textcolor{keywordflow}{if} (f.open(fn, O\_CREAT | O\_TRUNC | O\_WRONLY, 0644, \textcolor{stringliteral}{"{}ISO-\/8859-\/1"{}}))} \DoxyCodeLine{ \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"{}\%s: \%s\(\backslash\)n"{}}, fn, strerror(errno()));} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{EVENT\+\_\+\+OPEN\+\_\+\+FILE}}, \mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{EVENT\+\_\+\+FILE\+\_\+\+OPENED}} \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\+\_\+\+RDONLY} 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{namespace_qore_abcf45c25ca1234fc8c54761750324cda}{errno()}} and \mbox{\hyperlink{namespace_qore_a13d9bb498eef9caffe641130bd8a1c73}{strerror()}} for the error message \end{DoxyReturn} \begin{DoxyExceptions}{Exceptions} {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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\+\_\+\+RDONLY}}}, }\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 FILE-\/\+OPEN2-\/\+ERROR} 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}{0} \DoxyCodeLine{\textcolor{comment}{\# open a file for writing, truncate data if already exists, create the file if doesn't exist}} \DoxyCodeLine{\textcolor{comment}{\# set 0644 permissions, and convert all string data to ISO-\/8859-\/1 encoding}} \DoxyCodeLine{\textcolor{keywordflow}{try} \{} \DoxyCodeLine{ f.open2(fn, O\_CREAT | O\_TRUNC | O\_WRONLY, 0644, \textcolor{stringliteral}{"{}ISO-\/8859-\/1"{}});} \DoxyCodeLine{\}} \DoxyCodeLine{catch (hash ex) \{} \DoxyCodeLine{ \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"{}\%s: \%s: \%s\(\backslash\)n"{}}, fn, ex.err, ex.desc);} \DoxyCodeLine{\}} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_OPEN_FILE}{EVENT\+\_\+\+OPEN\+\_\+\+FILE}}, \mbox{\hyperlink{event_handling_EVENT_FILE_OPENED}{EVENT\+\_\+\+FILE\+\_\+\+OPENED}} \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\+\_\+\+RDONLY} 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 FILE-\/\+OPEN2-\/\+ERROR} & an error occurred opening the file \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.print(data);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ENCODING-\/\+CONVERSION-\/\+ERROR} & 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 ILLEGAL-\/\+EXPRESSION} & 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_a7fb81ceed3597d9424e9bbd5dd2e55c0}\label{class_qore_1_1_file_a7fb81ceed3597d9424e9bbd5dd2e55c0}} \index{Qore::File@{Qore::File}!printf@{printf}} \index{printf@{printf}!Qore::File@{Qore::File}} \doxysubsubsection{\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}{ }\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}{RUNTIME\+\_\+\+NOOP}} \end{DoxyParagraph} \begin{DoxyReturn}{Returns} a constant 0 \end{DoxyReturn} \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}} \doxysubsubsection{\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}\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}{0} \DoxyCodeLine{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}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_a8ce1cf401892b56a61bbb16754366079}\label{class_qore_1_1_file_a8ce1cf401892b56a61bbb16754366079}} \index{Qore::File@{Qore::File}!redirect@{redirect}} \index{redirect@{redirect}!Qore::File@{Qore::File}} \doxysubsubsection{\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}{0} \DoxyCodeLine{File my\_file(\textcolor{stringliteral}{"{}/tmp/my\_stderr.txt"{}}, O\_CREAT|O\_TRUNC|O\_WRONLY);} \DoxyCodeLine{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 FILE-\/\+REDIRECT-\/\+ERROR} & the underlying call to {\ttfamily dup2()} failed \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!setCharset@{setCharset}} \index{setCharset@{setCharset}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{setCharset()}{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 ILLEGAL-\/\+EXPRESSION} & 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}!setTerminalAttributes@{setTerminalAttributes}} \index{setTerminalAttributes@{setTerminalAttributes}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{setTerminalAttributes()}{setTerminalAttributes()}} {\footnotesize\ttfamily nothing Qore\+::\+File\+::set\+Terminal\+Attributes (\begin{DoxyParamCaption}\item[{softint}]{action = {\ttfamily \mbox{\hyperlink{group__tattr__term__setting__constants_ga1e9c9ecc5ab9180c3665ba2115c792a0}{TCSANOW}}}, }\item[{\mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}}}]{termios }\end{DoxyParamCaption})} Sets the current terminal attributes for the File from the \mbox{\hyperlink{class_qore_1_1_term_i_o_s}{Term\+IOS}} object passed; does not change the object passed. \begin{DoxyParagraph}{Platform Availability\+:} \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Qore\+::\+Option\+::\+HAVE\+\_\+\+TERMIOS}} \end{DoxyParagraph} \begin{DoxyParagraph}{Example\+:} \begin{DoxyCode}{0} \DoxyCodeLine{TermIOS termios();} \DoxyCodeLine{stdin.getTerminalAttributes(termios);} \DoxyCodeLine{TermIOS orig = termios.copy();} \DoxyCodeLine{on\_exit} \DoxyCodeLine{ stdin.setTerminalAttributes(TCSADRAIN, orig);} \DoxyCodeLine{} \DoxyCodeLine{int lflag = termios.getLFlag();} \DoxyCodeLine{lflag \&= \string~ICANON;} \DoxyCodeLine{lflag \&= \string~ECHO;} \DoxyCodeLine{lflag \&= \string~ISIG;} \DoxyCodeLine{termios.setLFlag(lflag);} \DoxyCodeLine{termios.setCC(VMIN, 1);} \DoxyCodeLine{termios.setCC(VTIME, 0);} \DoxyCodeLine{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}{TCSANOW}}\+: the change occurs immediately \item \mbox{\hyperlink{group__tattr__term__setting__constants_ga9d4186bd3d8efad89a2d5ef9a1bdac32}{TCSADRAIN}}\+: 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}{TCSAFLUSH}}\+: 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}{TCSASOFT}}\+: 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\+IOS}} to use\\ \hline \end{DoxyParams} \begin{DoxyExceptions}{Exceptions} {\em FILE-\/\+OPERATION-\/\+ERROR} & the File is not open \\ \hline {\em TERMIOS-\/\+SET-\/\+ERROR} & error setting terminal attributes on the file descriptor \\ \hline {\em MISSING-\/\+FEATURE-\/\+ERROR} & this method is not supported on this platform; check \mbox{\hyperlink{group__option__constants_ga98899bee8f8dda3f4b1feed875118b85}{Option\+::\+HAVE\+\_\+\+TERMIOS}} before calling this method to avoid this exception \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{\textcolor{keywordflow}{if} (f.sync())} \DoxyCodeLine{ \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{printf}}(\textcolor{stringliteral}{"{}error in File::sync(): \%s\(\backslash\)n"{}}, strerror(errno()));} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyReturn}{Returns} 0 for success, -\/1 for error (see \mbox{\hyperlink{namespace_qore_abcf45c25ca1234fc8c54761750324cda}{errno()}} and \mbox{\hyperlink{namespace_qore_a13d9bb498eef9caffe641130bd8a1c73}{strerror()}} for the error information) \end{DoxyReturn} \begin{DoxyExceptions}{Exceptions} {\em ILLEGAL-\/\+EXPRESSION} & 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_a8e508aabefedf9fa70c42d0e5fab5959}\label{class_qore_1_1_file_a8e508aabefedf9fa70c42d0e5fab5959}} \index{Qore::File@{Qore::File}!vprintf@{vprintf}} \index{vprintf@{vprintf}!Qore::File@{Qore::File}} \doxysubsubsection{\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}{ }\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}{RUNTIME\+\_\+\+NOOP}} \end{DoxyParagraph} \begin{DoxyReturn}{Returns} a constant 0 \end{DoxyReturn} \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}} \doxysubsubsection{\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}\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}{0} \DoxyCodeLine{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}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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_acd30e6f14435bae0393b1ed52bec502d}\label{class_qore_1_1_file_acd30e6f14435bae0393b1ed52bec502d}} \index{Qore::File@{Qore::File}!write@{write}} \index{write@{write}!Qore::File@{Qore::File}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.write(data);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.write(data);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ENCODING-\/\+CONVERSION-\/\+ERROR} & 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 ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.writei1(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.writei2(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!writei2LSB@{writei2LSB}} \index{writei2LSB@{writei2LSB}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{writei2LSB()}{writei2LSB()}} {\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei2\+LSB (\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}{0} \DoxyCodeLine{f.writei2LSB(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.writei4(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!writei4LSB@{writei4LSB}} \index{writei4LSB@{writei4LSB}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{writei4LSB()}{writei4LSB()}} {\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei4\+LSB (\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}{0} \DoxyCodeLine{f.writei4LSB(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}} \doxysubsubsection{\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}{0} \DoxyCodeLine{f.writei8(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}!writei8LSB@{writei8LSB}} \index{writei8LSB@{writei8LSB}!Qore::File@{Qore::File}} \doxysubsubsection{\texorpdfstring{writei8LSB()}{writei8LSB()}} {\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+File\+::writei8\+LSB (\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}{0} \DoxyCodeLine{f.writei8LSB(val);} \end{DoxyCode} \end{DoxyParagraph} \begin{DoxyParagraph}{Events\+:} \mbox{\hyperlink{event_handling_EVENT_DATA_WRITTEN}{EVENT\+\_\+\+DATA\+\_\+\+WRITTEN}} \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 FILE-\/\+WRITE-\/\+ERROR} & File is not open or an I/O error occurred writing data to the \mbox{\hyperlink{class_qore_1_1_file}{File}} \\ \hline {\em ILLEGAL-\/\+EXPRESSION} & 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}