[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19070 - in gnunet/src: fs include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19070 - in gnunet/src: fs include |
Date: |
Mon, 9 Jan 2012 17:43:54 +0100 |
Author: grothoff
Date: 2012-01-09 17:43:54 +0100 (Mon, 09 Jan 2012)
New Revision: 19070
Modified:
gnunet/src/fs/fs_file_information.c
gnunet/src/fs/test_fs_file_information.c
gnunet/src/fs/test_fs_list_indexed.c
gnunet/src/fs/test_fs_publish.c
gnunet/src/fs/test_fs_publish_persistence.c
gnunet/src/include/gnunet_fs_service.h
Log:
-LRN: make file filename alterable and initializable
Modified: gnunet/src/fs/fs_file_information.c
===================================================================
--- gnunet/src/fs/fs_file_information.c 2012-01-09 16:38:26 UTC (rev 19069)
+++ gnunet/src/fs/fs_file_information.c 2012-01-09 16:43:54 UTC (rev 19070)
@@ -107,8 +107,39 @@
return s->serialization;
}
+/**
+ * Obtain the filename from the file information structure.
+ *
+ * @param s structure to get the filename for
+ * @return "filename" field of the structure (can be NULL)
+ */
+const char *
+GNUNET_FS_file_information_get_filename (struct GNUNET_FS_FileInformation *s)
+{
+ return s->filename;
+}
+
/**
+ * Set the filename in the file information structure.
+ * If filename was already set, frees it before setting the new one.
+ * Makes a copy of the argument.
+ *
+ * @param s structure to get the filename for
+ * @param filename filename to set
+ */
+void
+GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s,
+ const char *filename)
+{
+ GNUNET_free_non_null (s->filename);
+ if (filename)
+ s->filename = GNUNET_strdup (filename);
+ else
+ s->filename = NULL;
+}
+
+/**
* Create an entry for a file in a publish-structure.
*
* @param h handle to the file sharing subsystem
@@ -764,7 +795,7 @@
GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, GNUNET_FS_DIRECTORY_MIME,
GNUNET_NO);
ret =
GNUNET_FS_file_information_create_empty_directory (h, client_info,
cdmc.ksk,
- cdmc.meta, bo);
+ cdmc.meta, bo,
filename);
GNUNET_CONTAINER_meta_data_destroy (cdmc.meta);
GNUNET_FS_uri_destroy (cdmc.ksk);
ret->data.dir.entries = dc.entries;
@@ -789,8 +820,7 @@
"text/plain", dn, strlen (dn) + 1);
#endif
GNUNET_free (dn);
- ret->filename = GNUNET_strdup (filename);
- return ret;
+ return ret;
}
@@ -820,6 +850,7 @@
* @param keywords under which keywords should this directory be available
* directly; can be NULL
* @param bo block options
+ * @param filename name of the directory; can be NULL
* @return publish structure entry for the directory , NULL on error
*/
struct GNUNET_FS_FileInformation *
@@ -831,7 +862,8 @@
GNUNET_CONTAINER_MetaData
*meta,
const struct
- GNUNET_FS_BlockOptions *bo)
+ GNUNET_FS_BlockOptions *bo,
+ const char *filename)
{
struct GNUNET_FS_FileInformation *ret;
@@ -842,6 +874,8 @@
ret->keywords = GNUNET_FS_uri_dup (keywords);
ret->bo = *bo;
ret->is_directory = GNUNET_YES;
+ if (filename != NULL)
+ ret->filename = GNUNET_strdup (filename);
return ret;
}
Modified: gnunet/src/fs/test_fs_file_information.c
===================================================================
--- gnunet/src/fs/test_fs_file_information.c 2012-01-09 16:38:26 UTC (rev
19069)
+++ gnunet/src/fs/test_fs_file_information.c 2012-01-09 16:43:54 UTC (rev
19070)
@@ -121,7 +121,7 @@
fidir =
GNUNET_FS_file_information_create_empty_directory (fs,
"file_information-context-dir",
- kuri, meta, &bo);
+ kuri, meta, &bo,
NULL);
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
GNUNET_FS_uri_destroy (kuri);
Modified: gnunet/src/fs/test_fs_list_indexed.c
===================================================================
--- gnunet/src/fs/test_fs_list_indexed.c 2012-01-09 16:38:26 UTC (rev
19069)
+++ gnunet/src/fs/test_fs_list_indexed.c 2012-01-09 16:43:54 UTC (rev
19070)
@@ -281,7 +281,7 @@
fidir =
GNUNET_FS_file_information_create_empty_directory (fs,
"list_indexed-context-dir",
- kuri, meta, &bo);
+ kuri, meta, &bo,
NULL);
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
GNUNET_FS_uri_destroy (kuri);
Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c 2012-01-09 16:38:26 UTC (rev 19069)
+++ gnunet/src/fs/test_fs_publish.c 2012-01-09 16:43:54 UTC (rev 19070)
@@ -266,7 +266,7 @@
fidir =
GNUNET_FS_file_information_create_empty_directory (fs,
"publish-context-dir",
- kuri, meta, &bo);
+ kuri, meta, &bo,
NULL);
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
GNUNET_FS_uri_destroy (kuri);
Modified: gnunet/src/fs/test_fs_publish_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_publish_persistence.c 2012-01-09 16:38:26 UTC (rev
19069)
+++ gnunet/src/fs/test_fs_publish_persistence.c 2012-01-09 16:43:54 UTC (rev
19070)
@@ -328,7 +328,7 @@
fidir =
GNUNET_FS_file_information_create_empty_directory (fs,
"publish-context-dir",
- kuri, meta, &bo);
+ kuri, meta, &bo,
NULL);
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1));
GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2));
GNUNET_FS_uri_destroy (kuri);
Modified: gnunet/src/include/gnunet_fs_service.h
===================================================================
--- gnunet/src/include/gnunet_fs_service.h 2012-01-09 16:38:26 UTC (rev
19069)
+++ gnunet/src/include/gnunet_fs_service.h 2012-01-09 16:43:54 UTC (rev
19070)
@@ -1749,8 +1749,28 @@
GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s);
+/**
+ * Obtain the filename from the file information structure.
+ *
+ * @param s structure to get the filename for
+ * @return "filename" field of the structure (can be NULL)
+ */
+const char *
+GNUNET_FS_file_information_get_filename (struct GNUNET_FS_FileInformation *s);
/**
+ * Set the filename in the file information structure.
+ * If filename was already set, frees it before setting the new one.
+ * Makes a copy of the argument.
+ *
+ * @param s structure to get the filename for
+ * @param filename filename to set
+ */
+void
+GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s,
+ const char *filename);
+
+/**
* Create an entry for a file in a publish-structure.
*
* @param h handle to the file sharing subsystem
@@ -1968,6 +1988,7 @@
* directly; can be NULL
* @param meta metadata for the directory
* @param bo block options
+ * @param filename name of the directory; can be NULL
* @return publish structure entry for the directory , NULL on error
*/
struct GNUNET_FS_FileInformation *
@@ -1979,7 +2000,8 @@
GNUNET_CONTAINER_MetaData
*meta,
const struct
- GNUNET_FS_BlockOptions *bo);
+ GNUNET_FS_BlockOptions *bo,
+ const char *filename);
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19070 - in gnunet/src: fs include,
gnunet <=