.
This commit is contained in:
parent
5fa02400f6
commit
d712265401
@ -129,7 +129,7 @@ int cptree(const char *src, const char *dst) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(const int argc, const char **argv) {
|
||||
int main(const int argc, char **argv) {
|
||||
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@ -33,8 +34,13 @@ int list(const char *path, int label) {
|
||||
if (label)
|
||||
printf("\n%s: \n", path);
|
||||
|
||||
if (chdir(path)) {
|
||||
fprintf(stderr, "ls: %s: %s\n", path, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open and print dir */
|
||||
DIR *dp = opendir(path);
|
||||
DIR *dp = opendir(".");
|
||||
if (dp == NULL) {
|
||||
fprintf(stderr, "ls: %s: %s\n", path, strerror(errno));
|
||||
return 1;
|
||||
@ -64,14 +70,15 @@ int list(const char *path, int label) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf(" %jd %jd %s ", (uintmax_t)sb.st_mode, (uintmax_t)sb.st_size, date);
|
||||
printf(" %jd %jd %s %s\n", (uintmax_t)sb.st_mode, (uintmax_t)sb.st_size, date, ep->d_name);
|
||||
}
|
||||
|
||||
printf("%s ", ep->d_name);
|
||||
printf("\n");
|
||||
else
|
||||
printf("%s ", ep->d_name);
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,9 @@ int main(const int argc, char **argv) {
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-')
|
||||
continue;
|
||||
|
||||
int status = rmtree(argv[i]);
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
Loading…
Reference in New Issue
Block a user