本文整理汇总了C++中G_SEEKABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ G_SEEKABLE函数的具体用法?C++ G_SEEKABLE怎么用?C++ G_SEEKABLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_SEEKABLE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: xmms_gvfs_seek
static gint64
xmms_gvfs_seek (xmms_xform_t *xform, gint64 offset,
xmms_xform_seek_mode_t whence, xmms_error_t *error)
{
GSeekType type;
GError *err = NULL;
xmms_gvfs_data_t *data = xmms_xform_private_data_get (xform);
g_return_val_if_fail (data, -1);
g_return_val_if_fail (!g_input_stream_is_closed (data->handle), -1);
switch (whence) {
case XMMS_XFORM_SEEK_CUR:
type = G_SEEK_CUR;
break;
case XMMS_XFORM_SEEK_SET:
type = G_SEEK_SET;
break;
case XMMS_XFORM_SEEK_END:
type = G_SEEK_END;
break;
}
if (g_seekable_seek (G_SEEKABLE (data->handle), offset, type, NULL, &err)) {
return g_seekable_tell (G_SEEKABLE (data->handle));
}
xmms_error_set (error, XMMS_ERROR_GENERIC, err->message);
return -1;
}
开发者ID:kfihihc,项目名称:xmms2-devel,代码行数:30,代码来源:gvfs.c
示例2: try_seek_on_read
static gboolean
try_seek_on_read (GVfsBackend *backend,
GVfsJobSeekRead *job,
GVfsBackendHandle handle,
goffset offset,
GSeekType type)
{
GInputStream *stream;
GError *error = NULL;
stream = G_INPUT_STREAM (handle);
if (!g_seekable_seek (G_SEEKABLE (stream), offset, type,
G_VFS_JOB (job)->cancellable, &error))
{
g_vfs_job_failed_literal (G_VFS_JOB (job),
error->domain,
error->code,
error->message);
g_error_free (error);
return FALSE;
}
else
{
g_vfs_job_seek_read_set_offset (job, g_seekable_tell (G_SEEKABLE (stream)));
g_vfs_job_succeeded (G_VFS_JOB (job));
}
return TRUE;
}
开发者ID:GNOME,项目名称:gvfs,代码行数:30,代码来源:gvfsbackendhttp.c
示例3: extract_gibest_hash
static void
extract_gibest_hash (GTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
{
GFile *file = source_object;
guint64 buffer[2][CHUNK_N_BYTES/8];
GInputStream *stream = NULL;
gssize n_bytes, file_size;
GError *error = NULL;
guint64 hash = 0;
gint i;
char *str;
ResolveData *resolve_data = task_data;
GrlLocalMetadataSourcePriv *priv;
priv = GRL_LOCAL_METADATA_SOURCE_GET_PRIVATE (resolve_data->source);
stream = G_INPUT_STREAM (g_file_read (file, cancellable, &error));
if (stream == NULL)
goto fail;
/* Extract start/end chunks of the file */
n_bytes = g_input_stream_read (stream, buffer[0], CHUNK_N_BYTES, cancellable, &error);
if (n_bytes == -1)
goto fail;
if (!g_seekable_seek (G_SEEKABLE (stream), -CHUNK_N_BYTES, G_SEEK_END, cancellable, &error))
goto fail;
n_bytes = g_input_stream_read (stream, buffer[1], CHUNK_N_BYTES, cancellable, &error);
if (n_bytes == -1)
goto fail;
for (i = 0; i < G_N_ELEMENTS (buffer[0]); i++)
hash += buffer[0][i] + buffer[1][i];
file_size = g_seekable_tell (G_SEEKABLE (stream));
if (file_size < CHUNK_N_BYTES)
goto fail;
/* Include file size */
hash += file_size;
g_object_unref (stream);
str = g_strdup_printf ("%" G_GINT64_FORMAT, hash);
grl_data_set_string (GRL_DATA (resolve_data->rs->media), priv->hash_keyid, str);
g_free (str);
g_task_return_boolean (task, TRUE);
return;
fail:
GRL_DEBUG ("Could not get file hash: %s\n", error ? error->message : "Unknown error");
g_task_return_error (task, error);
g_clear_object (&stream);
}
开发者ID:GeorgesStavracas,项目名称:grilo-plugins,代码行数:59,代码来源:grl-local-metadata.c
示例4: ddb_gvfs_rewind
static void
ddb_gvfs_rewind (DB_FILE *stream)
{
vfs_gvfs_data_t *data = (vfs_gvfs_data_t *) stream;
g_return_if_fail (data != NULL);
if (g_seekable_can_seek (G_SEEKABLE (data->handle)))
g_seekable_seek (G_SEEKABLE (data->handle), 0, G_SEEK_SET, NULL, NULL);
}
开发者ID:asv,项目名称:deadbeef-gvfs,代码行数:9,代码来源:deadbeef-gvfs.c
示例5: test_message_compare
gint
test_message_compare (CamelMimeMessage *msg)
{
CamelMimeMessage *msg2;
CamelStream *stream1;
CamelStream *stream2;
GByteArray *byte_array1;
GByteArray *byte_array2;
byte_array1 = g_byte_array_new ();
stream1 = camel_stream_mem_new_with_byte_array (byte_array1);
check_msg (camel_data_wrapper_write_to_stream_sync (
CAMEL_DATA_WRAPPER (msg), stream1, NULL, NULL) != -1,
"write_to_stream 1 failed", NULL);
g_seekable_seek (G_SEEKABLE (stream1), 0, G_SEEK_SET, NULL, NULL);
msg2 = camel_mime_message_new ();
check_msg (camel_data_wrapper_construct_from_stream_sync (
CAMEL_DATA_WRAPPER (msg2), stream1, NULL, NULL) != -1,
"construct_from_stream 1 failed");
g_seekable_seek (G_SEEKABLE (stream1), 0, G_SEEK_SET, NULL, NULL);
byte_array2 = g_byte_array_new ();
stream2 = camel_stream_mem_new_with_byte_array (byte_array2);
check_msg (camel_data_wrapper_write_to_stream_sync (
CAMEL_DATA_WRAPPER (msg2), stream2, NULL, NULL) != -1,
"write_to_stream 2 failed");
g_seekable_seek (G_SEEKABLE (stream2), 0, G_SEEK_SET, NULL, NULL);
if (byte_array1->len != byte_array2->len) {
CamelDataWrapper *content;
printf ("stream1 stream:\n%.*s\n", byte_array1->len, byte_array1->data);
printf ("stream2 stream:\n%.*s\n\n", byte_array2->len, byte_array2->data);
printf ("msg1:\n");
test_message_dump_structure (msg);
printf ("msg2:\n");
test_message_dump_structure (msg2);
content = camel_medium_get_content ((CamelMedium *) msg);
}
check_unref (msg2, 1);
check_msg (
byte_array1->len == byte_array2->len,
"byte_array1->len = %d, byte_array2->len = %d",
byte_array1->len, byte_array2->len);
check_msg (memcmp (byte_array1->data, byte_array2->data, byte_array1->len) == 0, "msg/stream compare");
g_object_unref (stream1);
g_object_unref (stream2);
return 0;
}
开发者ID:jdapena,项目名称:evolution-data-server,代码行数:57,代码来源:messages.c
示例6: vfs_data_seek
/* Called from gpgme to seek a file */
static off_t
vfs_data_seek (void *handle, off_t offset, int whence)
{
VfsAsyncHandle* ah = (VfsAsyncHandle*)handle;
GSeekable *seekable = NULL;
GSeekType wh;
/* If the file isn't open yet, then do that now */
if (!ah->ostream && !ah->istream && ah->state == VFS_ASYNC_READY)
vfs_data_open_helper (ah);
/* Just in case we have an operation, like open */
if (!vfs_data_wait_results(ah, TRUE))
return (off_t)-1;
g_assert (ah->state == VFS_ASYNC_READY);
if (ah->writer && G_IS_SEEKABLE (ah->ostream))
seekable = G_SEEKABLE (ah->ostream);
else
seekable = G_SEEKABLE (ah->istream);
if (!seekable || !g_seekable_can_seek (seekable)) {
errno = ENOTSUP;
return -1;
}
switch(whence)
{
case SEEK_SET:
wh = G_SEEK_SET;
break;
case SEEK_CUR:
wh = G_SEEK_CUR;
break;
case SEEK_END:
wh = G_SEEK_END;
break;
default:
g_assert_not_reached();
break;
}
/* All seek operations are not async */
g_clear_error (&ah->error);
g_seekable_seek (seekable, (goffset)offset, wh, ah->cancellable, &ah->error);
/* Start async operation */
ah->state = VFS_ASYNC_READY;
if (!vfs_data_wait_results (ah, TRUE))
return -1;
/* Return results */
ah->state = VFS_ASYNC_READY;
return offset;
}
开发者ID:GNOME,项目名称:seahorse-plugins,代码行数:57,代码来源:seahorse-vfs-data.c
示例7: seek_in_stream
static toff_t
seek_in_stream(thandle_t handle,
toff_t offset,
int whence)
{
Priv *p = (Priv*) handle;
GError *error = NULL;
gboolean sought = FALSE;
goffset position = -1;
g_assert(p->stream);
if (p->can_seek)
{
sought = g_seekable_seek(G_SEEKABLE(p->stream),
(goffset) offset, lseek_to_seek_type(whence),
NULL, &error);
if (sought)
position = g_seekable_tell(G_SEEKABLE(p->stream));
else
{
g_warning("%s", error->message);
g_error_free(error);
}
}
else
{
switch (whence)
{
default:
case SEEK_SET:
if (offset <= p->allocated)
position = p->position = offset;
break;
case SEEK_CUR:
if (p->position + offset <= p->allocated)
position = p->position += offset;
break;
case G_SEEK_END:
position = p->position = p->allocated + offset;
break;
}
}
return (toff_t) position;
}
开发者ID:kleopatra999,项目名称:gegl,代码行数:48,代码来源:tiff-save.c
示例8: seahorse_util_read_to_memory
/**
* seahorse_util_read_to_memory:
* @input: Data to read. The #GInputStream is read till the end.
* @len: Length of the data read (out)
*
* Reads data from the input stream and returns them as #guchar
*
* Returns: The string read from data. The returned string should be freed
* with #g_free when no longer needed.
**/
guchar*
seahorse_util_read_to_memory (GInputStream *input, guint *len)
{
gsize size = 128;
gchar *buffer, *text;
gsize nread = 0;
GString *string;
GSeekable *seek;
if (G_IS_SEEKABLE (input)) {
seek = G_SEEKABLE (input);
g_seekable_seek (seek, 0, SEEK_SET, NULL, NULL);
}
string = g_string_new ("");
buffer = g_new (gchar, size);
while (g_input_stream_read_all (input, buffer, size, &nread, NULL, NULL)) {
string = g_string_append_len (string, buffer, nread);
if (nread != size)
break;
}
if (len)
*len = string->len;
text = g_string_free (string, FALSE);
g_free (buffer);
return (guchar*)text;
}
开发者ID:xZeroCooLx,项目名称:seahorse,代码行数:41,代码来源:seahorse-util.c
示例9: cache_replace_ready_cb
static void
cache_replace_ready_cb (GObject *source,
GAsyncResult *res,
gpointer user_data)
{
GFileOutputStream *cache_stream;
GError *error = NULL;
NemoPreviewCoverArtFetcher *self = user_data;
cache_stream = g_file_replace_finish (G_FILE (source),
res, &error);
if (error != NULL) {
g_warning ("Can't save the cover art image in the cache: %s\n", error->message);
g_error_free (error);
return;
}
g_seekable_seek (G_SEEKABLE (self->priv->input_stream), 0, G_SEEK_SET,
NULL, NULL);
g_output_stream_splice_async (G_OUTPUT_STREAM (cache_stream),
self->priv->input_stream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
G_PRIORITY_DEFAULT,
NULL,
cache_splice_ready_cb, self);
g_object_unref (cache_stream);
}
开发者ID:Fantu,项目名称:nemo-extensions,代码行数:32,代码来源:nemo-preview-cover-art.c
示例10: gegl_tile_backend_file_write_header
static gboolean
gegl_tile_backend_file_write_header (GeglTileBackendFile *self)
{
gboolean success;
gegl_tile_backend_file_ensure_exist (self);
#if HAVE_GIO
success = g_seekable_seek (G_SEEKABLE (self->o), 0, G_SEEK_SET,
NULL, NULL);
#else
success = (lseek (self->o, 0, SEEK_SET) != -1);
#endif
if (success == FALSE)
{
g_warning ("unable to seek in buffer");
return FALSE;
}
#if HAVE_GIO
g_output_stream_write (self->o, &(self->header), 256, NULL, NULL);
#else
write (self->o, &(self->header), 256);
#endif
GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "Wrote header, next=%i", (gint)self->header.next);
return TRUE;
}
开发者ID:jcupitt,项目名称:gegl-vips,代码行数:26,代码来源:gegl-tile-backend-file.c
示例11: gimp_curves_tool_settings_import
static gboolean
gimp_curves_tool_settings_import (GimpImageMapTool *image_map_tool,
GInputStream *input,
GError **error)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
gchar header[64];
gsize bytes_read;
if (! g_input_stream_read_all (input, header, sizeof (header),
&bytes_read, NULL, error) ||
bytes_read != sizeof (header))
{
g_prefix_error (error, _("Could not read header: "));
return FALSE;
}
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
if (g_str_has_prefix (header, "# GIMP Curves File\n"))
return gimp_curves_config_load_cruft (tool->config, input, error);
return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool,
input,
error);
}
开发者ID:Distrotech,项目名称:gimp,代码行数:26,代码来源:gimpcurvestool.c
示例12: et_ogg_tell_func
/*
* et_ogg_tell_func:
* @datasource: the Ogg parser state
*
* Tell the current position of the stream from the beginning of the Ogg file.
*
* Returns: the current position in the Ogg file
*/
static long
et_ogg_tell_func (void *datasource)
{
EtOggState *state = (EtOggState *)datasource;
return g_seekable_tell (G_SEEKABLE (state->istream));
}
开发者ID:imclab,项目名称:easytag-mac,代码行数:15,代码来源:ogg_header.c
示例13: gst_gio_base_sink_event
static gboolean
gst_gio_base_sink_event (GstBaseSink * base_sink, GstEvent * event)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
GstFlowReturn ret = GST_FLOW_OK;
if (sink->stream == NULL)
return TRUE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:
if (G_IS_OUTPUT_STREAM (sink->stream)) {
const GstSegment *segment;
gst_event_parse_segment (event, &segment);
if (segment->format != GST_FORMAT_BYTES) {
GST_WARNING_OBJECT (sink, "ignored SEGMENT event in %s format",
gst_format_get_name (segment->format));
break;
}
if (GST_GIO_STREAM_IS_SEEKABLE (sink->stream)) {
ret = gst_gio_seek (sink, G_SEEKABLE (sink->stream), segment->start,
sink->cancel);
if (ret == GST_FLOW_OK)
sink->position = segment->start;
} else {
ret = GST_FLOW_NOT_SUPPORTED;
}
}
break;
case GST_EVENT_EOS:
case GST_EVENT_FLUSH_START:
if (G_IS_OUTPUT_STREAM (sink->stream)) {
gboolean success;
GError *err = NULL;
success = g_output_stream_flush (sink->stream, sink->cancel, &err);
if (!success && !gst_gio_error (sink, "g_output_stream_flush", &err,
&ret)) {
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
("flush failed: %s", err->message));
g_clear_error (&err);
}
}
break;
default:
break;
}
if (ret == GST_FLOW_OK)
return GST_BASE_SINK_CLASS (parent_class)->event (base_sink, event);
else {
gst_event_unref (event);
return FALSE;
}
}
开发者ID:Lachann,项目名称:gst-plugins-base,代码行数:60,代码来源:gstgiobasesink.c
示例14: on_file_read_ready
static void on_file_read_ready (GObject * object, GAsyncResult * res, gpointer data)
{
GError *error = NULL;
GDownloadable *download = G_DOWNLOADABLE (data);
GioDownload *gio_download = GIO_DOWNLOAD (data);
g_assert (download != NULL);
gio_download->priv->input = g_file_read_finish (G_FILE(object), res, &error);
handle_critical_error (error);
if (gio_download->priv->input == NULL) {
// TODO: Error details
g_downloadable_set_status (download, G_DOWNLOADABLE_NETWORK_ERROR);
} else {
if (g_seekable_can_seek(G_SEEKABLE(gio_download->priv->input))
&& g_file_query_exists (download->priv->local_file, NULL)) {
//g_message ("appeding file ...\n");
g_file_append_to_async (download->priv->local_file, 0,G_PRIORITY_DEFAULT,
NULL, on_file_append_to_ready, download);
} else {
//g_message ("replacing file ...\n");
g_file_replace_async (download->priv->local_file, NULL, FALSE, 0, G_PRIORITY_DEFAULT,
NULL, on_file_replace_ready, download);
}
g_downloadable_set_status (download, G_DOWNLOADABLE_DOWNLOADING);
}
}
开发者ID:trhura,项目名称:rookie,代码行数:27,代码来源:gio-download.c
示例15: gst_gio_base_src_start
static gboolean
gst_gio_base_src_start (GstBaseSrc * base_src)
{
GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);
GstGioBaseSrcClass *gbsrc_class = GST_GIO_BASE_SRC_GET_CLASS (src);
src->position = 0;
/* FIXME: This will likely block */
src->stream = gbsrc_class->get_stream (src);
if (G_UNLIKELY (!G_IS_INPUT_STREAM (src->stream))) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("No input stream provided by subclass"));
return FALSE;
} else if (G_UNLIKELY (g_input_stream_is_closed (src->stream))) {
GST_ELEMENT_ERROR (src, LIBRARY, FAILED, (NULL),
("Input stream is already closed"));
return FALSE;
}
if (G_IS_SEEKABLE (src->stream))
src->position = g_seekable_tell (G_SEEKABLE (src->stream));
GST_DEBUG_OBJECT (src, "started source");
return TRUE;
}
开发者ID:collects,项目名称:gst-plugins-base,代码行数:27,代码来源:gstgiobasesrc.c
示例16: vfs_stream_read
static unsigned long
vfs_stream_read (FT_Stream stream,
unsigned long offset,
unsigned char *buffer,
unsigned long count)
{
GFileInputStream *handle = stream->descriptor.pointer;
gssize bytes_read = 0;
if (!count && offset > stream->size)
return 1;
if (!g_seekable_seek (G_SEEKABLE (handle), offset, G_SEEK_SET, NULL, NULL))
return (count ? 0 : 1);
if (count > 0) {
bytes_read = g_input_stream_read (G_INPUT_STREAM (handle), buffer,
count, NULL, NULL);
if (bytes_read == -1)
return 0;
}
return bytes_read;
}
开发者ID:kissthink,项目名称:deepin-utils,代码行数:25,代码来源:deepin_font_icon.c
示例17: seahorse_util_memory_output_length
/**
* seahorse_util_memory_output_length:
* @output: a stream
*
* A replacement for #g_memory_output_stream_get_data_size (since 2.18)
*
* Returns: The length of the stream
*/
gsize
seahorse_util_memory_output_length (GMemoryOutputStream *output)
{
GSeekable *seekable;
goffset offset, end;
/*
* This is a replacement for g_memory_output_stream_get_data_size()
* which is not available in current version of glib.
*/
g_return_val_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output), 0);
g_return_val_if_fail (G_IS_SEEKABLE (output), 0);
seekable = G_SEEKABLE (output);
offset = g_seekable_tell (seekable);
if (!g_seekable_seek (seekable, 0, G_SEEK_END, NULL, NULL))
g_return_val_if_reached (0);
end = g_seekable_tell (seekable);
if (offset != end) {
if (!g_seekable_seek (seekable, offset, G_SEEK_SET, NULL, NULL))
g_return_val_if_reached (0);
}
return (gsize)end;
}
开发者ID:GNOME,项目名称:libcryptui,代码行数:37,代码来源:seahorse-util.c
示例18: g_resource_file_input_stream_can_seek
static gboolean
g_resource_file_input_stream_can_seek (GFileInputStream *stream)
{
GResourceFileInputStream *file = G_RESOURCE_FILE_INPUT_STREAM (stream);
return G_IS_SEEKABLE (file->stream) && g_seekable_can_seek (G_SEEKABLE (file->stream));
}
开发者ID:adesurya,项目名称:gst-mobile,代码行数:7,代码来源:gresourcefile.c
示例19: can_seek
static gboolean
can_seek (GInputStream *stream)
{
if (!G_IS_SEEKABLE (stream))
return FALSE;
return g_seekable_can_seek (G_SEEKABLE (stream));
}
开发者ID:GNOME,项目名称:libgsf,代码行数:8,代码来源:gsf-input-gio.c
示例20: main
gint main (gint argc, gchar **argv)
{
struct dirent *dent;
DIR *dir;
gint fd;
camel_test_init (argc, argv);
camel_test_start ("Message Test Suite");
if (!(dir = opendir ("../data/messages")))
return 77;
while ((dent = readdir (dir)) != NULL) {
CamelMimeMessage *message;
CamelStream *stream;
gchar *filename;
struct stat st;
if (dent->d_name[0] == '.')
continue;
filename = g_strdup_printf ("../data/messages/%s", dent->d_name);
if (g_stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) {
g_free (filename);
continue;
}
if ((fd = open (filename, O_RDONLY)) == -1) {
g_free (filename);
continue;
}
push ("testing message '%s'", filename);
g_free (filename);
stream = camel_stream_fs_new_with_fd (fd);
message = camel_mime_message_new ();
camel_data_wrapper_construct_from_stream_sync (
CAMEL_DATA_WRAPPER (message), stream, NULL, NULL);
g_seekable_seek (
G_SEEKABLE (stream), 0, G_SEEK_SET, NULL, NULL);
/*dump_mime_struct ((CamelMimePart *) message, 0);*/
test_message_compare (message);
g_object_unref (message);
g_object_unref (stream);
pull ();
}
closedir (dir);
camel_test_end ();
return 0;
}
开发者ID:Pecisk,项目名称:eds-gtasks,代码行数:58,代码来源:test4.c
注:本文中的G_SEEKABLE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论