Commit a1cdcb3d a1cdcb3d53d87ad3cd24fa5909752a90806fa693 by Sergey Poznyakoff

A (very rudimentary) implementation.

1 parent ac2f982e
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
18 #include "mail.h" 18 #include "mail.h"
19 #include <dirent.h>
19 20
20 /* 21 /*
21 * folders 22 * folders
...@@ -24,7 +25,37 @@ ...@@ -24,7 +25,37 @@
24 int 25 int
25 mail_folders (int argc, char **argv) 26 mail_folders (int argc, char **argv)
26 { 27 {
27 fprintf (ofile, "Function not implemented in %s line %d\n", 28 DIR *dir;
28 __FILE__, __LINE__); 29 struct dirent *dirent;
30 char *path;
31 struct mail_env_entry *env = util_find_env ("folder");
32
33 if (!env->set)
34 {
35 fprintf(ofile, "No value set for \"folder\"\n");
36 return 1;
37 }
38
39 path = util_fullpath(env->value);
40 dir = opendir(path);
41 if (!dir)
42 {
43 fprintf(ofile, "can't open directory `%s'\n", path);
44 free(path);
29 return 1; 45 return 1;
46 }
47
48
49 while (dirent = readdir(dir))
50 {
51 if (dirent->d_name[0] == '.')
52 continue;
53 fprintf(ofile, "%s\n", dirent->d_name);
54 }
55
56 closedir(dir);
57
58 free(path);
59
60 return 0;
30 } 61 }
......