summaryrefslogtreecommitdiff
path: root/src/filelist.c
diff options
context:
space:
mode:
authorDennis Real <github@tildepipe.org>2013-02-14 17:02:16 +0100
committerDennis Real <github@tildepipe.org>2013-02-14 17:02:16 +0100
commit08faff479023efff6380061d81362073f679cd34 (patch)
treea462195afe9a6e2e2249f070c12ff6d1ff60d65c /src/filelist.c
parent353578ebc130f53547996ab87f5b3795c1360f3f (diff)
parent43a7d315ae6952e096ae3a0351273c5639377870 (diff)
Merge branch 'master' of git://github.com/derf/feh
Diffstat (limited to 'src/filelist.c')
-rw-r--r--src/filelist.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/filelist.c b/src/filelist.c
index 3ea0928..bbde98c 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -155,6 +155,41 @@ static void feh_print_stat_error(char *path)
}
}
+static void add_stdin_to_filelist()
+{
+ char buf[1024];
+ size_t readsize;
+ char *sfn = estrjoin("_", "/tmp/feh_stdin", "XXXXXX", NULL);
+ int fd = mkstemp(sfn);
+ FILE *outfile;
+
+ if (fd == -1) {
+ free(sfn);
+ weprintf("cannot read from stdin: mktemp:");
+ return;
+ }
+
+ outfile = fdopen(fd, "w");
+
+ if (outfile == NULL) {
+ free(sfn);
+ weprintf("cannot read from stdin: fdopen:");
+ return;
+ }
+
+ while ((readsize = fread(buf, sizeof(char), sizeof(buf), stdin)) > 0) {
+ if (fwrite(buf, sizeof(char), readsize, outfile) < readsize) {
+ free(sfn);
+ return;
+ }
+ }
+ fclose(outfile);
+
+ filelist = gib_list_add_front(filelist, feh_file_new(sfn));
+ add_file_to_rm_filelist(sfn);
+ free(sfn);
+}
+
/* Recursive */
void add_file_to_filelist_recursively(char *origpath, unsigned char level)
@@ -186,8 +221,8 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)
free(path);
return;
} else if ((len == 1) && (path[0] == '-')) {
- D(("Addig stdin (-) to filelist\n"));
- filelist = gib_list_add_front(filelist, feh_file_new(path));
+ D(("Adding temporary file for stdin (-) to filelist\n"));
+ add_stdin_to_filelist();
free(path);
return;
} else if (opt.filelistfile) {