aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-05 13:05:14 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-05 13:05:14 +0000
commitfcfef3ee8c14488a689636bab590d19b8ff3b43d (patch)
tree19d4a4ecbd12f538f02c1e43699b27154cf0d190 /src/fs
parent4e4a397228548042d6be340e0e304bc7d52db74d (diff)
downloadgnunet-fcfef3ee8c14488a689636bab590d19b8ff3b43d.tar.gz
gnunet-fcfef3ee8c14488a689636bab590d19b8ff3b43d.zip
test if dirs exist, create dirs if needed
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c
index 5b3dd067a..817b29d7f 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -986,6 +986,12 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h,
986 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 986 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
987 return NULL; /* persistence not requested */ 987 return NULL; /* persistence not requested */
988 dn = get_serialization_file_name (h, ext, ""); 988 dn = get_serialization_file_name (h, ext, "");
989 if (GNUNET_OK !=
990 GNUNET_DISK_directory_create_for_file (dn))
991 {
992 GNUNET_free (dn);
993 return NULL;
994 }
989 fn = GNUNET_DISK_mktemp (dn); 995 fn = GNUNET_DISK_mktemp (dn);
990 GNUNET_free (dn); 996 GNUNET_free (dn);
991 if (fn == NULL) 997 if (fn == NULL)
@@ -1017,6 +1023,12 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
1017 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 1023 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
1018 return NULL; /* persistence not requested */ 1024 return NULL; /* persistence not requested */
1019 dn = get_serialization_file_name_in_dir (h, ext, uni, ""); 1025 dn = get_serialization_file_name_in_dir (h, ext, uni, "");
1026 if (GNUNET_OK !=
1027 GNUNET_DISK_directory_create_for_file (dn))
1028 {
1029 GNUNET_free (dn);
1030 return NULL;
1031 }
1020 fn = GNUNET_DISK_mktemp (dn); 1032 fn = GNUNET_DISK_mktemp (dn);
1021 GNUNET_free (dn); 1033 GNUNET_free (dn);
1022 if (fn == NULL) 1034 if (fn == NULL)
@@ -1607,6 +1619,12 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
1607 dir = get_download_sync_filename (dc, ""); 1619 dir = get_download_sync_filename (dc, "");
1608 if (dir == NULL) 1620 if (dir == NULL)
1609 return; 1621 return;
1622 if (GNUNET_OK !=
1623 GNUNET_DISK_directory_create_for_file (dir))
1624 {
1625 GNUNET_free (dir);
1626 return;
1627 }
1610 fn = GNUNET_DISK_mktemp (dir); 1628 fn = GNUNET_DISK_mktemp (dir);
1611 GNUNET_free (dir); 1629 GNUNET_free (dir);
1612 dc->serialization = get_serialization_short_name (fn); 1630 dc->serialization = get_serialization_short_name (fn);
@@ -2422,7 +2440,9 @@ deserialize_download (struct GNUNET_FS_Handle *h,
2422 dn = get_download_sync_filename (dc, ""); 2440 dn = get_download_sync_filename (dc, "");
2423 if (dn != NULL) 2441 if (dn != NULL)
2424 { 2442 {
2425 GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc); 2443 if (GNUNET_YES ==
2444 GNUNET_DISK_directory_test (dn))
2445 GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc);
2426 GNUNET_free (dn); 2446 GNUNET_free (dn);
2427 } 2447 }
2428 if (parent != NULL) 2448 if (parent != NULL)
@@ -2531,7 +2551,9 @@ deserialize_search (struct GNUNET_FS_Handle *h,
2531 ""); 2551 "");
2532 if (dn != NULL) 2552 if (dn != NULL)
2533 { 2553 {
2534 GNUNET_DISK_directory_scan (dn, &deserialize_search_result, sc); 2554 if (GNUNET_YES ==
2555 GNUNET_DISK_directory_test (dn))
2556 GNUNET_DISK_directory_scan (dn, &deserialize_search_result, sc);
2535 GNUNET_free (dn); 2557 GNUNET_free (dn);
2536 } 2558 }
2537 if ( ('\0' == in_pause) && 2559 if ( ('\0' == in_pause) &&
@@ -2658,7 +2680,9 @@ deserialization_master (const char *master_path,
2658 dn = get_serialization_file_name (h, master_path, ""); 2680 dn = get_serialization_file_name (h, master_path, "");
2659 if (dn == NULL) 2681 if (dn == NULL)
2660 return; 2682 return;
2661 GNUNET_DISK_directory_scan (dn, proc, h); 2683 if (GNUNET_YES ==
2684 GNUNET_DISK_directory_test (dn))
2685 GNUNET_DISK_directory_scan (dn, proc, h);
2662 GNUNET_free (dn); 2686 GNUNET_free (dn);
2663} 2687}
2664 2688