2 * client cmdline interface GnomeVFSFileInfo utils for libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <glib/gmessages.h>
23 #include <glib/gerror.h>
24 #include <libgnomevfs/gnome-vfs-file-info.h>
25 #include <glib/gstrfuncs.h>
29 #include "file_info.h" /* self */
32 GQuark cmdline_file_info_error_quark(void)
37 r=g_quark_from_static_string("cmdline-file_info");
43 void file_info_dump_line(const GnomeVFSFileInfo *file_info,GError **errp)
45 const gchar *file_type,*file_perms;
48 g_return_if_fail(!errp || !*errp);
50 switch (!(file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) ? GNOME_VFS_FILE_TYPE_UNKNOWN : file_info->type) {
51 case GNOME_VFS_FILE_TYPE_REGULAR: file_type="FILE"; break;
52 case GNOME_VFS_FILE_TYPE_DIRECTORY: file_type="DIR "; break;
53 case GNOME_VFS_FILE_TYPE_SOCKET: file_type="DEV "; break;
54 default: file_type="??? "; break;
57 if (!(file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS))
59 else if (file_info->permissions & GNOME_VFS_PERM_USER_WRITE)
64 if (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE)
65 file_size=g_strdup_printf("%8" GNOME_VFS_SIZE_FORMAT_STR,file_info->size);
67 file_size=g_strdup_printf("%8s","???");
70 printf("[%s] %s %s %s\n",file_type,file_perms,file_size,file_info->name);