fix show hidden logic and fix cannot navigate to root
This commit is contained in:
parent
920a660f23
commit
d723be72ff
1 changed files with 5 additions and 1 deletions
6
ccc.c
6
ccc.c
|
@ -127,6 +127,10 @@ int main(int argc, char** argv)
|
||||||
strcpy(p_cwd, cwd);
|
strcpy(p_cwd, cwd);
|
||||||
char *last_slash = strrchr(cwd, '/');
|
char *last_slash = strrchr(cwd, '/');
|
||||||
if (last_slash != NULL) {
|
if (last_slash != NULL) {
|
||||||
|
if (last_slash == cwd) {
|
||||||
|
strcpy(cwd, "/");
|
||||||
|
change_dir(cwd, 0);
|
||||||
|
}
|
||||||
*last_slash = '\0';
|
*last_slash = '\0';
|
||||||
change_dir(cwd, 0);
|
change_dir(cwd, 0);
|
||||||
}
|
}
|
||||||
|
@ -449,7 +453,7 @@ void populate_files(const char *path, int ftype)
|
||||||
strcat(filename, ep->d_name);
|
strcat(filename, ep->d_name);
|
||||||
|
|
||||||
/* use strncmp to filter out dotfiles */
|
/* use strncmp to filter out dotfiles */
|
||||||
if ((show_hidden && strncmp(filename, ".", 1) && strncmp(filename, "..", 2)) || (!show_hidden && strcmp(filename, ".") && strcmp(filename, ".."))) {
|
if ((!show_hidden && strncmp(filename, ".", 1) && strncmp(filename, "..", 2)) || (show_hidden && strcmp(filename, ".") && strcmp(filename, ".."))) {
|
||||||
/* construct full file path */
|
/* construct full file path */
|
||||||
filename[0] = '\0';
|
filename[0] = '\0';
|
||||||
strcat(filename, cwd);
|
strcat(filename, cwd);
|
||||||
|
|
Loading…
Reference in a new issue