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  = GFileInputStream.html
27  * outPack = gio
28  * outFile = FileInputStream
29  * strct   = GFileInputStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileInputStream
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- SeekableIF
40  * prefixes:
41  * 	- g_file_input_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.FileInputStream;
65 
66 public  import gtkc.giotypes;
67 
68 private import gtkc.gio;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 private import glib.Str;
73 private import glib.ErrorG;
74 private import glib.GException;
75 private import gio.AsyncResultIF;
76 private import gio.Cancellable;
77 private import gio.FileInfo;
78 private import gio.SeekableT;
79 private import gio.SeekableIF;
80 
81 
82 private import gio.InputStream;
83 
84 /**
85  * GFileInputStream provides input streams that take their
86  * content from a file.
87  *
88  * GFileInputStream implements GSeekable, which allows the input
89  * stream to jump to arbitrary positions in the file, provided the
90  * filesystem of the file allows it. To find the position of a file
91  * input stream, use g_seekable_tell(). To find out if a file input
92  * stream supports seeking, use g_seekable_can_seek().
93  * To position a file input stream, use g_seekable_seek().
94  */
95 public class FileInputStream : InputStream, SeekableIF
96 {
97 	
98 	/** the main Gtk struct */
99 	protected GFileInputStream* gFileInputStream;
100 	
101 	
102 	/** Get the main Gtk struct */
103 	public GFileInputStream* getFileInputStreamStruct()
104 	{
105 		return gFileInputStream;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected override void* getStruct()
111 	{
112 		return cast(void*)gFileInputStream;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (GFileInputStream* gFileInputStream)
119 	{
120 		super(cast(GInputStream*)gFileInputStream);
121 		this.gFileInputStream = gFileInputStream;
122 	}
123 	
124 	protected override void setStruct(GObject* obj)
125 	{
126 		super.setStruct(obj);
127 		gFileInputStream = cast(GFileInputStream*)obj;
128 	}
129 	
130 	// add the Seekable capabilities
131 	mixin SeekableT!(GFileInputStream);
132 	
133 	/**
134 	 */
135 	
136 	/**
137 	 * Queries a file input stream the given attributes. This function blocks
138 	 * while querying the stream. For the asynchronous (non-blocking) version
139 	 * of this function, see g_file_input_stream_query_info_async(). While the
140 	 * stream is blocked, the stream will set the pending flag internally, and
141 	 * any other operations on the stream will fail with G_IO_ERROR_PENDING.
142 	 * Params:
143 	 * attributes = a file attribute query string.
144 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
145 	 * Returns: a GFileInfo, or NULL on error. [transfer full]
146 	 * Throws: GException on failure.
147 	 */
148 	public FileInfo queryInfo(string attributes, Cancellable cancellable)
149 	{
150 		// GFileInfo * g_file_input_stream_query_info (GFileInputStream *stream,  const char *attributes,  GCancellable *cancellable,  GError **error);
151 		GError* err = null;
152 		
153 		auto p = g_file_input_stream_query_info(gFileInputStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
154 		
155 		if (err !is null)
156 		{
157 			throw new GException( new ErrorG(err) );
158 		}
159 		
160 		
161 		if(p is null)
162 		{
163 			return null;
164 		}
165 		
166 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p);
167 	}
168 	
169 	/**
170 	 * Queries the stream information asynchronously.
171 	 * When the operation is finished callback will be called.
172 	 * You can then call g_file_input_stream_query_info_finish()
173 	 * to get the result of the operation.
174 	 * For the synchronous version of this function,
175 	 * see g_file_input_stream_query_info().
176 	 * If cancellable is not NULL, then the operation can be cancelled by
177 	 * triggering the cancellable object from another thread. If the operation
178 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be set
179 	 * Params:
180 	 * attributes = a file attribute query string.
181 	 * ioPriority = the I/O priority
182 	 * of the request.
183 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
184 	 * callback = callback to call when the request is satisfied. [scope async]
185 	 * userData = the data to pass to callback function. [closure]
186 	 */
187 	public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
188 	{
189 		// void g_file_input_stream_query_info_async  (GFileInputStream *stream,  const char *attributes,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
190 		g_file_input_stream_query_info_async(gFileInputStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
191 	}
192 	
193 	/**
194 	 * Finishes an asynchronous info query operation.
195 	 * Params:
196 	 * result = a GAsyncResult.
197 	 * Returns: GFileInfo. [transfer full]
198 	 * Throws: GException on failure.
199 	 */
200 	public FileInfo queryInfoFinish(AsyncResultIF result)
201 	{
202 		// GFileInfo * g_file_input_stream_query_info_finish  (GFileInputStream *stream,  GAsyncResult *result,  GError **error);
203 		GError* err = null;
204 		
205 		auto p = g_file_input_stream_query_info_finish(gFileInputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
206 		
207 		if (err !is null)
208 		{
209 			throw new GException( new ErrorG(err) );
210 		}
211 		
212 		
213 		if(p is null)
214 		{
215 			return null;
216 		}
217 		
218 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p);
219 	}
220 }