mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 12:17:45 +00:00
Ls: Support single files in long mode
This commit is contained in:
parent
fee686e2cd
commit
776a359a17
1 changed files with 16 additions and 6 deletions
|
@ -174,6 +174,12 @@ int do_dir(const char* path)
|
||||||
{
|
{
|
||||||
DIR* dirp = opendir(path);
|
DIR* dirp = opendir(path);
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
|
if (errno == ENOTDIR) {
|
||||||
|
if (print_filesystem_object(path, path)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
perror("opendir");
|
perror("opendir");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +190,9 @@ int do_dir(const char* path)
|
||||||
continue;
|
continue;
|
||||||
sprintf(pathbuf, "%s/%s", path, de->d_name);
|
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);
|
closedir(dirp);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -213,14 +221,16 @@ int do_dir_short(const char* path)
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
if (errno == ENOTDIR) {
|
if (errno == ENOTDIR) {
|
||||||
int nprinted;
|
int nprinted;
|
||||||
print_filesystem_object_short(path, path, &nprinted);
|
bool status = print_filesystem_object_short(path, path, &nprinted);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
if (status) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
perror("opendir");
|
perror("opendir");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Vector<String, 1024> names;
|
Vector<String, 1024> names;
|
||||||
int longest_name = 0;
|
int longest_name = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue