[gthumb] Migrate file_is_search_result from gnomevfs to gfile
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Migrate file_is_search_result from gnomevfs to gfile
- Date: Wed, 20 May 2009 11:26:45 -0400 (EDT)
commit 37077c8a10cfdbf3b1d377fbdbf0737cbf54a4f3
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Wed May 20 11:25:18 2009 -0400
Migrate file_is_search_result from gnomevfs to gfile
---
libgthumb/file-utils.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 723af91..4753416 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -1653,19 +1653,31 @@ get_catalog_full_path (const char *relative_path)
gboolean
file_is_search_result (const char *path)
{
- GnomeVFSResult r;
- GnomeVFSHandle *handle;
- char line[50] = "";
+ GFileInputStream *istream;
+ GDataInputStream *dstream;
+ GError *error = NULL;
+ GFile *gfile;
+ char *line;
+ gsize length;
- r = gnome_vfs_open (&handle, path, GNOME_VFS_OPEN_READ);
- if (r != GNOME_VFS_OK)
- return FALSE;
+ gfile = gfile_new (path);
+ istream = g_file_read (gfile, NULL, &error);
+ if (error != NULL) {
+ g_error_free (error);
+ g_object_unref (istream);
+ g_object_unref (gfile);
+ return FALSE;
+ }
+
+ dstream = g_data_input_stream_new (G_INPUT_STREAM(istream));
+ line = g_data_input_stream_read_line (dstream, &length, NULL, NULL);
- r = gnome_vfs_read (handle, line, strlen (SEARCH_HEADER), NULL);
- gnome_vfs_close (handle);
+ g_object_unref (istream);
+ g_object_unref (dstream);
+ g_object_unref (gfile);
- if ((r != GNOME_VFS_OK) || (line[0] == 0))
- return FALSE;
+ if (line == NULL)
+ return FALSE;
return strncmp (line, SEARCH_HEADER, strlen (SEARCH_HEADER)) == 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]