From ec859e84036e5a932a03cda59ddbe1281a2d6c4e Mon Sep 17 00:00:00 2001 From: night0721 Date: Sun, 17 Nov 2024 19:04:15 +0000 Subject: [PATCH] View file/dir attribute --- ccc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ccc.c b/ccc.c index c8a9d29..2cf3424 100644 --- a/ccc.c +++ b/ccc.c @@ -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 */