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