diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-19 10:48:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-19 10:48:51 +0000 |
commit | b3e1d0806fb274c62a5acf19c56369b71f992312 (patch) | |
tree | 657a7cd7a327aad0e7598b3d28cecc0d5cd95cd4 /src/fs/fs_file_information.c | |
parent | 0385dc1043912d3ddc5d57f6b7346054a30f64ef (diff) | |
download | gnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.tar.gz gnunet-b3e1d0806fb274c62a5acf19c56369b71f992312.zip |
-LRN: calculate file size for single files when needed and use GNUNET_DISK_file_size instead of STAT
Diffstat (limited to 'src/fs/fs_file_information.c')
-rw-r--r-- | src/fs/fs_file_information.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 85a076fee..806592784 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -107,7 +107,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
107 | *bo) | 107 | *bo) |
108 | { | 108 | { |
109 | struct FileInfo *fi; | 109 | struct FileInfo *fi; |
110 | struct stat sbuf; | 110 | uint64_t fsize; |
111 | struct GNUNET_FS_FileInformation *ret; | 111 | struct GNUNET_FS_FileInformation *ret; |
112 | const char *fn; | 112 | const char *fn; |
113 | const char *ss; | 113 | const char *ss; |
@@ -116,7 +116,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
116 | char fn_conv[MAX_PATH]; | 116 | char fn_conv[MAX_PATH]; |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | if (0 != STAT (filename, &sbuf)) | 119 | /* FIXME: should includeSymLinks be GNUNET_NO or GNUNET_YES here? */ |
120 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES)) | ||
120 | { | 121 | { |
121 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename); | 122 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename); |
122 | return NULL; | 123 | return NULL; |
@@ -129,7 +130,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
129 | } | 130 | } |
130 | ret = | 131 | ret = |
131 | GNUNET_FS_file_information_create_from_reader (h, client_info, | 132 | GNUNET_FS_file_information_create_from_reader (h, client_info, |
132 | sbuf.st_size, | 133 | fsize, |
133 | &GNUNET_FS_data_reader_file_, | 134 | &GNUNET_FS_data_reader_file_, |
134 | fi, keywords, meta, | 135 | fi, keywords, meta, |
135 | do_index, bo); | 136 | do_index, bo); |
@@ -145,6 +146,9 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, | |||
145 | #endif | 146 | #endif |
146 | while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) | 147 | while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) |
147 | fn = ss + 1; | 148 | fn = ss + 1; |
149 | /* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then | ||
150 | * this should be changed to EXTRACTOR_METAFORMAT_UTF8 | ||
151 | */ | ||
148 | #if !WINDOWS | 152 | #if !WINDOWS |
149 | GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>", | 153 | GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>", |
150 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 154 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |