1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GFileOutputStream.html
27  * outPack = gio
28  * outFile = FileOutputStream
29  * strct   = GFileOutputStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileOutputStream
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- SeekableIF
40  * prefixes:
41  * 	- g_file_output_stream_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gio.AsyncResultIF
51  * 	- gio.Cancellable
52  * 	- gio.FileInfo
53  * 	- gio.SeekableT
54  * 	- gio.SeekableIF
55  * structWrap:
56  * 	- GAsyncResult* -> AsyncResultIF
57  * 	- GCancellable* -> Cancellable
58  * 	- GFileInfo* -> FileInfo
59  * module aliases:
60  * local aliases:
61  * overrides:
62  */
63 
64 module gio.FileOutputStream;
65 
66 public  import gtkc.giotypes;
67 
68 private import gtkc.gio;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 
73 private import glib.Str;
74 private import glib.ErrorG;
75 private import glib.GException;
76 private import gio.AsyncResultIF;
77 private import gio.Cancellable;
78 private import gio.FileInfo;
79 private import gio.SeekableT;
80 private import gio.SeekableIF;
81 
82 
83 
84 private import gio.OutputStream;
85 
86 /**
87  * GFileOutputStream provides output streams that write their
88  * content to a file.
89  *
90  * GFileOutputStream implements GSeekable, which allows the output
91  * stream to jump to arbitrary positions in the file and to truncate
92  * the file, provided the filesystem of the file supports these
93  * operations.
94  *
95  * To find the position of a file output stream, use g_seekable_tell().
96  * To find out if a file output stream supports seeking, use
97  * g_seekable_can_seek().To position a file output stream, use
98  * g_seekable_seek(). To find out if a file output stream supports
99  * truncating, use g_seekable_can_truncate(). To truncate a file output
100  * stream, use g_seekable_truncate().
101  */
102 public class FileOutputStream : OutputStream, SeekableIF
103 {
104 	
105 	/** the main Gtk struct */
106 	protected GFileOutputStream* gFileOutputStream;
107 	
108 	
109 	public GFileOutputStream* getFileOutputStreamStruct()
110 	{
111 		return gFileOutputStream;
112 	}
113 	
114 	
115 	/** the main Gtk struct as a void* */
116 	protected override void* getStruct()
117 	{
118 		return cast(void*)gFileOutputStream;
119 	}
120 	
121 	/**
122 	 * Sets our main struct and passes it to the parent class
123 	 */
124 	public this (GFileOutputStream* gFileOutputStream)
125 	{
126 		super(cast(GOutputStream*)gFileOutputStream);
127 		this.gFileOutputStream = gFileOutputStream;
128 	}
129 	
130 	protected override void setStruct(GObject* obj)
131 	{
132 		super.setStruct(obj);
133 		gFileOutputStream = cast(GFileOutputStream*)obj;
134 	}
135 	
136 	// add the Seekable capabilities
137 	mixin SeekableT!(GFileOutputStream);
138 	
139 	/**
140 	 */
141 	
142 	/**
143 	 * Queries a file output stream for the given attributes.
144 	 * This function blocks while querying the stream. For the asynchronous
145 	 * version of this function, see g_file_output_stream_query_info_async().
146 	 * While the stream is blocked, the stream will set the pending flag
147 	 * internally, and any other operations on the stream will fail with
148 	 * G_IO_ERROR_PENDING.
149 	 * Can fail if the stream was already closed (with error being set to
150 	 * G_IO_ERROR_CLOSED), the stream has pending operations (with error being
151 	 * set to G_IO_ERROR_PENDING), or if querying info is not supported for
152 	 * the stream's interface (with error being set to G_IO_ERROR_NOT_SUPPORTED). In
153 	 * all cases of failure, NULL will be returned.
154 	 * If cancellable is not NULL, then the operation can be cancelled by
155 	 * triggering the cancellable object from another thread. If the operation
156 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and NULL will
157 	 * be returned.
158 	 * Params:
159 	 * attributes = a file attribute query string.
160 	 * cancellable = optional GCancellable object, NULL to ignore.
161 	 * Returns: a GFileInfo for the stream, or NULL on error. [transfer full]
162 	 * Throws: GException on failure.
163 	 */
164 	public FileInfo queryInfo(string attributes, Cancellable cancellable)
165 	{
166 		// GFileInfo * g_file_output_stream_query_info (GFileOutputStream *stream,  const char *attributes,  GCancellable *cancellable,  GError **error);
167 		GError* err = null;
168 		
169 		auto p = g_file_output_stream_query_info(gFileOutputStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
170 		
171 		if (err !is null)
172 		{
173 			throw new GException( new ErrorG(err) );
174 		}
175 		
176 		
177 		if(p is null)
178 		{
179 			return null;
180 		}
181 		
182 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p);
183 	}
184 	
185 	/**
186 	 * Asynchronously queries the stream for a GFileInfo. When completed,
187 	 * callback will be called with a GAsyncResult which can be used to
188 	 * finish the operation with g_file_output_stream_query_info_finish().
189 	 * For the synchronous version of this function, see
190 	 * g_file_output_stream_query_info().
191 	 * Params:
192 	 * attributes = a file attribute query string.
193 	 * ioPriority = the I/O priority
194 	 * of the request.
195 	 * cancellable = optional GCancellable object, NULL to ignore.
196 	 * callback = callback to call when the request is satisfied
197 	 * userData = the data to pass to callback function
198 	 */
199 	public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
200 	{
201 		// void g_file_output_stream_query_info_async  (GFileOutputStream *stream,  const char *attributes,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
202 		g_file_output_stream_query_info_async(gFileOutputStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
203 	}
204 	
205 	/**
206 	 * Finalizes the asynchronous query started
207 	 * by g_file_output_stream_query_info_async().
208 	 * Params:
209 	 * result = a GAsyncResult.
210 	 * Returns: A GFileInfo for the finished query. [transfer full]
211 	 * Throws: GException on failure.
212 	 */
213 	public FileInfo queryInfoFinish(AsyncResultIF result)
214 	{
215 		// GFileInfo * g_file_output_stream_query_info_finish  (GFileOutputStream *stream,  GAsyncResult *result,  GError **error);
216 		GError* err = null;
217 		
218 		auto p = g_file_output_stream_query_info_finish(gFileOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
219 		
220 		if (err !is null)
221 		{
222 			throw new GException( new ErrorG(err) );
223 		}
224 		
225 		
226 		if(p is null)
227 		{
228 			return null;
229 		}
230 		
231 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p);
232 	}
233 	
234 	/**
235 	 * Gets the entity tag for the file when it has been written.
236 	 * This must be called after the stream has been written
237 	 * and closed, as the etag can change while writing.
238 	 * Returns: the entity tag for the stream.
239 	 */
240 	public string getEtag()
241 	{
242 		// char * g_file_output_stream_get_etag (GFileOutputStream *stream);
243 		return Str.toString(g_file_output_stream_get_etag(gFileOutputStream));
244 	}
245 }