#include <unistd.h>
#include <string.h>
#include <libgen.h>
+#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
return(0);
}
+static void checkempty(char *dir)
+{
+ DIR *dh;
+ int empty;
+ struct dirent *de;
+
+ if((dh = opendir(dir)) == NULL)
+ return;
+ empty = 1;
+ while((de = readdir(dh)) != NULL) {
+ if(de->d_name[0] != '.') {
+ empty = 0;
+ break;
+ }
+ }
+ closedir(dh);
+ if(empty)
+ rmdir(dir);
+}
+
static void usage(FILE *out)
{
fprintf(out, "usage: nextep [-h] [-f FILE] [-s SET-VALUE] [DIR]\n");
fprintf(stderr, "nextep: %s: %s\n", fpath, strerror(errno));
exit(1);
}
+ checkempty(base);
} else {
if(ensuredir(buf, base)) {
fprintf(stderr, "nextep: %s: %s\n", base, strerror(errno));