GNUNET_FS_namespace_rename
authorLRN <lrn1986@gmail.com>
Sun, 3 Mar 2013 01:57:23 +0000 (01:57 +0000)
committerLRN <lrn1986@gmail.com>
Sun, 3 Mar 2013 01:57:23 +0000 (01:57 +0000)
src/fs/fs_namespace.c
src/include/gnunet_fs_service.h

index 3558b0ae6ad7aaba9bdb5634102365bff6a8c5d8..97b981343601a0a8cf7cd7a6ab16288bff4e27cc 100644 (file)
@@ -459,6 +459,43 @@ GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc)
 }
 
 
+/**
+ * Rename a local namespace.
+ *
+ * @param h handle to the file sharing subsystem
+ * @param old_name old name of the namespace
+ * @param new_name new name of the namespace
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
+ */
+int
+GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, char *old_name, char *new_name)
+{
+  char *dn;
+  char *fn_old;
+  char *fn_new;
+  int result;
+  int save_errno;
+
+  dn = get_namespace_directory (h);
+  if (NULL == dn)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _("Can't determine where namespace directory is\n"));
+    return GNUNET_SYSERR;
+  }
+  GNUNET_asprintf (&fn_old, "%s%s%s", dn, DIR_SEPARATOR_STR, old_name);
+  GNUNET_asprintf (&fn_new, "%s%s%s", dn, DIR_SEPARATOR_STR, new_name);
+  GNUNET_free (dn);
+  result = RENAME (fn_old, fn_new);
+  save_errno = errno;
+  GNUNET_free (fn_old);
+  GNUNET_free (fn_new);
+  errno = save_errno;
+  if (result == 0)
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
+}
+
 /**
  * Duplicate a namespace handle.
  *
index 5b0217a190e6e553dfd7181eb954f0f33e4d9290..c14584890aeb7cc55ec4433387a35892adffb3f4 100644 (file)
@@ -2291,6 +2291,18 @@ void
 GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc);
 
 
+/**
+ * Rename a local namespace.
+ *
+ * @param h handle to the file sharing subsystem
+ * @param old_name old name of the namespace
+ * @param new_name new name of the namespace
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
+ */
+int
+GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, char *old_name, char *new_name);
+
+
 /**
  * Duplicate a namespace handle.
  *