| Index: webrtc/base/unixfilesystem.cc
|
| diff --git a/webrtc/base/unixfilesystem.cc b/webrtc/base/unixfilesystem.cc
|
| index b7a720ecf1bed1715dad40c6fc63016f215999a9..b4743241925e166fd92db83371203259d06aa12b 100644
|
| --- a/webrtc/base/unixfilesystem.cc
|
| +++ b/webrtc/base/unixfilesystem.cc
|
| @@ -17,7 +17,7 @@
|
| #include <unistd.h>
|
|
|
| #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
| -#include <CoreFoundation/CoreFoundation.h>
|
| +#include <Carbon/Carbon.h>
|
| #include <IOKit/IOCFBundle.h>
|
| #include <sys/statvfs.h>
|
| #include "webrtc/base/macutils.h"
|
| @@ -50,13 +50,13 @@
|
| #include "webrtc/base/stream.h"
|
| #include "webrtc/base/stringutils.h"
|
|
|
| -#if defined(WEBRTC_MAC)
|
| -// Defined in applefilesystem.mm. No header file to discourage use
|
| +#if defined(WEBRTC_IOS)
|
| +// Defined in iosfilesystem.mm. No header file to discourage use
|
| // elsewhere; other places should use GetApp{Data,Temp}Folder() in
|
| // this file. Don't copy/paste. I mean it.
|
| -char* AppleDataDirectory();
|
| -char* AppleTempDirectory();
|
| -void AppleAppName(rtc::Pathname* path);
|
| +char* IOSDataDirectory();
|
| +char* IOSTempDirectory();
|
| +void IOSAppName(rtc::Pathname* path);
|
| #endif
|
|
|
| namespace rtc {
|
| @@ -81,9 +81,9 @@
|
| UnixFilesystem::UnixFilesystem() {
|
| #if defined(WEBRTC_IOS)
|
| if (!provided_app_data_folder_)
|
| - provided_app_data_folder_ = AppleDataDirectory();
|
| + provided_app_data_folder_ = IOSDataDirectory();
|
| if (!provided_app_temp_folder_)
|
| - provided_app_temp_folder_ = AppleTempDirectory();
|
| + provided_app_temp_folder_ = IOSTempDirectory();
|
| #endif
|
| }
|
|
|
| @@ -171,10 +171,19 @@
|
|
|
| bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create,
|
| const std::string *append) {
|
| -#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
| +#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
| + FSRef fr;
|
| + if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType,
|
| + kCreateFolder, &fr))
|
| + return false;
|
| + unsigned char buffer[NAME_MAX+1];
|
| + if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
|
| + return false;
|
| + pathname.SetPathname(reinterpret_cast<char*>(buffer), "");
|
| +#elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
| ASSERT(provided_app_temp_folder_ != NULL);
|
| pathname.SetPathname(provided_app_temp_folder_, "");
|
| -#else
|
| +#else // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID
|
| if (const char* tmpdir = getenv("TMPDIR")) {
|
| pathname.SetPathname(tmpdir, "");
|
| } else if (const char* tmp = getenv("TMP")) {
|
| @@ -186,7 +195,7 @@
|
| pathname.SetPathname("/tmp/", "");
|
| #endif // !P_tmpdir
|
| }
|
| -#endif // defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
| +#endif // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID
|
| if (append) {
|
| ASSERT(!append->empty());
|
| pathname.AppendFolder(*append);
|
| @@ -348,10 +357,24 @@
|
| }
|
|
|
| bool UnixFilesystem::GetAppPathname(Pathname* path) {
|
| -#if defined(__native_client__)
|
| +#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
| + ProcessSerialNumber psn = { 0, kCurrentProcess };
|
| + CFDictionaryRef procinfo = ProcessInformationCopyDictionary(&psn,
|
| + kProcessDictionaryIncludeAllInformationMask);
|
| + if (NULL == procinfo)
|
| + return false;
|
| + CFStringRef cfpath = (CFStringRef) CFDictionaryGetValue(procinfo,
|
| + kIOBundleExecutableKey);
|
| + std::string path8;
|
| + bool success = ToUtf8(cfpath, &path8);
|
| + CFRelease(procinfo);
|
| + if (success)
|
| + path->SetPathname(path8);
|
| + return success;
|
| +#elif defined(__native_client__)
|
| return false;
|
| -#elif defined(WEBRTC_MAC)
|
| - AppleAppName(path);
|
| +#elif WEBRTC_IOS
|
| + IOSAppName(path);
|
| return true;
|
| #else // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
| char buffer[PATH_MAX + 2];
|
|
|