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/gnunet-helper-fs-publish.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/gnunet-helper-fs-publish.c')
-rw-r--r-- | src/fs/gnunet-helper-fs-publish.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 4f7046408..4bb77fa22 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -69,7 +69,8 @@ struct ScanTreeNode | |||
69 | char *filename; | 69 | char *filename; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Size of the file (if it is a file), in bytes | 72 | * Size of the file (if it is a file), in bytes. |
73 | * At the moment it is set to 0 for directories. | ||
73 | */ | 74 | */ |
74 | uint64_t file_size; | 75 | uint64_t file_size; |
75 | 76 | ||
@@ -275,8 +276,11 @@ preprocess_file (const char *filename, | |||
275 | { | 276 | { |
276 | struct ScanTreeNode *item; | 277 | struct ScanTreeNode *item; |
277 | struct stat sbuf; | 278 | struct stat sbuf; |
279 | uint64_t fsize = 0; | ||
278 | 280 | ||
279 | if (0 != STAT (filename, &sbuf)) | 281 | if ((0 != STAT (filename, &sbuf)) || |
282 | ((!S_ISDIR (sbuf.st_mode)) && (GNUNET_OK != GNUNET_DISK_file_size ( | ||
283 | filename, &fsize, GNUNET_NO, GNUNET_YES)))) | ||
280 | { | 284 | { |
281 | /* If the file doesn't exist (or is not stat-able for any other reason) | 285 | /* If the file doesn't exist (or is not stat-able for any other reason) |
282 | skip it (but report it), but do continue. */ | 286 | skip it (but report it), but do continue. */ |
@@ -297,7 +301,7 @@ preprocess_file (const char *filename, | |||
297 | item = GNUNET_malloc (sizeof (struct ScanTreeNode)); | 301 | item = GNUNET_malloc (sizeof (struct ScanTreeNode)); |
298 | item->filename = GNUNET_strdup (filename); | 302 | item->filename = GNUNET_strdup (filename); |
299 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; | 303 | item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; |
300 | item->file_size = (uint64_t) sbuf.st_size; | 304 | item->file_size = fsize; |
301 | if (item->is_directory == GNUNET_YES) | 305 | if (item->is_directory == GNUNET_YES) |
302 | { | 306 | { |
303 | struct RecursionContext rc; | 307 | struct RecursionContext rc; |