summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-30 20:03:31 +0200
committerwm4 <wm4@nowhere>2014-08-30 20:03:31 +0200
commitc80adac07772f5b3c7a6c31e3e05480252f84171 (patch)
tree1622e2e678885b9171811bca506861688b0001b2 /stream
parent829fdef2193584ccf9b671747df9e4a806f82137 (diff)
downloadmpv-c80adac07772f5b3c7a6c31e3e05480252f84171.tar.bz2
mpv-c80adac07772f5b3c7a6c31e3e05480252f84171.tar.xz
cache_file: add a mode that creates a temporary file
Since we have to be portable, our options for creating temporary files are somewhat limited. tmpfile() happens to be available everywhere, so use that. This function doesn't allow having a "visible" filename or location, so we use the magic string "TMP" for this.
Diffstat (limited to 'stream')
-rw-r--r--stream/cache_file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stream/cache_file.c b/stream/cache_file.c
index af315b355a..7ecc0f9858 100644
--- a/stream/cache_file.c
+++ b/stream/cache_file.c
@@ -127,7 +127,8 @@ int stream_file_cache_init(stream_t *cache, stream_t *stream,
if (!opts->file || !opts->file[0] || opts->file_max < 1)
return 0;
- FILE *file = fopen(opts->file, "wb+");
+ bool use_anon_file = strcmp(opts->file, "TMP") == 0;
+ FILE *file = use_anon_file ? tmpfile() : fopen(opts->file, "wb+");
if (!file) {
MP_ERR(cache, "can't open cache file '%s'\n", opts->file);
return -1;