mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03:00
Ls: Cleanup
This commit is contained in:
parent
4c410f3de6
commit
f28cc2e2e0
Notes:
sideshowbarker
2024-07-19 13:54:44 +09:00
Author: https://github.com/faissaloo Commit: https://github.com/SerenityOS/serenity/commit/f28cc2e2e0a Pull-request: https://github.com/SerenityOS/serenity/pull/120 Reviewed-by: https://github.com/awesomekling
@ -11,8 +11,8 @@
|
|||||||
#include <AK/AKString.h>
|
#include <AK/AKString.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
|
||||||
static int do_dir(const char* path);
|
static int do_file_system_object_long(const char* path);
|
||||||
static int do_dir_short(const char* path);
|
static int do_file_system_object_short(const char* path);
|
||||||
|
|
||||||
static bool flag_colorize = true;
|
static bool flag_colorize = true;
|
||||||
static bool flag_long = false;
|
static bool flag_long = false;
|
||||||
@ -45,30 +45,24 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
int status;
|
int status;
|
||||||
if (optind >= argc) {
|
if (optind >= argc) {
|
||||||
if (flag_long) {
|
status = do_file_system_object(".")
|
||||||
status = do_dir(".");
|
} if (optind+1 >= argc) {
|
||||||
} else {
|
status = do_file_system_object(argv[optind]);
|
||||||
status = do_dir_short(".");
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
} else {
|
} else {
|
||||||
bool show_names = !(optind+1 >= argc);
|
|
||||||
|
|
||||||
for (; optind < argc; optind++) {
|
for (; optind < argc; optind++) {
|
||||||
if (show_names) {
|
|
||||||
printf("%s:\n", argv[optind]);
|
printf("%s:\n", argv[optind]);
|
||||||
}
|
status = do_file_system_object(argv[optind]);
|
||||||
if (flag_long) {
|
|
||||||
status = do_dir(argv[optind]);
|
|
||||||
} else {
|
|
||||||
status = do_dir_short(argv[optind]);
|
|
||||||
}
|
|
||||||
if (status != 0) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int do_file_system_object(const char* path) {
|
||||||
|
if (flag_long) {
|
||||||
|
return do_file_system_object_long(argv[optind]);
|
||||||
|
} else {
|
||||||
|
return do_file_system_object_short(argv[optind]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_geometry(int& rows, int& columns)
|
void get_geometry(int& rows, int& columns)
|
||||||
@ -186,7 +180,7 @@ bool print_filesystem_object(const char* path, const char* name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_dir(const char* path)
|
int do_file_system_object_long(const char* path)
|
||||||
{
|
{
|
||||||
DIR* dirp = opendir(path);
|
DIR* dirp = opendir(path);
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
@ -227,7 +221,7 @@ bool print_filesystem_object_short(const char *path, const char *name, int *npri
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_dir_short(const char* path)
|
int do_file_system_object_short(const char* path)
|
||||||
{
|
{
|
||||||
int rows;
|
int rows;
|
||||||
int columns;
|
int columns;
|
||||||
|
Loading…
Reference in New Issue
Block a user