diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-09 16:43:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-09 16:43:54 +0000 |
commit | 0e770eb262e25bd2d2b268d2f72c4918280a4a2a (patch) | |
tree | d1d1005abf1a0bb8bbe33d10043b400f5486523d /src | |
parent | c4829724c001815fd57fc2f1d44c7815602196ec (diff) | |
download | gnunet-0e770eb262e25bd2d2b268d2f72c4918280a4a2a.tar.gz gnunet-0e770eb262e25bd2d2b268d2f72c4918280a4a2a.zip |
-LRN: make file filename alterable and initializable
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_file_information.c | 42 | ||||
-rw-r--r-- | src/fs/test_fs_file_information.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_list_indexed.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_publish.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_publish_persistence.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 24 |
6 files changed, 65 insertions, 9 deletions
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index c2ab84ec2..cade94a79 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -107,6 +107,37 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s) | |||
107 | return s->serialization; | 107 | return s->serialization; |
108 | } | 108 | } |
109 | 109 | ||
110 | /** | ||
111 | * Obtain the filename from the file information structure. | ||
112 | * | ||
113 | * @param s structure to get the filename for | ||
114 | * @return "filename" field of the structure (can be NULL) | ||
115 | */ | ||
116 | const char * | ||
117 | GNUNET_FS_file_information_get_filename (struct GNUNET_FS_FileInformation *s) | ||
118 | { | ||
119 | return s->filename; | ||
120 | } | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Set the filename in the file information structure. | ||
125 | * If filename was already set, frees it before setting the new one. | ||
126 | * Makes a copy of the argument. | ||
127 | * | ||
128 | * @param s structure to get the filename for | ||
129 | * @param filename filename to set | ||
130 | */ | ||
131 | void | ||
132 | GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s, | ||
133 | const char *filename) | ||
134 | { | ||
135 | GNUNET_free_non_null (s->filename); | ||
136 | if (filename) | ||
137 | s->filename = GNUNET_strdup (filename); | ||
138 | else | ||
139 | s->filename = NULL; | ||
140 | } | ||
110 | 141 | ||
111 | /** | 142 | /** |
112 | * Create an entry for a file in a publish-structure. | 143 | * Create an entry for a file in a publish-structure. |
@@ -764,7 +795,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
764 | GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, GNUNET_FS_DIRECTORY_MIME, GNUNET_NO); | 795 | GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, GNUNET_FS_DIRECTORY_MIME, GNUNET_NO); |
765 | ret = | 796 | ret = |
766 | GNUNET_FS_file_information_create_empty_directory (h, client_info, cdmc.ksk, | 797 | GNUNET_FS_file_information_create_empty_directory (h, client_info, cdmc.ksk, |
767 | cdmc.meta, bo); | 798 | cdmc.meta, bo, filename); |
768 | GNUNET_CONTAINER_meta_data_destroy (cdmc.meta); | 799 | GNUNET_CONTAINER_meta_data_destroy (cdmc.meta); |
769 | GNUNET_FS_uri_destroy (cdmc.ksk); | 800 | GNUNET_FS_uri_destroy (cdmc.ksk); |
770 | ret->data.dir.entries = dc.entries; | 801 | ret->data.dir.entries = dc.entries; |
@@ -789,8 +820,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
789 | "text/plain", dn, strlen (dn) + 1); | 820 | "text/plain", dn, strlen (dn) + 1); |
790 | #endif | 821 | #endif |
791 | GNUNET_free (dn); | 822 | GNUNET_free (dn); |
792 | ret->filename = GNUNET_strdup (filename); | 823 | return ret; |
793 | return ret; | ||
794 | } | 824 | } |
795 | 825 | ||
796 | 826 | ||
@@ -820,6 +850,7 @@ GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation | |||
820 | * @param keywords under which keywords should this directory be available | 850 | * @param keywords under which keywords should this directory be available |
821 | * directly; can be NULL | 851 | * directly; can be NULL |
822 | * @param bo block options | 852 | * @param bo block options |
853 | * @param filename name of the directory; can be NULL | ||
823 | * @return publish structure entry for the directory , NULL on error | 854 | * @return publish structure entry for the directory , NULL on error |
824 | */ | 855 | */ |
825 | struct GNUNET_FS_FileInformation * | 856 | struct GNUNET_FS_FileInformation * |
@@ -831,7 +862,8 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, | |||
831 | GNUNET_CONTAINER_MetaData | 862 | GNUNET_CONTAINER_MetaData |
832 | *meta, | 863 | *meta, |
833 | const struct | 864 | const struct |
834 | GNUNET_FS_BlockOptions *bo) | 865 | GNUNET_FS_BlockOptions *bo, |
866 | const char *filename) | ||
835 | { | 867 | { |
836 | struct GNUNET_FS_FileInformation *ret; | 868 | struct GNUNET_FS_FileInformation *ret; |
837 | 869 | ||
@@ -842,6 +874,8 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, | |||
842 | ret->keywords = GNUNET_FS_uri_dup (keywords); | 874 | ret->keywords = GNUNET_FS_uri_dup (keywords); |
843 | ret->bo = *bo; | 875 | ret->bo = *bo; |
844 | ret->is_directory = GNUNET_YES; | 876 | ret->is_directory = GNUNET_YES; |
877 | if (filename != NULL) | ||
878 | ret->filename = GNUNET_strdup (filename); | ||
845 | return ret; | 879 | return ret; |
846 | } | 880 | } |
847 | 881 | ||
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index 0a2969cd3..8d89312df 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c | |||
@@ -121,7 +121,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
121 | fidir = | 121 | fidir = |
122 | GNUNET_FS_file_information_create_empty_directory (fs, | 122 | GNUNET_FS_file_information_create_empty_directory (fs, |
123 | "file_information-context-dir", | 123 | "file_information-context-dir", |
124 | kuri, meta, &bo); | 124 | kuri, meta, &bo, NULL); |
125 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); | 125 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); |
126 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); | 126 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); |
127 | GNUNET_FS_uri_destroy (kuri); | 127 | GNUNET_FS_uri_destroy (kuri); |
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index 8a847ba2b..5d2ad5d78 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c | |||
@@ -281,7 +281,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
281 | fidir = | 281 | fidir = |
282 | GNUNET_FS_file_information_create_empty_directory (fs, | 282 | GNUNET_FS_file_information_create_empty_directory (fs, |
283 | "list_indexed-context-dir", | 283 | "list_indexed-context-dir", |
284 | kuri, meta, &bo); | 284 | kuri, meta, &bo, NULL); |
285 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); | 285 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); |
286 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); | 286 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); |
287 | GNUNET_FS_uri_destroy (kuri); | 287 | GNUNET_FS_uri_destroy (kuri); |
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index 051b84f68..65632cb08 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c | |||
@@ -266,7 +266,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
266 | fidir = | 266 | fidir = |
267 | GNUNET_FS_file_information_create_empty_directory (fs, | 267 | GNUNET_FS_file_information_create_empty_directory (fs, |
268 | "publish-context-dir", | 268 | "publish-context-dir", |
269 | kuri, meta, &bo); | 269 | kuri, meta, &bo, NULL); |
270 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); | 270 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); |
271 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); | 271 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); |
272 | GNUNET_FS_uri_destroy (kuri); | 272 | GNUNET_FS_uri_destroy (kuri); |
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index 4d569849f..cdd6d818f 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c | |||
@@ -328,7 +328,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
328 | fidir = | 328 | fidir = |
329 | GNUNET_FS_file_information_create_empty_directory (fs, | 329 | GNUNET_FS_file_information_create_empty_directory (fs, |
330 | "publish-context-dir", | 330 | "publish-context-dir", |
331 | kuri, meta, &bo); | 331 | kuri, meta, &bo, NULL); |
332 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); | 332 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); |
333 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); | 333 | GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); |
334 | GNUNET_FS_uri_destroy (kuri); | 334 | GNUNET_FS_uri_destroy (kuri); |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 34925d562..cd9093a8e 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -1749,6 +1749,26 @@ const char * | |||
1749 | GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s); | 1749 | GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s); |
1750 | 1750 | ||
1751 | 1751 | ||
1752 | /** | ||
1753 | * Obtain the filename from the file information structure. | ||
1754 | * | ||
1755 | * @param s structure to get the filename for | ||
1756 | * @return "filename" field of the structure (can be NULL) | ||
1757 | */ | ||
1758 | const char * | ||
1759 | GNUNET_FS_file_information_get_filename (struct GNUNET_FS_FileInformation *s); | ||
1760 | |||
1761 | /** | ||
1762 | * Set the filename in the file information structure. | ||
1763 | * If filename was already set, frees it before setting the new one. | ||
1764 | * Makes a copy of the argument. | ||
1765 | * | ||
1766 | * @param s structure to get the filename for | ||
1767 | * @param filename filename to set | ||
1768 | */ | ||
1769 | void | ||
1770 | GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s, | ||
1771 | const char *filename); | ||
1752 | 1772 | ||
1753 | /** | 1773 | /** |
1754 | * Create an entry for a file in a publish-structure. | 1774 | * Create an entry for a file in a publish-structure. |
@@ -1968,6 +1988,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
1968 | * directly; can be NULL | 1988 | * directly; can be NULL |
1969 | * @param meta metadata for the directory | 1989 | * @param meta metadata for the directory |
1970 | * @param bo block options | 1990 | * @param bo block options |
1991 | * @param filename name of the directory; can be NULL | ||
1971 | * @return publish structure entry for the directory , NULL on error | 1992 | * @return publish structure entry for the directory , NULL on error |
1972 | */ | 1993 | */ |
1973 | struct GNUNET_FS_FileInformation * | 1994 | struct GNUNET_FS_FileInformation * |
@@ -1979,7 +2000,8 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, | |||
1979 | GNUNET_CONTAINER_MetaData | 2000 | GNUNET_CONTAINER_MetaData |
1980 | *meta, | 2001 | *meta, |
1981 | const struct | 2002 | const struct |
1982 | GNUNET_FS_BlockOptions *bo); | 2003 | GNUNET_FS_BlockOptions *bo, |
2004 | const char *filename); | ||
1983 | 2005 | ||
1984 | 2006 | ||
1985 | /** | 2007 | /** |