diff options
author | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:23 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-03-03 01:57:23 +0000 |
commit | b336a3030187b189cfc9b11f9ee1362054616a4b (patch) | |
tree | 21c267dcf8f39ebc9f5c1254729140de909f50ce /src/fs | |
parent | 5c2efc1952243768786f67d9fe8733cba1be0c2b (diff) | |
download | gnunet-b336a3030187b189cfc9b11f9ee1362054616a4b.tar.gz gnunet-b336a3030187b189cfc9b11f9ee1362054616a4b.zip |
GNUNET_FS_namespace_rename
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_namespace.c | 37 |
1 files changed, 37 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 | */ | ||
470 | int | ||
471 | GNUNET_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 |