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 // TODO(hjon): Update deprecated APIs (see webrtc:5478 for details). |
| 176 #pragma clang diagnostic push |
| 177 #pragma clang diagnostic ignored "-Wdeprecated" |
175 FSRef fr; | 178 FSRef fr; |
176 if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, | 179 if (0 != FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, |
177 kCreateFolder, &fr)) | 180 kCreateFolder, &fr)) |
178 return false; | 181 return false; |
179 unsigned char buffer[NAME_MAX+1]; | 182 unsigned char buffer[NAME_MAX+1]; |
180 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) | 183 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) |
181 return false; | 184 return false; |
182 pathname.SetPathname(reinterpret_cast<char*>(buffer), ""); | 185 pathname.SetPathname(reinterpret_cast<char*>(buffer), ""); |
| 186 #pragma clang diagnostic pop |
183 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 187 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
184 ASSERT(provided_app_temp_folder_ != NULL); | 188 ASSERT(provided_app_temp_folder_ != NULL); |
185 pathname.SetPathname(provided_app_temp_folder_, ""); | 189 pathname.SetPathname(provided_app_temp_folder_, ""); |
186 #else // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID | 190 #else // !WEBRTC_MAC || WEBRTC_IOS && !WEBRTC_ANDROID |
187 if (const char* tmpdir = getenv("TMPDIR")) { | 191 if (const char* tmpdir = getenv("TMPDIR")) { |
188 pathname.SetPathname(tmpdir, ""); | 192 pathname.SetPathname(tmpdir, ""); |
189 } else if (const char* tmp = getenv("TMP")) { | 193 } else if (const char* tmp = getenv("TMP")) { |
190 pathname.SetPathname(tmp, ""); | 194 pathname.SetPathname(tmp, ""); |
191 } else { | 195 } else { |
192 #ifdef P_tmpdir | 196 #ifdef P_tmpdir |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 break; | 356 break; |
353 default: | 357 default: |
354 return false; | 358 return false; |
355 } | 359 } |
356 return true; | 360 return true; |
357 } | 361 } |
358 | 362 |
359 bool UnixFilesystem::GetAppPathname(Pathname* path) { | 363 bool UnixFilesystem::GetAppPathname(Pathname* path) { |
360 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 364 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
361 ProcessSerialNumber psn = { 0, kCurrentProcess }; | 365 ProcessSerialNumber psn = { 0, kCurrentProcess }; |
| 366 // TODO(hjon): Update deprecated APIs (see webrtc:5478 for details). |
| 367 #pragma clang diagnostic push |
| 368 #pragma clang diagnostic ignored "-Wdeprecated" |
362 CFDictionaryRef procinfo = ProcessInformationCopyDictionary(&psn, | 369 CFDictionaryRef procinfo = ProcessInformationCopyDictionary(&psn, |
363 kProcessDictionaryIncludeAllInformationMask); | 370 kProcessDictionaryIncludeAllInformationMask); |
| 371 #pragma clang diagnostic pop |
364 if (NULL == procinfo) | 372 if (NULL == procinfo) |
365 return false; | 373 return false; |
366 CFStringRef cfpath = (CFStringRef) CFDictionaryGetValue(procinfo, | 374 CFStringRef cfpath = (CFStringRef) CFDictionaryGetValue(procinfo, |
367 kIOBundleExecutableKey); | 375 kIOBundleExecutableKey); |
368 std::string path8; | 376 std::string path8; |
369 bool success = ToUtf8(cfpath, &path8); | 377 bool success = ToUtf8(cfpath, &path8); |
370 CFRelease(procinfo); | 378 CFRelease(procinfo); |
371 if (success) | 379 if (success) |
372 path->SetPathname(path8); | 380 path->SetPathname(path8); |
373 return success; | 381 return success; |
(...skipping 13 matching lines...) Expand all Loading... |
387 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) | 395 #endif // WEBRTC_MAC && !defined(WEBRTC_IOS) |
388 } | 396 } |
389 | 397 |
390 bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) { | 398 bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) { |
391 ASSERT(!organization_name_.empty()); | 399 ASSERT(!organization_name_.empty()); |
392 ASSERT(!application_name_.empty()); | 400 ASSERT(!application_name_.empty()); |
393 | 401 |
394 // First get the base directory for app data. | 402 // First get the base directory for app data. |
395 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | 403 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
396 if (per_user) { | 404 if (per_user) { |
| 405 // TODO(hjon): Update deprecated APIs (see webrtc:5478 for details). |
| 406 #pragma clang diagnostic push |
| 407 #pragma clang diagnostic ignored "-Wdeprecated" |
397 // Use ~/Library/Application Support/<orgname>/<appname>/ | 408 // Use ~/Library/Application Support/<orgname>/<appname>/ |
398 FSRef fr; | 409 FSRef fr; |
399 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType, | 410 if (0 != FSFindFolder(kUserDomain, kApplicationSupportFolderType, |
400 kCreateFolder, &fr)) | 411 kCreateFolder, &fr)) |
401 return false; | 412 return false; |
402 unsigned char buffer[NAME_MAX+1]; | 413 unsigned char buffer[NAME_MAX+1]; |
403 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) | 414 if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer))) |
404 return false; | 415 return false; |
405 path->SetPathname(reinterpret_cast<char*>(buffer), ""); | 416 path->SetPathname(reinterpret_cast<char*>(buffer), ""); |
| 417 #pragma clang diagnostic pop |
406 } else { | 418 } else { |
407 // TODO | 419 // TODO |
408 return false; | 420 return false; |
409 } | 421 } |
410 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) // && !WEBRTC_MAC || WEBRT
C_IOS | 422 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) // && !WEBRTC_MAC || WEBRT
C_IOS |
411 ASSERT(provided_app_data_folder_ != NULL); | 423 ASSERT(provided_app_data_folder_ != NULL); |
412 path->SetPathname(provided_app_data_folder_, ""); | 424 path->SetPathname(provided_app_data_folder_, ""); |
413 #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) // && !WEBRTC_MAC && !W
EBRTC_IOS && !WEBRTC_ANDROID | 425 #elif defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) // && !WEBRTC_MAC && !W
EBRTC_IOS && !WEBRTC_ANDROID |
414 if (per_user) { | 426 if (per_user) { |
415 // We follow the recommendations in | 427 // We follow the recommendations in |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 577 |
566 } // namespace rtc | 578 } // namespace rtc |
567 | 579 |
568 #if defined(__native_client__) | 580 #if defined(__native_client__) |
569 extern "C" int __attribute__((weak)) | 581 extern "C" int __attribute__((weak)) |
570 link(const char* oldpath, const char* newpath) { | 582 link(const char* oldpath, const char* newpath) { |
571 errno = EACCES; | 583 errno = EACCES; |
572 return -1; | 584 return -1; |
573 } | 585 } |
574 #endif | 586 #endif |
OLD | NEW |