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