-nodebug #2300
[oweals/gnunet.git] / src / fs / fs_file_information.c
index a633dcb7b1264d550e54ca8e9535b85559af8bd3..806592784bfc4ae9e06280cdfac828417669f09a 100644 (file)
@@ -107,7 +107,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
                                              *bo)
 {
   struct FileInfo *fi;
-  struct stat sbuf;
+  uint64_t fsize;
   struct GNUNET_FS_FileInformation *ret;
   const char *fn;
   const char *ss;
@@ -116,7 +116,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
   char fn_conv[MAX_PATH];
 #endif
 
-  if (0 != STAT (filename, &sbuf))
+  /* FIXME: should includeSymLinks be GNUNET_NO or GNUNET_YES here? */
+  if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
   {
     GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
     return NULL;
@@ -129,7 +130,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
   }
   ret =
       GNUNET_FS_file_information_create_from_reader (h, client_info,
-                                                     sbuf.st_size,
+                                                     fsize,
                                                      &GNUNET_FS_data_reader_file_,
                                                      fi, keywords, meta,
                                                      do_index, bo);
@@ -145,6 +146,9 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
 #endif
   while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
     fn = ss + 1;
+/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
+ * this should be changed to EXTRACTOR_METAFORMAT_UTF8
+ */
 #if !WINDOWS
   GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
                                      EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
@@ -324,7 +328,7 @@ int
 GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
                                 struct GNUNET_FS_FileInformation *ent)
 {
-  if ((ent->dir != NULL) || (ent->next != NULL) || (!dir->is_directory))
+  if ((ent->dir != NULL) || (ent->next != NULL) || (dir->is_directory != GNUNET_YES))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -362,12 +366,12 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
   no = GNUNET_NO;
   if (GNUNET_OK !=
       proc (proc_cls, dir,
-            (dir->is_directory) ? dir->data.dir.dir_size : dir->data.
+            (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size : dir->data.
             file.file_size, dir->meta, &dir->keywords, &dir->bo,
-            (dir->is_directory) ? &no : &dir->data.file.do_index,
+            (dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
             &dir->client_info))
     return;
-  if (!dir->is_directory)
+  if (dir->is_directory != GNUNET_YES)
     return;
   pos = dir->data.dir.entries;
   while (pos != NULL)
@@ -375,9 +379,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
     no = GNUNET_NO;
     if (GNUNET_OK !=
         proc (proc_cls, pos,
-              (pos->is_directory) ? pos->data.dir.dir_size : pos->data.
+              (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size : pos->data.
               file.file_size, pos->meta, &pos->keywords, &pos->bo,
-              (pos->is_directory) ? &no : &pos->data.file.do_index,
+              (pos->is_directory == GNUNET_YES) ? &no : &pos->data.file.do_index,
               &pos->client_info))
       break;
     pos = pos->next;
@@ -404,7 +408,7 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
   int no;
 
   no = GNUNET_NO;
-  if (fi->is_directory)
+  if (fi->is_directory == GNUNET_YES)
   {
     /* clean up directory */
     while (NULL != (pos = fi->data.dir.entries))