| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 ASSERT(IsFolder(folder)); | 165 ASSERT(IsFolder(folder)); |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 std::string no_slash(folder.pathname(), 0, folder.pathname().length()-1); | 168 std::string no_slash(folder.pathname(), 0, folder.pathname().length()-1); |
| 169 return ::rmdir(no_slash.c_str()) == 0; | 169 return ::rmdir(no_slash.c_str()) == 0; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create, | 172 bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create, |
| 173 const std::string *append) { | 173 const std::string *append) { |
| 174 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 174 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 175 #pragma clang diagnostic push |
| 176 #pragma clang diagnostic ignored "-Wdeprecated" |
| 175 FSRef fr; | 177 FSRef fr; |
| 176 if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, | 178 if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, |
| 177 kCreateFolder, &fr)) | 179 kCreateFolder, &fr)) |
| 178 return false; | 180 return false; |
| 179 unsigned char buffer[NAME_MAX+1]; | 181 unsigned char buffer[NAME_MAX+1]; |
| 180 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) | 182 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) |
| 181 return false; | 183 return false; |
| 182 pathname.SetPathname(reinterpret_cast<char*>(buffer), ""); | 184 pathname.SetPathname(reinterpret_cast<char*>(buffer), ""); |
| 185 #pragma clang diagnostic pop |
| 183 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 186 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 184 ASSERT(provided_app_temp_folder_ != NULL); | 187 ASSERT(provided_app_temp_folder_ != NULL); |
| 185 pathname.SetPathname(provided_app_temp_folder_, ""); | 188 pathname.SetPathname(provided_app_temp_folder_, ""); |
| 186 #else // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID | 189 #else // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID |
| 187 if (const char* tmpdir = getenv("TMPDIR")) { | 190 if (const char* tmpdir = getenv("TMPDIR")) { |
| 188 pathname.SetPathname(tmpdir, ""); | 191 pathname.SetPathname(tmpdir, ""); |
| 189 } else if (const char* tmp = getenv("TMP")) { | 192 } else if (const char* tmp = getenv("TMP")) { |
| 190 pathname.SetPathname(tmp, ""); | 193 pathname.SetPathname(tmp, ""); |
| 191 } else { | 194 } else { |
| 192 #ifdef P_tmpdir | 195 #ifdef P_tmpdir |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 break; | 355 break; |
| 353 default: | 356 default: |
| 354 return false; | 357 return false; |
| 355 } | 358 } |
| 356 return true; | 359 return true; |
| 357 } | 360 } |
| 358 | 361 |
| 359 bool UnixFilesystem::GetAppPathname(Pathname* path) { | 362 bool UnixFilesystem::GetAppPathname(Pathname* path) { |
| 360 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 363 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 361 ProcessSerialNumber psn = { 0, kCurrentProcess }; | 364 ProcessSerialNumber psn = { 0, kCurrentProcess }; |
| 365 #pragma clang diagnostic push |
| 366 #pragma clang diagnostic ignored "-Wdeprecated" |
| 362 CFDictionaryRef procinfo = ProcessInformationCopyDictionary(&psn, | 367 CFDictionaryRef procinfo = ProcessInformationCopyDictionary(&psn, |
| 363 kProcessDictionaryIncludeAllInformationMask); | 368 kProcessDictionaryIncludeAllInformationMask); |
| 369 #pragma clang diagnostic pop |
| 364 if (NULL == procinfo) | 370 if (NULL == procinfo) |
| 365 return false; | 371 return false; |
| 366 CFStringRef cfpath = (CFStringRef) CFDictionaryGetValue(procinfo, | 372 CFStringRef cfpath = (CFStringRef) CFDictionaryGetValue(procinfo, |
| 367 kIOBundleExecutableKey); | 373 kIOBundleExecutableKey); |
| 368 std::string path8; | 374 std::string path8; |
| 369 bool success = ToUtf8(cfpath, &path8); | 375 bool success = ToUtf8(cfpath, &path8); |
| 370 CFRelease(procinfo); | 376 CFRelease(procinfo); |
| 371 if (success) | 377 if (success) |
| 372 path->SetPathname(path8); | 378 path->SetPathname(path8); |
| 373 return success; | 379 return success; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 387 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) | 393 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) |
| 388 } | 394 } |
| 389 | 395 |
| 390 bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) { | 396 bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) { |
| 391 ASSERT(!organization_name_.empty()); | 397 ASSERT(!organization_name_.empty()); |
| 392 ASSERT(!application_name_.empty()); | 398 ASSERT(!application_name_.empty()); |
| 393 | 399 |
| 394 // First get the base directory for app data. | 400 // First get the base directory for app data. |
| 395 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 401 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 396 if (per_user) { | 402 if (per_user) { |
| 403 #pragma clang diagnostic push |
| 404 #pragma clang diagnostic ignored "-Wdeprecated" |
| 397 // Use ~/Library/Application Support/<orgname>/<appname>/ | 405 // Use ~/Library/Application Support/<orgname>/<appname>/ |
| 398 FSRef fr; | 406 FSRef fr; |
| 399 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType, | 407 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType, |
| 400 kCreateFolder, &fr)) | 408 kCreateFolder, &fr)) |
| 401 return false; | 409 return false; |
| 402 unsigned char buffer[NAME_MAX+1]; | 410 unsigned char buffer[NAME_MAX+1]; |
| 403 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) | 411 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) |
| 404 return false; | 412 return false; |
| 405 path->SetPathname(reinterpret_cast<char*>(buffer), ""); | 413 path->SetPathname(reinterpret_cast<char*>(buffer), ""); |
| 414 #pragma clang diagnostic pop |
| 406 } else { | 415 } else { |
| 407 // TODO | 416 // TODO |
| 408 return false; | 417 return false; |
| 409 } | 418 } |
| 410 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) // && !WEBRTC_MAC || WEBRT
C_IOS | 419 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) // && !WEBRTC_MAC || WEBRT
C_IOS |
| 411 ASSERT(provided_app_data_folder_ != NULL); | 420 ASSERT(provided_app_data_folder_ != NULL); |
| 412 path->SetPathname(provided_app_data_folder_, ""); | 421 path->SetPathname(provided_app_data_folder_, ""); |
| 413 #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) // && !WEBRTC_MAC && !W
EBRTC_IOS && !WEBRTC_ANDROID | 422 #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) // && !WEBRTC_MAC && !W
EBRTC_IOS && !WEBRTC_ANDROID |
| 414 if (per_user) { | 423 if (per_user) { |
| 415 // We follow the recommendations in | 424 // We follow the recommendations in |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 574 |
| 566 } // namespace rtc | 575 } // namespace rtc |
| 567 | 576 |
| 568 #if defined(__native_client__) | 577 #if defined(__native_client__) |
| 569 extern "C" int __attribute__((weak)) | 578 extern "C" int __attribute__((weak)) |
| 570 link(const char* oldpath, const char* newpath) { | 579 link(const char* oldpath, const char* newpath) { |
| 571 errno = EACCES; | 580 errno = EACCES; |
| 572 return -1; | 581 return -1; |
| 573 } | 582 } |
| 574 #endif | 583 #endif |
| OLD | NEW |