Make all files previewable
This commit is contained in:
parent
12205feacd
commit
3cad97a7d4
1 changed files with 6 additions and 9 deletions
15
ccc.c
15
ccc.c
|
@ -847,12 +847,7 @@ void show_file_content()
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
/* Child */
|
/* Child */
|
||||||
/*
|
|
||||||
close(pipe_fd[0]);
|
|
||||||
dup2(pipe_fd[1], STDOUT_FILENO);
|
|
||||||
dup2(pipe_fd[1], STDERR_FILENO);
|
|
||||||
close(pipe_fd[1]);
|
|
||||||
*/
|
|
||||||
move_cursor(1, half_width);
|
move_cursor(1, half_width);
|
||||||
if (strstr(current_file.name, ".jpg") || strstr(current_file.name, ".png")) {
|
if (strstr(current_file.name, ".jpg") || strstr(current_file.name, ".png")) {
|
||||||
sixel_encoder_t *encoder = NULL;
|
sixel_encoder_t *encoder = NULL;
|
||||||
|
@ -864,15 +859,17 @@ void show_file_content()
|
||||||
sixel_encoder_encode(encoder, current_file.name);
|
sixel_encoder_encode(encoder, current_file.name);
|
||||||
sixel_encoder_unref(encoder);
|
sixel_encoder_unref(encoder);
|
||||||
} else {
|
} else {
|
||||||
|
close(pipe_fd[0]);
|
||||||
|
dup2(pipe_fd[1], STDOUT_FILENO);
|
||||||
|
dup2(pipe_fd[1], STDERR_FILENO);
|
||||||
|
close(pipe_fd[1]);
|
||||||
execlp("nsh", "nsh", current_file.name, NULL);
|
execlp("nsh", "nsh", current_file.name, NULL);
|
||||||
}
|
}
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
/* Parent */
|
/* Parent */
|
||||||
/*
|
|
||||||
close(pipe_fd[1]);
|
|
||||||
*/
|
|
||||||
if (strstr(current_file.name, ".jpg") == NULL && strstr(current_file.name, ".png") == NULL) {
|
if (strstr(current_file.name, ".jpg") == NULL && strstr(current_file.name, ".png") == NULL) {
|
||||||
|
close(pipe_fd[1]);
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int row = 1;
|
int row = 1;
|
||||||
FILE *stream = fdopen(pipe_fd[0], "r");
|
FILE *stream = fdopen(pipe_fd[0], "r");
|
||||||
|
|
Loading…
Reference in a new issue