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