1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:17:34 +00:00

Ls: Support single files in long mode

This commit is contained in:
faissaloo 2019-05-27 13:13:25 +01:00 committed by Andreas Kling
parent fee686e2cd
commit 776a359a17

View file

@ -174,6 +174,12 @@ int do_dir(const char* path)
{
DIR* dirp = opendir(path);
if (!dirp) {
if (errno == ENOTDIR) {
if (print_filesystem_object(path, path)) {
return 0;
}
return 2;
}
perror("opendir");
return 1;
}
@ -184,7 +190,9 @@ int do_dir(const char* path)
continue;
sprintf(pathbuf, "%s/%s", path, de->d_name);
print_filesystem_object(pathbuf, de->d_name);
if (!print_filesystem_object(pathbuf, de->d_name)) {
return 2;
}
}
closedir(dirp);
return 0;
@ -213,14 +221,16 @@ int do_dir_short(const char* path)
if (!dirp) {
if (errno == ENOTDIR) {
int nprinted;
print_filesystem_object_short(path, path, &nprinted);
bool status = print_filesystem_object_short(path, path, &nprinted);
printf("\n");
if (status) {
return 0;
} else {
}
return 2;
}
perror("opendir");
return 1;
}
}
Vector<String, 1024> names;
int longest_name = 0;