aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-12-10 13:55:48 +0000
committerChristian Grothoff <christian@grothoff.org>2009-12-10 13:55:48 +0000
commit1df0f263b3062715aecba640f438a95bf2d33bb9 (patch)
treee6c5074053b6a04ee404e24454cbbf736f95c6bd /src/fs
parentc300b9d59bef391a73db246b2a87fc57d61bb98e (diff)
downloadgnunet-1df0f263b3062715aecba640f438a95bf2d33bb9.tar.gz
gnunet-1df0f263b3062715aecba640f438a95bf2d33bb9.zip
working on gnunet-directory
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-directory.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index 6c7bcdaf3..22eecdb19 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -102,50 +102,53 @@ run (void *cls,
102 void *data; 102 void *data;
103 size_t len; 103 size_t len;
104 uint64_t size; 104 uint64_t size;
105 const char *filename = args[0]; 105 const char *filename;
106 int i;
106 107
107 if (NULL == filename) 108 if (NULL == argv[0])
108 { 109 {
109 fprintf (stderr, 110 fprintf (stderr,
110 _("You must specify a filename to inspect.")); 111 _("You must specify a filename to inspect."));
111 ret = 1; 112 ret = 1;
112 return; 113 return;
113 } 114 }
114 if ( (GNUNET_OK != 115 i = 0;
115 GNUNET_DISK_file_size (filename, 116 while (NULL != (filename = args[i++]))
116 &size,
117 GNUNET_YES)) ||
118 (NULL == (h = GNUNET_DISK_file_open (filename,
119 GNUNET_DISK_OPEN_READ,
120 GNUNET_DISK_PERM_NONE))) )
121 { 117 {
122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 118 if ( (GNUNET_OK !=
123 _("Failed to read directory `%s'\n"), 119 GNUNET_DISK_file_size (filename,
124 filename); 120 &size,
125 ret = 1; 121 GNUNET_YES)) ||
126 return; 122 (NULL == (h = GNUNET_DISK_file_open (filename,
123 GNUNET_DISK_OPEN_READ,
124 GNUNET_DISK_PERM_NONE))) )
125 {
126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
127 _("Failed to read directory `%s'\n"),
128 filename);
129 ret = 1;
130 continue;
131 }
132 len = (size_t) size;
133 data = GNUNET_DISK_file_map (h,
134 &map,
135 GNUNET_DISK_MAP_TYPE_READ,
136 len);
137 GNUNET_assert (NULL != data);
138 GNUNET_FS_directory_list_contents (len,
139 data,
140 0,
141 &print_entry,
142 NULL);
143 GNUNET_DISK_file_unmap (map);
144 GNUNET_DISK_file_close (h);
127 } 145 }
128 len = (size_t) size;
129 data = GNUNET_DISK_file_map (h,
130 &map,
131 GNUNET_DISK_MAP_TYPE_READ,
132 len);
133 GNUNET_assert (NULL != data);
134 GNUNET_FS_directory_list_contents (len,
135 data,
136 0,
137 &print_entry,
138 NULL);
139 GNUNET_DISK_file_unmap (map);
140 GNUNET_DISK_file_close (h);
141} 146}
142 147
143
144/** 148/**
145 * gnunet-directory command line options 149 * gnunet-directory command line options
146 */ 150 */
147static struct GNUNET_GETOPT_CommandLineOption options[] = { 151static struct GNUNET_GETOPT_CommandLineOption options[] = {
148 // FIXME: options!
149 GNUNET_GETOPT_OPTION_END 152 GNUNET_GETOPT_OPTION_END
150}; 153};
151 154