Skip to content

Instantly share code, notes, and snippets.

@annidy annidy/patch.diff
Created Aug 15, 2017

Embed
What would you like to do?
patch for FFmpeg cache on iOS
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
You can’t perform that action at this time.