Created
August 15, 2017 02:45
-
-
Save annidy/29af88ec60d9ba218b99ff0333f51c2b to your computer and use it in GitHub Desktop.
patch for FFmpeg cache on iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libavutil/file_open.c b/libavutil/file_open.c | |
index 34070d933b..f96bdf11ac 100644 | |
--- a/libavutil/file_open.c | |
+++ b/libavutil/file_open.c | |
@@ -28,6 +28,9 @@ | |
#if HAVE_IO_H | |
#include <io.h> | |
#endif | |
+#if defined(__APPLE__) | |
+#include <CoreFoundation/CoreFoundation.h> | |
+#endif | |
#if defined(_WIN32) && !defined(__MINGW32CE__) | |
#undef open | |
@@ -116,6 +119,9 @@ int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *l | |
free(ptr); | |
#else | |
size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ | |
+#if defined(__APPLE__) | |
+ len = PATH_MAX; | |
+#endif | |
*filename = av_malloc(len); | |
#endif | |
/* -----common section-----*/ | |
@@ -140,6 +146,17 @@ int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *l | |
fd = mkstemp(*filename); | |
} | |
#endif | |
+#if defined(__APPLE__) | |
+ if (fd < 0) { | |
+ CFURLRef homeUrl = CFCopyHomeDirectoryURL(); | |
+ char homeStr[PATH_MAX]; | |
+ bzero(homeStr,PATH_MAX); | |
+ CFURLGetFileSystemRepresentation(homeUrl, false, homeStr, PATH_MAX); | |
+ | |
+ snprintf(*filename, len, "%s/Documents/%sXXXXXX", homeStr, prefix); | |
+ fd = mkstemp(*filename); | |
+ } | |
+#endif | |
#endif | |
/* -----common section-----*/ | |
if (fd < 0) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment