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 25 matching lines...) Expand all Loading... |
36 #include <stdlib.h> | 36 #include <stdlib.h> |
37 #include <string.h> | 37 #include <string.h> |
38 | 38 |
39 #include "webrtc/typedefs.h" // For architecture defines | 39 #include "webrtc/typedefs.h" // For architecture defines |
40 | 40 |
41 namespace webrtc { | 41 namespace webrtc { |
42 namespace test { | 42 namespace test { |
43 | 43 |
44 #if defined(WEBRTC_IOS) | 44 #if defined(WEBRTC_IOS) |
45 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. | 45 // Defined in iosfileutils.mm. No header file to discourage use elsewhere. |
| 46 std::string IOSOutputPath(); |
46 std::string IOSResourcePath(std::string name, std::string extension); | 47 std::string IOSResourcePath(std::string name, std::string extension); |
47 #endif | 48 #endif |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 #ifdef WIN32 | 52 #ifdef WIN32 |
52 const char* kPathDelimiter = "\\"; | 53 const char* kPathDelimiter = "\\"; |
53 #else | 54 #else |
54 const char* kPathDelimiter = "/"; | 55 const char* kPathDelimiter = "/"; |
55 #endif | 56 #endif |
56 | 57 |
57 #ifdef WEBRTC_ANDROID | 58 #ifdef WEBRTC_ANDROID |
58 const char* kRootDirName = "/sdcard/"; | 59 const char* kRootDirName = "/sdcard/"; |
59 #else | 60 #else |
60 // The file we're looking for to identify the project root dir. | 61 // The file we're looking for to identify the project root dir. |
61 const char* kProjectRootFileName = "DEPS"; | 62 const char* kProjectRootFileName = "DEPS"; |
| 63 #if !defined(WEBRTC_IOS) |
62 const char* kOutputDirName = "out"; | 64 const char* kOutputDirName = "out"; |
| 65 #endif |
63 const char* kFallbackPath = "./"; | 66 const char* kFallbackPath = "./"; |
64 #endif | 67 #endif // !defined(WEBRTC_ANDROID) |
| 68 |
65 #if !defined(WEBRTC_IOS) | 69 #if !defined(WEBRTC_IOS) |
66 const char* kResourcesDirName = "resources"; | 70 const char* kResourcesDirName = "resources"; |
67 #endif | 71 #endif |
68 | 72 |
69 char relative_dir_path[FILENAME_MAX]; | 73 char relative_dir_path[FILENAME_MAX]; |
70 bool relative_dir_path_set = false; | 74 bool relative_dir_path_set = false; |
71 | 75 |
72 } // namespace | 76 } // namespace |
73 | 77 |
74 const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR"; | 78 const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 140 } |
137 // Reached the root directory. | 141 // Reached the root directory. |
138 fprintf(stderr, "Cannot find project root directory!\n"); | 142 fprintf(stderr, "Cannot find project root directory!\n"); |
139 return kCannotFindProjectRootDir; | 143 return kCannotFindProjectRootDir; |
140 } | 144 } |
141 | 145 |
142 std::string OutputPath() { | 146 std::string OutputPath() { |
| 147 #if defined(WEBRTC_IOS) |
| 148 return IOSOutputPath(); |
| 149 #else |
143 std::string path = ProjectRootPath(); | 150 std::string path = ProjectRootPath(); |
144 if (path == kCannotFindProjectRootDir) { | 151 if (path == kCannotFindProjectRootDir) { |
145 return kFallbackPath; | 152 return kFallbackPath; |
146 } | 153 } |
147 path += kOutputDirName; | 154 path += kOutputDirName; |
148 if (!CreateDir(path)) { | 155 if (!CreateDir(path)) { |
149 return kFallbackPath; | 156 return kFallbackPath; |
150 } | 157 } |
151 return path + kPathDelimiter; | 158 return path + kPathDelimiter; |
| 159 #endif |
152 } | 160 } |
153 | 161 |
154 std::string WorkingDir() { | 162 std::string WorkingDir() { |
155 char path_buffer[FILENAME_MAX]; | 163 char path_buffer[FILENAME_MAX]; |
156 if (!GET_CURRENT_DIR(path_buffer, sizeof(path_buffer))) { | 164 if (!GET_CURRENT_DIR(path_buffer, sizeof(path_buffer))) { |
157 fprintf(stderr, "Cannot get current directory!\n"); | 165 fprintf(stderr, "Cannot get current directory!\n"); |
158 return kFallbackPath; | 166 return kFallbackPath; |
159 } else { | 167 } else { |
160 return std::string(path_buffer); | 168 return std::string(path_buffer); |
161 } | 169 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 if (fseek(f, 0, SEEK_END) == 0) { | 270 if (fseek(f, 0, SEEK_END) == 0) { |
263 size = ftell(f); | 271 size = ftell(f); |
264 } | 272 } |
265 fclose(f); | 273 fclose(f); |
266 } | 274 } |
267 return size; | 275 return size; |
268 } | 276 } |
269 | 277 |
270 } // namespace test | 278 } // namespace test |
271 } // namespace webrtc | 279 } // namespace webrtc |
OLD | NEW |