Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
faissaloo committed May 27, 2019
1 parent fb942ee commit ef1d84d
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions Userland/ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <AK/AKString.h>
#include <AK/Vector.h>

static int do_dir(const char* path);
static int do_dir_long(const char* path);
static int do_dir_short(const char* path);

static bool flag_colorize = true;
Expand Down Expand Up @@ -45,30 +45,24 @@ int main(int argc, char** argv)

int status;
if (optind >= argc) {
if (flag_long) {
status = do_dir(".");
} else {
status = do_dir_short(".");
}
return status;
status = do_dir(".")
} if (optind+1 >= argc) {
status = do_dir(argv[optind]);
} else {
bool show_names = !(optind+1 >= argc);

for (; optind < argc; optind++) {
if (show_names) {
printf("%s:\n", argv[optind]);
}
if (flag_long) {
status = do_dir(argv[optind]);
} else {
status = do_dir_short(argv[optind]);
}
if (status != 0) {
return status;
}
status = do_dir(argv[optind]);
}
}
return 0;
return status;
}

int do_dir(const char* path) {
if (flag_long) {
return do_dir_long(argv[optind]);
} else {
return do_dir_short(argv[optind]);
}
}

void get_geometry(int& rows, int& columns)
Expand Down Expand Up @@ -186,7 +180,7 @@ bool print_filesystem_object(const char* path, const char* name) {
return true;
}

int do_dir(const char* path)
int do_dir_long(const char* path)
{
DIR* dirp = opendir(path);
if (!dirp) {
Expand Down

0 comments on commit ef1d84d

Please sign in to comment.