aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_file_information.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-09 16:43:54 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-09 16:43:54 +0000
commit0e770eb262e25bd2d2b268d2f72c4918280a4a2a (patch)
treed1d1005abf1a0bb8bbe33d10043b400f5486523d /src/fs/fs_file_information.c
parentc4829724c001815fd57fc2f1d44c7815602196ec (diff)
downloadgnunet-0e770eb262e25bd2d2b268d2f72c4918280a4a2a.tar.gz
gnunet-0e770eb262e25bd2d2b268d2f72c4918280a4a2a.zip
-LRN: make file filename alterable and initializable
Diffstat (limited to 'src/fs/fs_file_information.c')
-rw-r--r--src/fs/fs_file_information.c42
1 files changed, 38 insertions, 4 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 */
116const char *
117GNUNET_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 */
131void
132GNUNET_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 */
825struct GNUNET_FS_FileInformation * 856struct 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