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.SeekableIF; 26 27 private import gio.Cancellable; 28 private import gio.c.functions; 29 public import gio.c.types; 30 private import glib.ErrorG; 31 private import glib.GException; 32 public import gtkc.giotypes; 33 34 35 /** 36 * #GSeekable is implemented by streams (implementations of 37 * #GInputStream or #GOutputStream) that support seeking. 38 * 39 * Seekable streams largely fall into two categories: resizable and 40 * fixed-size. 41 * 42 * #GSeekable on fixed-sized streams is approximately the same as POSIX 43 * lseek() on a block device (for example: attmepting to seek past the 44 * end of the device is an error). Fixed streams typically cannot be 45 * truncated. 46 * 47 * #GSeekable on resizable streams is approximately the same as POSIX 48 * lseek() on a normal file. Seeking past the end and writing data will 49 * usually cause the stream to resize by introducing zero bytes. 50 */ 51 public interface SeekableIF{ 52 /** Get the main Gtk struct */ 53 public GSeekable* getSeekableStruct(bool transferOwnership = false); 54 55 /** the main Gtk struct as a void* */ 56 protected void* getStruct(); 57 58 59 /** */ 60 public static GType getType() 61 { 62 return g_seekable_get_type(); 63 } 64 65 /** 66 * Tests if the stream supports the #GSeekableIface. 67 * 68 * Returns: %TRUE if @seekable can be seeked. %FALSE otherwise. 69 */ 70 public bool canSeek(); 71 72 /** 73 * Tests if the length of the stream can be adjusted with 74 * g_seekable_truncate(). 75 * 76 * Returns: %TRUE if the stream can be truncated, %FALSE otherwise. 77 */ 78 public bool canTruncate(); 79 80 /** 81 * Seeks in the stream by the given @offset, modified by @type. 82 * 83 * Attempting to seek past the end of the stream will have different 84 * results depending on if the stream is fixed-sized or resizable. If 85 * the stream is resizable then seeking past the end and then writing 86 * will result in zeros filling the empty space. Seeking past the end 87 * of a resizable stream and reading will result in EOF. Seeking past 88 * the end of a fixed-sized stream will fail. 89 * 90 * Any operation that would result in a negative offset will fail. 91 * 92 * If @cancellable is not %NULL, then the operation can be cancelled by 93 * triggering the cancellable object from another thread. If the operation 94 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 95 * 96 * Params: 97 * offset = a #goffset. 98 * type = a #GSeekType. 99 * cancellable = optional #GCancellable object, %NULL to ignore. 100 * 101 * Returns: %TRUE if successful. If an error 102 * has occurred, this function will return %FALSE and set @error 103 * appropriately if present. 104 * 105 * Throws: GException on failure. 106 */ 107 public bool seek(long offset, GSeekType type, Cancellable cancellable); 108 109 /** 110 * Tells the current position within the stream. 111 * 112 * Returns: the offset from the beginning of the buffer. 113 */ 114 public long tell(); 115 116 /** 117 * Sets the length of the stream to @offset. If the stream was previously 118 * larger than @offset, the extra data is discarded. If the stream was 119 * previouly shorter than @offset, it is extended with NUL ('\0') bytes. 120 * 121 * If @cancellable is not %NULL, then the operation can be cancelled by 122 * triggering the cancellable object from another thread. If the operation 123 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an 124 * operation was partially finished when the operation was cancelled the 125 * partial result will be returned, without an error. 126 * 127 * Params: 128 * offset = new length for @seekable, in bytes. 129 * cancellable = optional #GCancellable object, %NULL to ignore. 130 * 131 * Returns: %TRUE if successful. If an error 132 * has occurred, this function will return %FALSE and set @error 133 * appropriately if present. 134 * 135 * Throws: GException on failure. 136 */ 137 public bool truncate(long offset, Cancellable cancellable); 138 }