aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2013-06-18 23:46:15 +0000
committerDavid Barksdale <amatus.amongus@gmail.com>2013-06-18 23:46:15 +0000
commita5ec32f96c44672b83ddadfe6a9bfa750273333f (patch)
tree7412c5804a33c1643c773ad9d35c104d8d8d6fdf
parentab47616dbca27ca5c9ccb40532a7b59ac9dcaad7 (diff)
downloadgnunet-a5ec32f96c44672b83ddadfe6a9bfa750273333f.tar.gz
gnunet-a5ec32f96c44672b83ddadfe6a9bfa750273333f.zip
Removed GNUNET_DISK_get_blocks_available since it's not used and it would
be hard to port to emscripten.
-rw-r--r--src/include/gnunet_disk_lib.h11
-rw-r--r--src/util/disk.c59
-rw-r--r--src/util/test_disk.c22
3 files changed, 0 insertions, 92 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index 427b55c08..c26f9dcda 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -268,17 +268,6 @@ enum GNUNET_DISK_PipeEnd
268 268
269 269
270/** 270/**
271 * Get the number of blocks that are left on the partition that
272 * contains the given file (for normal users).
273 *
274 * @param part a file on the partition to check
275 * @return -1 on errors, otherwise the number of free blocks
276 */
277long
278GNUNET_DISK_get_blocks_available (const char *part);
279
280
281/**
282 * Checks whether a handle is invalid 271 * Checks whether a handle is invalid
283 * 272 *
284 * @param h handle to check 273 * @param h handle to check
diff --git a/src/util/disk.c b/src/util/disk.c
index 6dca6db54..6da5c8c1d 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -560,65 +560,6 @@ GNUNET_DISK_mktemp (const char *t)
560 560
561 561
562/** 562/**
563 * Get the number of blocks that are left on the partition that
564 * contains the given file (for normal users).
565 *
566 * @param part a file on the partition to check
567 * @return -1 on errors, otherwise the number of free blocks
568 */
569long
570GNUNET_DISK_get_blocks_available (const char *part)
571{
572#ifdef SOLARIS
573 struct statvfs buf;
574
575 if (0 != statvfs (part, &buf))
576 {
577 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "statfs", part);
578 return -1;
579 }
580 return buf.f_bavail;
581#elif MINGW
582 DWORD dwDummy;
583 DWORD dwBlocks;
584 wchar_t szDrive[4];
585 wchar_t wpath[MAX_PATH + 1];
586 char *path;
587
588 path = GNUNET_STRINGS_filename_expand (part);
589 if (path == NULL)
590 return -1;
591 /* "part" was in UTF-8, and so is "path" */
592 if (ERROR_SUCCESS != plibc_conv_to_win_pathwconv(path, wpath))
593 {
594 GNUNET_free (path);
595 return -1;
596 }
597 GNUNET_free (path);
598 wcsncpy (szDrive, wpath, 3);
599 szDrive[3] = 0;
600 if (!GetDiskFreeSpaceW (szDrive, &dwDummy, &dwDummy, &dwBlocks, &dwDummy))
601 {
602 LOG (GNUNET_ERROR_TYPE_WARNING, _("`%s' failed for drive `%S': %u\n"),
603 "GetDiskFreeSpace", szDrive, GetLastError ());
604
605 return -1;
606 }
607 return dwBlocks;
608#else
609 struct statfs s;
610
611 if (0 != statfs (part, &s))
612 {
613 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "statfs", part);
614 return -1;
615 }
616 return s.f_bavail;
617#endif
618}
619
620
621/**
622 * Test if "fil" is a directory and listable. Optionally, also check if the 563 * Test if "fil" is a directory and listable. Optionally, also check if the
623 * directory is readable. Will not print an error message if the directory does 564 * directory is readable. Will not print an error message if the directory does
624 * not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file exists 565 * not exist. Will log errors if GNUNET_SYSERR is returned (i.e., a file exists
diff --git a/src/util/test_disk.c b/src/util/test_disk.c
index 804a870e5..7fc8618ce 100644
--- a/src/util/test_disk.c
+++ b/src/util/test_disk.c
@@ -86,7 +86,6 @@ testOpenClose ()
86{ 86{
87 struct GNUNET_DISK_FileHandle *fh; 87 struct GNUNET_DISK_FileHandle *fh;
88 uint64_t size; 88 uint64_t size;
89 long avail;
90 89
91 fh = GNUNET_DISK_file_open (".testfile", 90 fh = GNUNET_DISK_file_open (".testfile",
92 GNUNET_DISK_OPEN_READWRITE | 91 GNUNET_DISK_OPEN_READWRITE |
@@ -102,27 +101,6 @@ testOpenClose ()
102 return 1; 101 return 1;
103 GNUNET_break (0 == UNLINK (".testfile")); 102 GNUNET_break (0 == UNLINK (".testfile"));
104 103
105 /* test that avail goes down as we fill the disk... */
106 GNUNET_log_skip (1, GNUNET_NO);
107 avail = GNUNET_DISK_get_blocks_available (".testfile");
108 GNUNET_log_skip (0, GNUNET_NO);
109 fh = GNUNET_DISK_file_open (".testfile",
110 GNUNET_DISK_OPEN_READWRITE |
111 GNUNET_DISK_OPEN_CREATE,
112 GNUNET_DISK_PERM_USER_WRITE |
113 GNUNET_DISK_PERM_USER_READ);
114 GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh));
115 while ((avail == GNUNET_DISK_get_blocks_available (".testfile")) &&
116 (avail != -1))
117 if (16 != GNUNET_DISK_file_write (fh, "HelloWorld123456", 16))
118 {
119 GNUNET_DISK_file_close (fh);
120 GNUNET_break (0 == UNLINK (".testfile"));
121 return 1;
122 }
123 GNUNET_DISK_file_close (fh);
124 GNUNET_break (0 == UNLINK (".testfile"));
125
126 return 0; 104 return 0;
127} 105}
128 106