Tizen 2.1 base
[platform/upstream/glib2.0.git] / docs / reference / gio / html / GFileOutputStream.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GFileOutputStream</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="streaming.html" title="Streaming I/O">
9 <link rel="prev" href="GFileInputStream.html" title="GFileInputStream">
10 <link rel="next" href="GFileIOStream.html" title="GFileIOStream">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="GFileInputStream.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="streaming.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GIO Reference Manual</th>
21 <td><a accesskey="n" href="GFileIOStream.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#GFileOutputStream.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#GFileOutputStream.description" class="shortcut">Description</a>
27                    | 
28                   <a href="#GFileOutputStream.object-hierarchy" class="shortcut">Object Hierarchy</a>
29                    | 
30                   <a href="#GFileOutputStream.implemented-interfaces" class="shortcut">Implemented Interfaces</a>
31 </td></tr>
32 </table>
33 <div class="refentry">
34 <a name="GFileOutputStream"></a><div class="titlepage"></div>
35 <div class="refnamediv"><table width="100%"><tr>
36 <td valign="top">
37 <h2><span class="refentrytitle"><a name="GFileOutputStream.top_of_page"></a>GFileOutputStream</span></h2>
38 <p>GFileOutputStream — File output streaming operations</p>
39 </td>
40 <td valign="top" align="right"></td>
41 </tr></table></div>
42 <div class="refsynopsisdiv">
43 <a name="GFileOutputStream.synopsis"></a><h2>Synopsis</h2>
44 <pre class="synopsis">
45 #include &lt;gio/gio.h&gt;
46
47                     <a class="link" href="GFileOutputStream.html#GFileOutputStream-struct" title="GFileOutputStream">GFileOutputStream</a>;
48 <a class="link" href="GFileInfo.html" title="GFileInfo"><span class="returnvalue">GFileInfo</span></a> *         <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info" title="g_file_output_stream_query_info ()">g_file_output_stream_query_info</a>     (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
49                                                          <em class="parameter"><code>const <span class="type">char</span> *attributes</code></em>,
50                                                          <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
51                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
52 <span class="returnvalue">void</span>                <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info-async" title="g_file_output_stream_query_info_async ()">g_file_output_stream_query_info_async</a>
53                                                         (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
54                                                          <em class="parameter"><code>const <span class="type">char</span> *attributes</code></em>,
55                                                          <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
56                                                          <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
57                                                          <em class="parameter"><code><a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
58                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
59 <a class="link" href="GFileInfo.html" title="GFileInfo"><span class="returnvalue">GFileInfo</span></a> *         <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info-finish" title="g_file_output_stream_query_info_finish ()">g_file_output_stream_query_info_finish</a>
60                                                         (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
61                                                          <em class="parameter"><code><a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *result</code></em>,
62                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
63 <span class="returnvalue">char</span> *              <a class="link" href="GFileOutputStream.html#g-file-output-stream-get-etag" title="g_file_output_stream_get_etag ()">g_file_output_stream_get_etag</a>       (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>);
64 </pre>
65 </div>
66 <div class="refsect1">
67 <a name="GFileOutputStream.object-hierarchy"></a><h2>Object Hierarchy</h2>
68 <pre class="synopsis">
69   <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>
70    +----<a class="link" href="GOutputStream.html" title="GOutputStream">GOutputStream</a>
71          +----GFileOutputStream
72 </pre>
73 </div>
74 <div class="refsect1">
75 <a name="GFileOutputStream.implemented-interfaces"></a><h2>Implemented Interfaces</h2>
76 <p>
77 GFileOutputStream implements
78  <a class="link" href="GSeekable.html" title="GSeekable">GSeekable</a>.</p>
79 </div>
80 <div class="refsect1">
81 <a name="GFileOutputStream.description"></a><h2>Description</h2>
82 <p>
83 GFileOutputStream provides output streams that write their
84 content to a file.
85 </p>
86 <p>
87 GFileOutputStream implements <a class="link" href="GSeekable.html" title="GSeekable"><span class="type">GSeekable</span></a>, which allows the output 
88 stream to jump to arbitrary positions in the file and to truncate
89 the file, provided the filesystem of the file supports these 
90 operations.
91 </p>
92 <p>
93 To find the position of a file output stream, use <a class="link" href="GSeekable.html#g-seekable-tell" title="g_seekable_tell ()"><code class="function">g_seekable_tell()</code></a>.
94 To find out if a file output stream supports seeking, use
95 <a class="link" href="GSeekable.html#g-seekable-can-seek" title="g_seekable_can_seek ()"><code class="function">g_seekable_can_seek()</code></a>.To position a file output stream, use
96 <a class="link" href="GSeekable.html#g-seekable-seek" title="g_seekable_seek ()"><code class="function">g_seekable_seek()</code></a>. To find out if a file output stream supports
97 truncating, use <a class="link" href="GSeekable.html#g-seekable-can-truncate" title="g_seekable_can_truncate ()"><code class="function">g_seekable_can_truncate()</code></a>. To truncate a file output
98 stream, use <a class="link" href="GSeekable.html#g-seekable-truncate" title="g_seekable_truncate ()"><code class="function">g_seekable_truncate()</code></a>.
99 </p>
100 </div>
101 <div class="refsect1">
102 <a name="GFileOutputStream.details"></a><h2>Details</h2>
103 <div class="refsect2">
104 <a name="GFileOutputStream-struct"></a><h3>GFileOutputStream</h3>
105 <pre class="programlisting">typedef struct _GFileOutputStream GFileOutputStream;</pre>
106 <p>
107 A subclass of GOutputStream for opened files. This adds
108 a few file-specific operations and seeking and truncating.
109 </p>
110 <p>
111 <a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> implements GSeekable.
112 </p>
113 </div>
114 <hr>
115 <div class="refsect2">
116 <a name="g-file-output-stream-query-info"></a><h3>g_file_output_stream_query_info ()</h3>
117 <pre class="programlisting"><a class="link" href="GFileInfo.html" title="GFileInfo"><span class="returnvalue">GFileInfo</span></a> *         g_file_output_stream_query_info     (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
118                                                          <em class="parameter"><code>const <span class="type">char</span> *attributes</code></em>,
119                                                          <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
120                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
121 <p>
122 Queries a file output stream for the given <em class="parameter"><code>attributes</code></em>. 
123 This function blocks while querying the stream. For the asynchronous 
124 version of this function, see <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info-async" title="g_file_output_stream_query_info_async ()"><code class="function">g_file_output_stream_query_info_async()</code></a>. 
125 While the stream is blocked, the stream will set the pending flag 
126 internally, and any other operations on the stream will fail with 
127 <a class="link" href="gio-GIOError.html#G-IO-ERROR-PENDING:CAPS"><code class="literal">G_IO_ERROR_PENDING</code></a>.
128 </p>
129 <p>
130 Can fail if the stream was already closed (with <em class="parameter"><code>error</code></em> being set to 
131 <a class="link" href="gio-GIOError.html#G-IO-ERROR-CLOSED:CAPS"><code class="literal">G_IO_ERROR_CLOSED</code></a>), the stream has pending operations (with <em class="parameter"><code>error</code></em> being
132 set to <a class="link" href="gio-GIOError.html#G-IO-ERROR-PENDING:CAPS"><code class="literal">G_IO_ERROR_PENDING</code></a>), or if querying info is not supported for 
133 the stream's interface (with <em class="parameter"><code>error</code></em> being set to <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a>). In
134 all cases of failure, <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> will be returned.
135 </p>
136 <p>
137 If <em class="parameter"><code>cancellable</code></em> is not <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, then the operation can be cancelled by
138 triggering the cancellable object from another thread. If the operation
139 was cancelled, the error <a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> will be set, and <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> will 
140 be returned.
141 </p>
142 <div class="variablelist"><table border="0">
143 <col align="left" valign="top">
144 <tbody>
145 <tr>
146 <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
147 <td>a <a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a>.</td>
148 </tr>
149 <tr>
150 <td><p><span class="term"><em class="parameter"><code>attributes</code></em> :</span></p></td>
151 <td>a file attribute query string.</td>
152 </tr>
153 <tr>
154 <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
155 <td>optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
156 </tr>
157 <tr>
158 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
159 <td>a <a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
160 </tr>
161 <tr>
162 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
163 <td>a <a class="link" href="GFileInfo.html" title="GFileInfo"><span class="type">GFileInfo</span></a> for the <em class="parameter"><code>stream</code></em>, or <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
164 </td>
165 </tr>
166 </tbody>
167 </table></div>
168 </div>
169 <hr>
170 <div class="refsect2">
171 <a name="g-file-output-stream-query-info-async"></a><h3>g_file_output_stream_query_info_async ()</h3>
172 <pre class="programlisting"><span class="returnvalue">void</span>                g_file_output_stream_query_info_async
173                                                         (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
174                                                          <em class="parameter"><code>const <span class="type">char</span> *attributes</code></em>,
175                                                          <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
176                                                          <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
177                                                          <em class="parameter"><code><a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
178                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
179 <p>
180 Asynchronously queries the <em class="parameter"><code>stream</code></em> for a <a class="link" href="GFileInfo.html" title="GFileInfo"><span class="type">GFileInfo</span></a>. When completed,
181 <em class="parameter"><code>callback</code></em> will be called with a <a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a> which can be used to 
182 finish the operation with <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info-finish" title="g_file_output_stream_query_info_finish ()"><code class="function">g_file_output_stream_query_info_finish()</code></a>.
183 </p>
184 <p>
185 For the synchronous version of this function, see 
186 <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info" title="g_file_output_stream_query_info ()"><code class="function">g_file_output_stream_query_info()</code></a>.
187 </p>
188 <div class="variablelist"><table border="0">
189 <col align="left" valign="top">
190 <tbody>
191 <tr>
192 <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
193 <td>a <a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a>.</td>
194 </tr>
195 <tr>
196 <td><p><span class="term"><em class="parameter"><code>attributes</code></em> :</span></p></td>
197 <td>a file attribute query string.</td>
198 </tr>
199 <tr>
200 <td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td>
201 <td>the <a class="link" href="gio-GIOScheduler.html" title="GIOScheduler">I/O priority</a>
202 of the request.</td>
203 </tr>
204 <tr>
205 <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
206 <td>optional <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
207 </tr>
208 <tr>
209 <td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
210 <td>callback to call when the request is satisfied</td>
211 </tr>
212 <tr>
213 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
214 <td>the data to pass to callback function</td>
215 </tr>
216 </tbody>
217 </table></div>
218 </div>
219 <hr>
220 <div class="refsect2">
221 <a name="g-file-output-stream-query-info-finish"></a><h3>g_file_output_stream_query_info_finish ()</h3>
222 <pre class="programlisting"><a class="link" href="GFileInfo.html" title="GFileInfo"><span class="returnvalue">GFileInfo</span></a> *         g_file_output_stream_query_info_finish
223                                                         (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>,
224                                                          <em class="parameter"><code><a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *result</code></em>,
225                                                          <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
226 <p>
227 Finalizes the asynchronous query started 
228 by <a class="link" href="GFileOutputStream.html#g-file-output-stream-query-info-async" title="g_file_output_stream_query_info_async ()"><code class="function">g_file_output_stream_query_info_async()</code></a>.
229 </p>
230 <div class="variablelist"><table border="0">
231 <col align="left" valign="top">
232 <tbody>
233 <tr>
234 <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
235 <td>a <a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a>.</td>
236 </tr>
237 <tr>
238 <td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
239 <td>a <a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a>.</td>
240 </tr>
241 <tr>
242 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
243 <td>a <a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, <a href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
244 </tr>
245 <tr>
246 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
247 <td>A <a class="link" href="GFileInfo.html" title="GFileInfo"><span class="type">GFileInfo</span></a> for the finished query. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
248 </td>
249 </tr>
250 </tbody>
251 </table></div>
252 </div>
253 <hr>
254 <div class="refsect2">
255 <a name="g-file-output-stream-get-etag"></a><h3>g_file_output_stream_get_etag ()</h3>
256 <pre class="programlisting"><span class="returnvalue">char</span> *              g_file_output_stream_get_etag       (<em class="parameter"><code><a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a> *stream</code></em>);</pre>
257 <p>
258 Gets the entity tag for the file when it has been written.
259 This must be called after the stream has been written
260 and closed, as the etag can change while writing.
261 </p>
262 <div class="variablelist"><table border="0">
263 <col align="left" valign="top">
264 <tbody>
265 <tr>
266 <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
267 <td>a <a class="link" href="GFileOutputStream.html" title="GFileOutputStream"><span class="type">GFileOutputStream</span></a>.</td>
268 </tr>
269 <tr>
270 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
271 <td>the entity tag for the stream.</td>
272 </tr>
273 </tbody>
274 </table></div>
275 </div>
276 </div>
277 <div class="refsect1">
278 <a name="GFileOutputStream.see-also"></a><h2>See Also</h2>
279 <a class="link" href="GOutputStream.html" title="GOutputStream"><span class="type">GOutputStream</span></a>, <a class="link" href="GDataOutputStream.html" title="GDataOutputStream"><span class="type">GDataOutputStream</span></a>, <a class="link" href="GSeekable.html" title="GSeekable"><span class="type">GSeekable</span></a>
280 </div>
281 </div>
282 <div class="footer">
283 <hr>
284           Generated by GTK-Doc V1.18</div>
285 </body>
286 </html>