Re: semantics of gnome_vfs_get_file_info_from_handle
- From: Colin Walters <walters debian org>
- To: gnome-vfs-list gnome org
- Subject: Re: semantics of gnome_vfs_get_file_info_from_handle
- Date: 18 Feb 2003 23:24:48 -0500
On Tue, 2003-02-18 at 05:08, Alexander Larsson wrote:
> Its not. Its "the only change you want to do at the moment". Its a
> slippery slope. Good APIs are small.
Mmmm. I see your point, I guess.
> Can't you just basically return HttpFileHandle->file_info in
> do_get_file_info_from_handle(). Or am I missing something?
Hey...that is a good idea. Patch attached.
Index: test/test-shell.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/test/test-shell.c,v
retrieving revision 1.27
diff -u -d -I$Id: -r1.27 test-shell.c
--- test/test-shell.c 4 Nov 2002 12:51:48 -0000 1.27
+++ test/test-shell.c 19 Feb 2003 04:23:58 -0000
@@ -227,6 +227,7 @@
printf ("File operations:\n");
printf (" * open <handle> <name>: open a file\n");
printf (" * create <handle> <name>: create a file\n");
+ printf (" * handleinfo <handle>: information from handle\n");
printf (" * close <handle>: close a file\n");
printf (" * read <handle> <bytes>: read bytes from stream\n");
printf (" * seek <handle> <pos>: seek set position\n");
@@ -541,24 +542,10 @@
}
static void
-do_info (void)
+print_info (GnomeVFSFileInfo *info)
{
- char *from;
- GnomeVFSResult result;
- GnomeVFSFileInfo *info;
const char *mime_type;
- struct tm *loctime;
-
- from = get_fname ();
-
-
- info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info (
- from, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
-
- if (show_if_error (result, "getting info on: ", from))
- return;
-
+ struct tm *loctime;
fprintf (stdout, "Name: '%s'\n", info->name);
if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) {
fprintf (stdout, "Type: ");
@@ -586,8 +573,8 @@
break;
case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
fprintf (stdout, "symlink\n");
- fprintf (stdout, "symlink points to: %s",
- info->symlink_name);
+ fprintf (stdout, "symlink points to: %s",
+ info->symlink_name);
break;
default:
fprintf (stdout, "Error; invalid value");
@@ -609,18 +596,38 @@
fprintf (stdout, "Mime Type: %s \n", mime_type);
- loctime = localtime(&info->atime);
- fprintf (stdout, "Last Accessed: %s", asctime(loctime));
- loctime = localtime(&info->mtime);
- fprintf (stdout, "Last Modified: %s", asctime(loctime));
- loctime = localtime(&info->ctime);
- fprintf (stdout, "Last Changed: %s", asctime(loctime));
+ loctime = localtime(&info->atime);
+ fprintf (stdout, "Last Accessed: %s", asctime(loctime));
+ loctime = localtime(&info->mtime);
+ fprintf (stdout, "Last Modified: %s", asctime(loctime));
+ loctime = localtime(&info->ctime);
+ fprintf (stdout, "Last Changed: %s", asctime(loctime));
- fprintf (stdout, "uid: %d\n", info->uid);
- fprintf (stdout, "gid: %d\n", info->gid);
+ fprintf (stdout, "uid: %d\n", info->uid);
+
+ fprintf (stdout, "gid: %d\n", info->gid);
fprintf (stdout, "\n");
/* FIXME bugzilla.eazel.com 2800: hack here; should dump them all */
-
+}
+
+static void
+do_info (void)
+{
+ char *from;
+ GnomeVFSResult result;
+ GnomeVFSFileInfo *info;
+
+ from = get_fname ();
+
+
+ info = gnome_vfs_file_info_new ();
+ result = gnome_vfs_get_file_info (
+ from, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
+
+ if (show_if_error (result, "getting info on: ", from))
+ return;
+
+ print_info (info);
gnome_vfs_file_info_unref (info);
}
@@ -876,6 +883,27 @@
close_file (get_handle ());
}
+static void
+do_handleinfo (void)
+{
+ const char *handlename = get_handle ();
+ GnomeVFSResult result;
+ GnomeVFSHandle *handle = lookup_file (handlename);
+ GnomeVFSFileInfo *info;
+
+ if (!handle)
+ return;
+
+ info = gnome_vfs_file_info_new ();
+ result = gnome_vfs_get_file_info_from_handle (handle, info,
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
+
+ if (show_if_error (result, "getting info from handle: ", handlename))
+ return;
+
+ print_info (info);
+ gnome_vfs_file_info_unref (info);
+}
/*
* ---------------------------------------------------------------------
@@ -1046,6 +1074,8 @@
do_create ();
else if (g_ascii_strcasecmp (ptr, "close") == 0)
do_close ();
+ else if (g_ascii_strcasecmp (ptr, "handleinfo") == 0)
+ do_handleinfo ();
else if (g_ascii_strcasecmp (ptr, "read") == 0)
do_read ();
else if (g_ascii_strcasecmp (ptr, "seek") == 0)
Index: modules/http-method.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/modules/http-method.c,v
retrieving revision 1.141
diff -u -d -I$Id: -r1.141 http-method.c
--- modules/http-method.c 13 Sep 2002 13:41:42 -0000 1.141
+++ modules/http-method.c 19 Feb 2003 04:24:00 -0000
@@ -2346,16 +2346,10 @@
GnomeVFSFileInfoOptions options,
GnomeVFSContext *context)
{
- GnomeVFSResult result;
-
- DEBUG_HTTP (("+Get_File_Info_From_Handle"));
-
- result = do_get_file_info (method, ((HttpFileHandle *)method_handle)->uri,
- file_info, options, context);
-
- DEBUG_HTTP (("-Get_File_Info_From_Handle"));
+ HttpFileHandle *handle = (HttpFileHandle *) method_handle;
+ gnome_vfs_file_info_copy (file_info, handle->file_info);
- return result;
+ return GNOME_VFS_OK;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]