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 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.OutputStream; 83 84 /** 85 * GFileOutputStream provides output streams that write their 86 * content to a file. 87 * 88 * GFileOutputStream implements GSeekable, which allows the output 89 * stream to jump to arbitrary positions in the file and to truncate 90 * the file, provided the filesystem of the file supports these 91 * operations. 92 * 93 * To find the position of a file output stream, use g_seekable_tell(). 94 * To find out if a file output stream supports seeking, use 95 * g_seekable_can_seek().To position a file output stream, use 96 * g_seekable_seek(). To find out if a file output stream supports 97 * truncating, use g_seekable_can_truncate(). To truncate a file output 98 * stream, use g_seekable_truncate(). 99 */ 100 public class FileOutputStream : OutputStream, SeekableIF 101 { 102 103 /** the main Gtk struct */ 104 protected GFileOutputStream* gFileOutputStream; 105 106 107 /** Get the main Gtk struct */ 108 public GFileOutputStream* getFileOutputStreamStruct() 109 { 110 return gFileOutputStream; 111 } 112 113 114 /** the main Gtk struct as a void* */ 115 protected override void* getStruct() 116 { 117 return cast(void*)gFileOutputStream; 118 } 119 120 /** 121 * Sets our main struct and passes it to the parent class 122 */ 123 public this (GFileOutputStream* gFileOutputStream) 124 { 125 super(cast(GOutputStream*)gFileOutputStream); 126 this.gFileOutputStream = gFileOutputStream; 127 } 128 129 protected override void setStruct(GObject* obj) 130 { 131 super.setStruct(obj); 132 gFileOutputStream = cast(GFileOutputStream*)obj; 133 } 134 135 // add the Seekable capabilities 136 mixin SeekableT!(GFileOutputStream); 137 138 /** 139 */ 140 141 /** 142 * Queries a file output stream for the given attributes. 143 * This function blocks while querying the stream. For the asynchronous 144 * version of this function, see g_file_output_stream_query_info_async(). 145 * While the stream is blocked, the stream will set the pending flag 146 * internally, and any other operations on the stream will fail with 147 * G_IO_ERROR_PENDING. 148 * Can fail if the stream was already closed (with error being set to 149 * G_IO_ERROR_CLOSED), the stream has pending operations (with error being 150 * set to G_IO_ERROR_PENDING), or if querying info is not supported for 151 * the stream's interface (with error being set to G_IO_ERROR_NOT_SUPPORTED). In 152 * all cases of failure, NULL will be returned. 153 * If cancellable is not NULL, then the operation can be cancelled by 154 * triggering the cancellable object from another thread. If the operation 155 * was cancelled, the error G_IO_ERROR_CANCELLED will be set, and NULL will 156 * be returned. 157 * Params: 158 * attributes = a file attribute query string. 159 * cancellable = optional GCancellable object, NULL to ignore. 160 * Returns: a GFileInfo for the stream, or NULL on error. [transfer full] 161 * Throws: GException on failure. 162 */ 163 public FileInfo queryInfo(string attributes, Cancellable cancellable) 164 { 165 // GFileInfo * g_file_output_stream_query_info (GFileOutputStream *stream, const char *attributes, GCancellable *cancellable, GError **error); 166 GError* err = null; 167 168 auto p = g_file_output_stream_query_info(gFileOutputStream, Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 169 170 if (err !is null) 171 { 172 throw new GException( new ErrorG(err) ); 173 } 174 175 176 if(p is null) 177 { 178 return null; 179 } 180 181 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p); 182 } 183 184 /** 185 * Asynchronously queries the stream for a GFileInfo. When completed, 186 * callback will be called with a GAsyncResult which can be used to 187 * finish the operation with g_file_output_stream_query_info_finish(). 188 * For the synchronous version of this function, see 189 * g_file_output_stream_query_info(). 190 * Params: 191 * attributes = a file attribute query string. 192 * ioPriority = the I/O priority 193 * of the request. 194 * cancellable = optional GCancellable object, NULL to ignore. 195 * callback = callback to call when the request is satisfied 196 * userData = the data to pass to callback function 197 */ 198 public void queryInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 199 { 200 // void g_file_output_stream_query_info_async (GFileOutputStream *stream, const char *attributes, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 201 g_file_output_stream_query_info_async(gFileOutputStream, Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 202 } 203 204 /** 205 * Finalizes the asynchronous query started 206 * by g_file_output_stream_query_info_async(). 207 * Params: 208 * result = a GAsyncResult. 209 * Returns: A GFileInfo for the finished query. [transfer full] 210 * Throws: GException on failure. 211 */ 212 public FileInfo queryInfoFinish(AsyncResultIF result) 213 { 214 // GFileInfo * g_file_output_stream_query_info_finish (GFileOutputStream *stream, GAsyncResult *result, GError **error); 215 GError* err = null; 216 217 auto p = g_file_output_stream_query_info_finish(gFileOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err); 218 219 if (err !is null) 220 { 221 throw new GException( new ErrorG(err) ); 222 } 223 224 225 if(p is null) 226 { 227 return null; 228 } 229 230 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) p); 231 } 232 233 /** 234 * Gets the entity tag for the file when it has been written. 235 * This must be called after the stream has been written 236 * and closed, as the etag can change while writing. 237 * Returns: the entity tag for the stream. 238 */ 239 public string getEtag() 240 { 241 // char * g_file_output_stream_get_etag (GFileOutputStream *stream); 242 return Str.toString(g_file_output_stream_get_etag(gFileOutputStream)); 243 } 244 }