gseekable.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Author: Alexander Larsson <[email protected]>
  19. */
  20. #ifndef __G_SEEKABLE_H__
  21. #define __G_SEEKABLE_H__
  22. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  23. #error "Only <gio/gio.h> can be included directly."
  24. #endif
  25. #include <gio/giotypes.h>
  26. G_BEGIN_DECLS
  27. #define G_TYPE_SEEKABLE (g_seekable_get_type ())
  28. #define G_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SEEKABLE, GSeekable))
  29. #define G_IS_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SEEKABLE))
  30. #define G_SEEKABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SEEKABLE, GSeekableIface))
  31. /**
  32. * GSeekable:
  33. *
  34. * Seek object for streaming operations.
  35. **/
  36. typedef struct _GSeekableIface GSeekableIface;
  37. /**
  38. * GSeekableIface:
  39. * @g_iface: The parent interface.
  40. * @tell: Tells the current location within a stream.
  41. * @can_seek: Checks if seeking is supported by the stream.
  42. * @seek: Seeks to a location within a stream.
  43. * @can_truncate: Checks if truncation is supported by the stream.
  44. * @truncate_fn: Truncates a stream.
  45. *
  46. * Provides an interface for implementing seekable functionality on I/O Streams.
  47. **/
  48. struct _GSeekableIface
  49. {
  50. GTypeInterface g_iface;
  51. /* Virtual Table */
  52. goffset (* tell) (GSeekable *seekable);
  53. gboolean (* can_seek) (GSeekable *seekable);
  54. gboolean (* seek) (GSeekable *seekable,
  55. goffset offset,
  56. GSeekType type,
  57. GCancellable *cancellable,
  58. GError **error);
  59. gboolean (* can_truncate) (GSeekable *seekable);
  60. gboolean (* truncate_fn) (GSeekable *seekable,
  61. goffset offset,
  62. GCancellable *cancellable,
  63. GError **error);
  64. /* TODO: Async seek/truncate */
  65. };
  66. GLIB_AVAILABLE_IN_ALL
  67. GType g_seekable_get_type (void) G_GNUC_CONST;
  68. GLIB_AVAILABLE_IN_ALL
  69. goffset g_seekable_tell (GSeekable *seekable);
  70. GLIB_AVAILABLE_IN_ALL
  71. gboolean g_seekable_can_seek (GSeekable *seekable);
  72. GLIB_AVAILABLE_IN_ALL
  73. gboolean g_seekable_seek (GSeekable *seekable,
  74. goffset offset,
  75. GSeekType type,
  76. GCancellable *cancellable,
  77. GError **error);
  78. GLIB_AVAILABLE_IN_ALL
  79. gboolean g_seekable_can_truncate (GSeekable *seekable);
  80. GLIB_AVAILABLE_IN_ALL
  81. gboolean g_seekable_truncate (GSeekable *seekable,
  82. goffset offset,
  83. GCancellable *cancellable,
  84. GError **error);
  85. G_END_DECLS
  86. #endif /* __G_SEEKABLE_H__ */