| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 22 matching lines...) Expand all Loading... |
| 33 #ifndef S_ISDIR // Not defined in stat.h on Windows. | 33 #ifndef S_ISDIR // Not defined in stat.h on Windows. |
| 34 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) | 34 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #include <stdio.h> | 37 #include <stdio.h> |
| 38 #include <stdlib.h> | 38 #include <stdlib.h> |
| 39 #include <string.h> | 39 #include <string.h> |
| 40 | 40 |
| 41 #include <memory> | 41 #include <memory> |
| 42 | 42 |
| 43 #include "webrtc/base/checks.h" |
| 43 #include "webrtc/typedefs.h" // For architecture defines | 44 #include "webrtc/typedefs.h" // For architecture defines |
| 44 | 45 |
| 45 namespace webrtc { | 46 namespace webrtc { |
| 46 namespace test { | 47 namespace test { |
| 47 | 48 |
| 48 #if defined(WEBRTC_IOS) | 49 #if defined(WEBRTC_IOS) |
| 49 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. | 50 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. |
| 50 std::string IOSOutputPath(); | 51 std::string IOSOutputPath(); |
| 51 std::string IOSRootPath(); | 52 std::string IOSRootPath(); |
| 52 std::string IOSResourcePath(std::string name, std::string extension); | 53 std::string IOSResourcePath(std::string name, std::string extension); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 120 } |
| 120 | 121 |
| 121 std::string OutputPath() { | 122 std::string OutputPath() { |
| 122 return kRootDirName; | 123 return kRootDirName; |
| 123 } | 124 } |
| 124 | 125 |
| 125 std::string WorkingDir() { | 126 std::string WorkingDir() { |
| 126 return kRootDirName; | 127 return kRootDirName; |
| 127 } | 128 } |
| 128 | 129 |
| 129 #else // WEBRTC_ANDROID | 130 #else // WEBRTC_ANDROID |
| 130 | 131 |
| 131 std::string ProjectRootPath() { | 132 std::string ProjectRootPath() { |
| 132 #if defined(WEBRTC_IOS) | 133 #if defined(WEBRTC_IOS) |
| 133 return IOSRootPath(); | 134 return IOSRootPath(); |
| 134 #else | 135 #else |
| 135 std::string path = WorkingDir(); | 136 std::string path = WorkingDir(); |
| 136 if (path == kFallbackPath) { | 137 if (path == kFallbackPath) { |
| 137 return kCannotFindProjectRootDir; | 138 return kCannotFindProjectRootDir; |
| 138 } | 139 } |
| 139 if (relative_dir_path_set) { | 140 if (relative_dir_path_set) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } else { | 226 } else { |
| 226 #ifdef WIN32 | 227 #ifdef WIN32 |
| 227 return _mkdir(directory_name.c_str()) == 0; | 228 return _mkdir(directory_name.c_str()) == 0; |
| 228 #else | 229 #else |
| 229 return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; | 230 return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; |
| 230 #endif | 231 #endif |
| 231 } | 232 } |
| 232 return true; | 233 return true; |
| 233 } | 234 } |
| 234 | 235 |
| 236 size_t RemoveDirRecursively(const rtc::Pathname& dir) { |
| 237 if (!DirExists(dir.pathname())) { return false; } |
| 238 rtc::DirectoryIterator it; |
| 239 it.Iterate(dir); |
| 240 size_t deleted_entries = 0; |
| 241 do { |
| 242 const std::string entry_name = it.Name(); |
| 243 if (entry_name == "." || entry_name == "..") { continue; } |
| 244 |
| 245 const rtc::Pathname entry = it.Path(); |
| 246 if (it.IsDirectory()) { |
| 247 deleted_entries += RemoveDirRecursively(entry); |
| 248 } else { |
| 249 if (RemoveFile(entry.pathname())) { deleted_entries++; } |
| 250 } |
| 251 } while (it.Next()); |
| 252 RemoveDir(dir.pathname()); |
| 253 return deleted_entries + 1; |
| 254 } |
| 255 |
| 235 bool RemoveDir(const std::string& directory_name) { | 256 bool RemoveDir(const std::string& directory_name) { |
| 236 #ifdef WIN32 | 257 #ifdef WIN32 |
| 237 return RemoveDirectoryA(directory_name.c_str()) != FALSE; | 258 return RemoveDirectoryA(directory_name.c_str()) != FALSE; |
| 238 #else | 259 #else |
| 239 return rmdir(directory_name.c_str()) == 0; | 260 return rmdir(directory_name.c_str()) == 0; |
| 240 #endif | 261 #endif |
| 241 } | 262 } |
| 242 | 263 |
| 243 bool RemoveFile(const std::string& file_name) { | 264 bool RemoveFile(const std::string& file_name) { |
| 244 #ifdef WIN32 | 265 #ifdef WIN32 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (fseek(f, 0, SEEK_END) == 0) { | 321 if (fseek(f, 0, SEEK_END) == 0) { |
| 301 size = ftell(f); | 322 size = ftell(f); |
| 302 } | 323 } |
| 303 fclose(f); | 324 fclose(f); |
| 304 } | 325 } |
| 305 return size; | 326 return size; |
| 306 } | 327 } |
| 307 | 328 |
| 308 } // namespace test | 329 } // namespace test |
| 309 } // namespace webrtc | 330 } // namespace webrtc |
| OLD | NEW |