View file/dir attribute

This commit is contained in:
Night Kaly 2024-11-17 19:04:15 +00:00
parent f413e0216e
commit ec859e8403
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM

23
ccc.c
View file

@ -70,6 +70,7 @@ void create_file(void);
void delete_files(void);
void start_shell(void);
void yank_clipboard(void);
void view_file_attr(void);
void wpprintw(const char *fmt, ...);
void move_cursor(int row, int col);
int readch(void);
@ -367,6 +368,9 @@ int main(int argc, char **argv)
case 'o':
case 'O':
case 'x':
view_file_attr();
break;
/* mark one file */
case SPACE:
@ -1269,6 +1273,25 @@ void yank_clipboard(void)
}
}
void view_file_attr(void)
{
bprintf("\033[2J");
move_cursor(1, 1);
pid_t pid = fork();
if (pid == 0) {
/* Child process */
execlp("stat", "stat", files->items[sel_file].name, NULL);
_exit(1); /* Exit if exec fails */
} else if (pid > 0) {
/* Parent process */
waitpid(pid, NULL, 0);
} else {
/* Fork failed */
wpprintw("fork failed: %s", strerror(errno));
}
readch();
}
/*
* Print line to the panel
*/