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 module gio.FileInputStream;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.FileInfo;
30 private import gio.InputStream;
31 private import gio.SeekableIF;
32 private import gio.SeekableT;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import glib.Str;
36 private import gobject.ObjectG;
37 private import gtkc.gio;
38 public  import gtkc.giotypes;
39 
40 
41 /**
42  * GFileInputStream provides input streams that take their
43  * content from a file.
44  * 
45  * GFileInputStream implements #GSeekable, which allows the input
46  * stream to jump to arbitrary positions in the file, provided the
47  * filesystem of the file allows it. To find the position of a file
48  * input stream, use g_seekable_tell(). To find out if a file input
49  * stream supports seeking, use g_seekable_can_seek().
50  * To position a file input stream, use g_seekable_seek().
51  */
52 public class FileInputStream : InputStream, SeekableIF
53 {
54 	/** the main Gtk struct */
55 	protected GFileInputStream* gFileInputStream;
56 
57 	/** Get the main Gtk struct */
58 	public GFileInputStream* getFileInputStreamStruct()
59 	{
60 		return gFileInputStream;
61 	}
62 
63 	/** the main Gtk struct as a void* */
64 	protected override void* getStruct()
65 	{
66 		return cast(void*)gFileInputStream;
67 	}
68 
69 	protected override void setStruct(GObject* obj)
70 	{
71 		gFileInputStream = cast(GFileInputStream*)obj;
72 		super.setStruct(obj);
73 	}
74 
75 	/**
76 	 * Sets our main struct and passes it to the parent class.
77 	 */
78 	public this (GFileInputStream* gFileInputStream, bool ownedRef = false)
79 	{
80 		this.gFileInputStream = gFileInputStream;
81 		super(cast(GInputStream*)gFileInputStream, ownedRef);
82 	}
83 
84 	// add the Seekable capabilities
85 	mixin SeekableT!(GFileInputStream);
86 
87 	/**
88 	 */
89 
90 	public static GType getType()
91 	{
92 		return g_file_input_stream_get_type();
93 	}
94 
95 	/**
96 	 * Queries a file input stream the given @attributes. This function blocks
97 	 * while querying the stream. For the asynchronous (non-blocking) version
98 	 * of this function, see g_file_input_stream_query_info_async(). While the
99 	 * stream is blocked, the stream will set the pending flag internally, and
100 	 * any other operations on the stream will fail with %G_IO_ERROR_PENDING.
101 	 *
102 	 * Params:
103 	 *     attributes = a file attribute query string.
104 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
105 	 *
106 	 * Return: a #GFileInfo, or %NULL on error.
107 	 *
108 	 * Throws: GException on failure.
109 	 */
110 	public FileInfo queryInfo(string attributes, Cancellable cancellable)
111 	{
112 		GError* err = null;
113 		
114 		auto p = g_file_input_stream_query_info(gFileInputStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
115 		
116 		if (err !is null)
117 		{
118 			throw new GException( new ErrorG(err) );
119 		}
120 		
121 		if(p is null)
122 		{
123 			return null;
124 		}
125 		
126 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true);
127 	}
128 
129 	/**
130 	 * Queries the stream information asynchronously.
131 	 * When the operation is finished @callback will be called.
132 	 * You can then call g_file_input_stream_query_info_finish()
133 	 * to get the result of the operation.
134 	 *
135 	 * For the synchronous version of this function,
136 	 * see g_file_input_stream_query_info().
137 	 *
138 	 * If @cancellable is not %NULL, then the operation can be cancelled by
139 	 * triggering the cancellable object from another thread. If the operation
140 	 * was cancelled, the error %G_IO_ERROR_CANCELLED will be set
141 	 *
142 	 * Params:
143 	 *     attributes = a file attribute query string.
144 	 *     ioPriority = the [I/O priority][io-priority] of the request
145 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
146 	 *     callback = callback to call when the request is satisfied
147 	 *     userData = the data to pass to callback function
148 	 */
149 	public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
150 	{
151 		g_file_input_stream_query_info_async(gFileInputStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
152 	}
153 
154 	/**
155 	 * Finishes an asynchronous info query operation.
156 	 *
157 	 * Params:
158 	 *     result = a #GAsyncResult.
159 	 *
160 	 * Return: #GFileInfo.
161 	 *
162 	 * Throws: GException on failure.
163 	 */
164 	public FileInfo queryInfoFinish(AsyncResultIF result)
165 	{
166 		GError* err = null;
167 		
168 		auto p = g_file_input_stream_query_info_finish(gFileInputStream, (result is null) ? null : result.getAsyncResultStruct(), &err);
169 		
170 		if (err !is null)
171 		{
172 			throw new GException( new ErrorG(err) );
173 		}
174 		
175 		if(p is null)
176 		{
177 			return null;
178 		}
179 		
180 		return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p, true);
181 	}
182 }