summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 08:38:27 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 08:38:27 +0000
commitc9c4cb2ecd910b19d2e649e6397b79a54ec006d5 (patch)
tree01aca4ef44ca253499a6a7f6ae0269487f78b865
parentcf9bb1493639116f262f8e4381b17a8c70b150f2 (diff)
downloadgvfs-c9c4cb2ecd910b19d2e649e6397b79a54ec006d5.tar.gz
Add gvfs-ls program
Original git commit by Alexander Larsson <alex@greebo.(none)> at 1159802810 +0200 svn path=/trunk/; revision=60
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac1
-rw-r--r--programs/.gitignore6
-rw-r--r--programs/Makefile.am28
-rw-r--r--programs/gvfs-ls.c100
5 files changed, 137 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 26555a7b..1f994bc0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,6 @@
SUBDIRS = \
gvfs \
- po
+ po \
+ programs
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
diff --git a/configure.ac b/configure.ac
index f235e1df..e06a227f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,5 +104,6 @@ fi
AC_OUTPUT([
Makefile
gvfs/Makefile
+programs/Makefile
po/Makefile.in
])
diff --git a/programs/.gitignore b/programs/.gitignore
new file mode 100644
index 00000000..f9e0aa28
--- /dev/null
+++ b/programs/.gitignore
@@ -0,0 +1,6 @@
+Makefile
+Makefile.in
+.deps
+.libs
+gvfs-ls
+
diff --git a/programs/Makefile.am b/programs/Makefile.am
new file mode 100644
index 00000000..5c9cd8d3
--- /dev/null
+++ b/programs/Makefile.am
@@ -0,0 +1,28 @@
+NULL =
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(GLIB_CFLAGS) \
+ -DG_DISABLE_DEPRECATED
+
+libraries = \
+ $(top_builddir)/gvfs/libgvfs.la \
+ $(GLIB_LIBS)
+
+bin_PROGRAMS = \
+ gvfs-ls \
+ $(NULL)
+
+# gvfs-cat \
+# gvfs-info \
+#
+
+#gvfs_cat_SOURCES = gvfs-cat.c
+#gvfs_cat_LDADD = $(libraries)
+
+#gvfs_info_SOURCES = gvfs-info.c
+#gvfs_info_LDADD = $(libraries)
+
+gvfs_ls_SOURCES = gvfs-ls.c
+gvfs_ls_LDADD = $(libraries)
diff --git a/programs/gvfs-ls.c b/programs/gvfs-ls.c
new file mode 100644
index 00000000..a78357bd
--- /dev/null
+++ b/programs/gvfs-ls.c
@@ -0,0 +1,100 @@
+#include <config.h>
+
+#include <glib.h>
+#include <locale.h>
+#include <gvfs/gfile.h>
+
+static char *attributes = NULL;
+
+static GOptionEntry entries[] =
+{
+ { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, "The attributes to get", NULL },
+ { NULL }
+};
+
+static void
+show_info (GFileInfo *info)
+{
+ const char *name;
+
+ name = g_file_info_get_name (info);
+ g_print ("filename: %s\n", name);
+}
+
+static void
+list (GFile *file)
+{
+ GFileInfoRequestFlags request;
+ GFileEnumerator *enumerator;
+ GFileInfo *info;
+ GError *error;
+
+ if (file == NULL)
+ return;
+
+ request = G_FILE_INFO_FILE_TYPE | G_FILE_INFO_NAME;
+
+ enumerator = g_file_enumerate_children (file, request, attributes, TRUE);
+
+ error = NULL;
+ while ((info = g_file_enumerator_next_file (enumerator, &error)) != NULL)
+ {
+ show_info (info);
+
+ g_object_unref (info);
+ }
+
+ if (error)
+ {
+ g_print ("Error: %s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (!g_file_enumerator_stop (enumerator, &error))
+ {
+ g_print ("Error stopping enumerator: %s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ GError *error;
+ GOptionContext *context;
+ GFile *file;
+
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+
+ error = NULL;
+ context = g_option_context_new ("- list files at <location>");
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_parse (context, &argc, &argv, &error);
+
+ if (argc > 1)
+ {
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ file = g_file_get_for_commandline_arg (argv[i]);
+ list (file);
+ g_object_unref (file);
+ }
+ }
+ else
+ {
+ char *cwd;
+
+ cwd = g_get_current_dir ();
+ file = g_file_get_for_path (cwd);
+ g_free (cwd);
+ list (file);
+ g_object_unref (file);
+ }
+
+ return 0;
+}