This commit is contained in:
Your Name 2023-10-20 17:32:50 +03:00
parent 5fa02400f6
commit d712265401
3 changed files with 15 additions and 5 deletions

View File

@ -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++) {

View File

@ -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;
}

View File

@ -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;