| 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 27 matching lines...) Expand all Loading... |
| 38 #include <memory> | 38 #include <memory> |
| 39 | 39 |
| 40 #include "webrtc/typedefs.h" // For architecture defines | 40 #include "webrtc/typedefs.h" // For architecture defines |
| 41 | 41 |
| 42 namespace webrtc { | 42 namespace webrtc { |
| 43 namespace test { | 43 namespace test { |
| 44 | 44 |
| 45 #if defined(WEBRTC_IOS) | 45 #if defined(WEBRTC_IOS) |
| 46 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. | 46 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. |
| 47 std::string IOSOutputPath(); | 47 std::string IOSOutputPath(); |
| 48 std::string IOSRootPath(); |
| 48 std::string IOSResourcePath(std::string name, std::string extension); | 49 std::string IOSResourcePath(std::string name, std::string extension); |
| 49 #endif | 50 #endif |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 #ifdef WIN32 | 54 #ifdef WIN32 |
| 54 const char* kPathDelimiter = "\\"; | 55 const char* kPathDelimiter = "\\"; |
| 55 #else | 56 #else |
| 56 const char* kPathDelimiter = "/"; | 57 const char* kPathDelimiter = "/"; |
| 57 #endif | 58 #endif |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return kRootDirName; | 113 return kRootDirName; |
| 113 } | 114 } |
| 114 | 115 |
| 115 std::string WorkingDir() { | 116 std::string WorkingDir() { |
| 116 return kRootDirName; | 117 return kRootDirName; |
| 117 } | 118 } |
| 118 | 119 |
| 119 #else // WEBRTC_ANDROID | 120 #else // WEBRTC_ANDROID |
| 120 | 121 |
| 121 std::string ProjectRootPath() { | 122 std::string ProjectRootPath() { |
| 123 #if defined(WEBRTC_IOS) |
| 124 return IOSRootPath(); |
| 125 #else |
| 122 std::string path = WorkingDir(); | 126 std::string path = WorkingDir(); |
| 123 if (path == kFallbackPath) { | 127 if (path == kFallbackPath) { |
| 124 return kCannotFindProjectRootDir; | 128 return kCannotFindProjectRootDir; |
| 125 } | 129 } |
| 126 if (relative_dir_path_set && strcmp(relative_dir_path, ".") != 0) { | 130 if (relative_dir_path_set && strcmp(relative_dir_path, ".") != 0) { |
| 127 path = path + kPathDelimiter + relative_dir_path; | 131 path = path + kPathDelimiter + relative_dir_path; |
| 128 } | 132 } |
| 129 // Remove two directory levels from the path, i.e. a path like | 133 // Remove two directory levels from the path, i.e. a path like |
| 130 // /absolute/path/src/out/Debug will become /absolute/path/src/ | 134 // /absolute/path/src/out/Debug will become /absolute/path/src/ |
| 131 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); | 135 size_t path_delimiter_index = path.find_last_of(kPathDelimiter); |
| 132 if (path_delimiter_index != std::string::npos) { | 136 if (path_delimiter_index != std::string::npos) { |
| 133 // Move up one directory in the directory tree. | 137 // Move up one directory in the directory tree. |
| 134 path = path.substr(0, path_delimiter_index); | 138 path = path.substr(0, path_delimiter_index); |
| 135 path_delimiter_index = path.find_last_of(kPathDelimiter); | 139 path_delimiter_index = path.find_last_of(kPathDelimiter); |
| 136 if (path_delimiter_index != std::string::npos) { | 140 if (path_delimiter_index != std::string::npos) { |
| 137 // Move up another directory in the directory tree. We should now be at | 141 // Move up another directory in the directory tree. We should now be at |
| 138 // the project root. | 142 // the project root. |
| 139 return path.substr(0, path_delimiter_index) + kPathDelimiter; | 143 return path.substr(0, path_delimiter_index) + kPathDelimiter; |
| 140 } | 144 } |
| 141 } | 145 } |
| 142 fprintf(stderr, "Cannot find project root directory!\n"); | 146 fprintf(stderr, "Cannot find project root directory!\n"); |
| 143 return kCannotFindProjectRootDir; | 147 return kCannotFindProjectRootDir; |
| 148 #endif |
| 144 } | 149 } |
| 145 | 150 |
| 146 std::string OutputPath() { | 151 std::string OutputPath() { |
| 147 #if defined(WEBRTC_IOS) | 152 #if defined(WEBRTC_IOS) |
| 148 return IOSOutputPath(); | 153 return IOSOutputPath(); |
| 149 #else | 154 #else |
| 150 std::string path = ProjectRootPath(); | 155 std::string path = ProjectRootPath(); |
| 151 if (path == kCannotFindProjectRootDir) { | 156 if (path == kCannotFindProjectRootDir) { |
| 152 return kFallbackPath; | 157 return kFallbackPath; |
| 153 } | 158 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (fseek(f, 0, SEEK_END) == 0) { | 275 if (fseek(f, 0, SEEK_END) == 0) { |
| 271 size = ftell(f); | 276 size = ftell(f); |
| 272 } | 277 } |
| 273 fclose(f); | 278 fclose(f); |
| 274 } | 279 } |
| 275 return size; | 280 return size; |
| 276 } | 281 } |
| 277 | 282 |
| 278 } // namespace test | 283 } // namespace test |
| 279 } // namespace webrtc | 284 } // namespace webrtc |
| OLD | NEW |