summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-11-22 22:31:32 +0000
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-11-22 23:10:12 +0000
commit0fd34688b79daa0dc4fb5f425da6b50c488a8a59 (patch)
tree9cd48e85e6c34ff42a29b9edebb63669c80f2e3c
parentf280f8d0fa1139ed39bf816a35c2b0d3c61826c1 (diff)
downloadgvfs-0fd34688b79daa0dc4fb5f425da6b50c488a8a59.tar.gz
Address first set of review comments
-rw-r--r--common/Makefile.am1
-rw-r--r--common/gvfsutils.c42
-rw-r--r--common/gvfsutils.h30
-rw-r--r--daemon/gvfsbackendafp.c2
-rw-r--r--daemon/gvfsbackendsftp.c2
-rw-r--r--daemon/gvfsbackendsmb.c9
-rw-r--r--daemon/gvfsdaemon.c1
-rw-r--r--daemon/gvfsdaemonutils.c17
-rw-r--r--daemon/gvfsdaemonutils.h4
-rw-r--r--metadata/Makefile.am6
-rw-r--r--metadata/metatree.c29
11 files changed, 88 insertions, 55 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index cfc1c230..00726ee6 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -27,6 +27,7 @@ libgvfscommon_la_SOURCES = \
gvfsdaemonprotocol.c gvfsdaemonprotocol.h \
gvfsicon.h gvfsicon.c \
gvfsfileinfo.c gvfsfileinfo.h \
+ gvfsutils.c gvfsutils.h \
$(dbus_built_sources) \
$(NULL)
diff --git a/common/gvfsutils.c b/common/gvfsutils.c
new file mode 100644
index 00000000..87718f30
--- /dev/null
+++ b/common/gvfsutils.c
@@ -0,0 +1,42 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2014 Ross Lagerwall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <glib.h>
+#include "gvfsutils.h"
+
+/**
+ * gvfs_randomize_string:
+ * @str: the string to randomize
+ * @len: the length of the string
+ *
+ * Takes a string and fills it with @len random chars.
+ **/
+void
+gvfs_randomize_string (char *str,
+ int len)
+{
+ int i;
+ const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+ for (i = 0; i < len; i++)
+ str[i] = chars[g_random_int_range (0, strlen(chars))];
+}
diff --git a/common/gvfsutils.h b/common/gvfsutils.h
new file mode 100644
index 00000000..aa7faf5e
--- /dev/null
+++ b/common/gvfsutils.h
@@ -0,0 +1,30 @@
+/* GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright (C) 2014 Ross Lagerwall
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __G_VFS_UTILS_H__
+#define __G_VFS_UTILS_H__
+
+G_BEGIN_DECLS
+
+void gvfs_randomize_string (char *str,
+ int len);
+
+G_END_DECLS
+
+#endif /* __G_VFS_UTILS_H__ */
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index f7cbd5ba..090d1de9 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -53,7 +53,7 @@
#include "gvfsjobsetdisplayname.h"
#include "gvfsjobmove.h"
#include "gvfsjobcopy.h"
-#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfsafpserver.h"
#include "gvfsafpvolume.h"
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 01340323..29a841e6 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -66,7 +66,7 @@
#include "gvfsjobpush.h"
#include "gvfsjobpull.h"
#include "gvfsdaemonprotocol.h"
-#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfskeyring.h"
#include "sftp.h"
#include "pty_open.h"
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index 7334ddf7..d2b958f3 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -50,6 +50,7 @@
#include "gvfsjobenumerate.h"
#include "gvfsdaemonprotocol.h"
#include "gvfsdaemonutils.h"
+#include "gvfsutils.h"
#include "gvfskeyring.h"
#include <libsmbclient.h>
@@ -860,8 +861,8 @@ do_seek_on_read (GVfsBackend *backend,
if ((whence = gvfs_seek_type_to_lseek (type)) == -1)
{
g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Unsupported seek type"));
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Unsupported seek type"));
return;
}
@@ -1339,8 +1340,8 @@ do_seek_on_write (GVfsBackend *backend,
if ((whence = gvfs_seek_type_to_lseek (type)) == -1)
{
g_vfs_job_failed (G_VFS_JOB (job),
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Unsupported seek type"));
+ G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Unsupported seek type"));
return;
}
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index cae2803a..235a62a7 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -38,6 +38,7 @@
#include <gvfsdaemon.h>
#include <gvfsdaemonprotocol.h>
#include <gvfsdaemonutils.h>
+#include <gvfsutils.h>
#include <gvfsjobmount.h>
#include <gvfsjobopenforread.h>
#include <gvfsjobopenforwrite.h>
diff --git a/daemon/gvfsdaemonutils.c b/daemon/gvfsdaemonutils.c
index 50f861da..2be975ce 100644
--- a/daemon/gvfsdaemonutils.c
+++ b/daemon/gvfsdaemonutils.c
@@ -217,23 +217,6 @@ gvfs_file_info_populate_content_types (GFileInfo *info,
}
/**
- * gvfs_randomize_string:
- * @str: the string to randomize
- * @len: the length of the string
- *
- * Takes a string and fills it with @len random chars.
- **/
-void
-gvfs_randomize_string (char *str, int len)
-{
- int i;
- const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
- for (i = 0; i < len; i++)
- str[i] = chars[g_random_int_range (0, strlen(chars))];
-}
-
-/**
* gvfs_seek_type_to_lseek:
* @type: the seek type
*
diff --git a/daemon/gvfsdaemonutils.h b/daemon/gvfsdaemonutils.h
index a586a6a9..f1951361 100644
--- a/daemon/gvfsdaemonutils.h
+++ b/daemon/gvfsdaemonutils.h
@@ -40,9 +40,7 @@ void gvfs_file_info_populate_content_types (GFileInfo *info,
const char *basename,
GFileType type);
-void gvfs_randomize_string (char *str, int len);
-
-int gvfs_seek_type_to_lseek (GSeekType type);
+int gvfs_seek_type_to_lseek (GSeekType type);
G_END_DECLS
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index e86e1c92..767033e1 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -46,16 +46,16 @@ libmetadata_la_SOURCES = \
libmetadata_la_LIBADD = $(GLIB_LIBS) $(UDEV_LIBS)
-meta_ls_LDADD = libmetadata.la
+meta_ls_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_ls_SOURCES = meta-ls.c
meta_set_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_set_SOURCES = meta-set.c
-meta_get_LDADD = libmetadata.la
+meta_get_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_get_SOURCES = meta-get.c
-meta_get_tree_LDADD = libmetadata.la
+meta_get_tree_LDADD = libmetadata.la ../common/libgvfscommon.la
meta_get_tree_SOURCES = meta-get-tree.c
convert_nautilus_metadata_LDADD = libmetadata.la $(LIBXML_LIBS)
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 7b59c4a5..1c6e5fd1 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -13,6 +13,7 @@
#include "metabuilder.h"
#include <glib.h>
#include <glib/gstdio.h>
+#include "gvfsutils.h"
#include "crc32.h"
#ifdef HAVE_LIBUDEV
@@ -266,38 +267,14 @@ link_to_tmp (const char *source, char *tmpl)
{
char *XXXXXX;
int count, res;
- static const char letters[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- static const int NLETTERS = sizeof (letters) - 1;
- glong value;
- GTimeVal tv;
- static int counter = 0;
/* find the last occurrence of "XXXXXX" */
XXXXXX = g_strrstr (tmpl, "XXXXXX");
g_assert (XXXXXX != NULL);
- /* Get some more or less random data. */
- g_get_current_time (&tv);
- value = (tv.tv_usec ^ tv.tv_sec) + counter++;
-
- for (count = 0; count < 100; value += 7777, ++count)
+ for (count = 0; count < 100; ++count)
{
- glong v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[1] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[2] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[3] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[4] = letters[v % NLETTERS];
- v /= NLETTERS;
- XXXXXX[5] = letters[v % NLETTERS];
-
+ gvfs_randomize_string (XXXXXX, 6);
res = link (source, tmpl);
if (res >= 0)