aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/fs_namespace.c37
-rw-r--r--src/include/gnunet_fs_service.h12
2 files changed, 49 insertions, 0 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 3558b0ae6..97b981343 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -460,6 +460,43 @@ GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc)
460 460
461 461
462/** 462/**
463 * Rename a local namespace.
464 *
465 * @param h handle to the file sharing subsystem
466 * @param old_name old name of the namespace
467 * @param new_name new name of the namespace
468 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
469 */
470int
471GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, char *old_name, char *new_name)
472{
473 char *dn;
474 char *fn_old;
475 char *fn_new;
476 int result;
477 int save_errno;
478
479 dn = get_namespace_directory (h);
480 if (NULL == dn)
481 {
482 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
483 _("Can't determine where namespace directory is\n"));
484 return GNUNET_SYSERR;
485 }
486 GNUNET_asprintf (&fn_old, "%s%s%s", dn, DIR_SEPARATOR_STR, old_name);
487 GNUNET_asprintf (&fn_new, "%s%s%s", dn, DIR_SEPARATOR_STR, new_name);
488 GNUNET_free (dn);
489 result = RENAME (fn_old, fn_new);
490 save_errno = errno;
491 GNUNET_free (fn_old);
492 GNUNET_free (fn_new);
493 errno = save_errno;
494 if (result == 0)
495 return GNUNET_OK;
496 return GNUNET_SYSERR;
497}
498
499/**
463 * Duplicate a namespace handle. 500 * Duplicate a namespace handle.
464 * 501 *
465 * @param ns namespace handle 502 * @param ns namespace handle
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 5b0217a19..c14584890 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -2292,6 +2292,18 @@ GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc)
2292 2292
2293 2293
2294/** 2294/**
2295 * Rename a local namespace.
2296 *
2297 * @param h handle to the file sharing subsystem
2298 * @param old_name old name of the namespace
2299 * @param new_name new name of the namespace
2300 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
2301 */
2302int
2303GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, char *old_name, char *new_name);
2304
2305
2306/**
2295 * Duplicate a namespace handle. 2307 * Duplicate a namespace handle.
2296 * 2308 *
2297 * @param ns namespace handle 2309 * @param ns namespace handle