Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: webrtc/test/testsupport/fileutils.cc

Issue 1178843002: Adds support for webrtc::test::ResourcePath on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nits Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/test.gyp ('k') | webrtc/test/testsupport/iosfileutils.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 34
35 #include <stdio.h> 35 #include <stdio.h>
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)
45 // Defined in iosfileutils.mm. No header file to discourage use elsewhere.
46 std::string IOSResourcePath(std::string name, std::string extension);
47 #endif
48
44 namespace { 49 namespace {
45 50
46 #ifdef WIN32 51 #ifdef WIN32
47 const char* kPathDelimiter = "\\"; 52 const char* kPathDelimiter = "\\";
48 #else 53 #else
49 const char* kPathDelimiter = "/"; 54 const char* kPathDelimiter = "/";
50 #endif 55 #endif
51 56
52 #ifdef WEBRTC_ANDROID 57 #ifdef WEBRTC_ANDROID
53 const char* kRootDirName = "/sdcard/"; 58 const char* kRootDirName = "/sdcard/";
54 #else 59 #else
55 // The file we're looking for to identify the project root dir. 60 // The file we're looking for to identify the project root dir.
56 const char* kProjectRootFileName = "DEPS"; 61 const char* kProjectRootFileName = "DEPS";
57 const char* kOutputDirName = "out"; 62 const char* kOutputDirName = "out";
58 const char* kFallbackPath = "./"; 63 const char* kFallbackPath = "./";
59 #endif 64 #endif
65 #if !defined(WEBRTC_IOS)
60 const char* kResourcesDirName = "resources"; 66 const char* kResourcesDirName = "resources";
67 #endif
61 68
62 char relative_dir_path[FILENAME_MAX]; 69 char relative_dir_path[FILENAME_MAX];
63 bool relative_dir_path_set = false; 70 bool relative_dir_path_set = false;
64 71
65 } // namespace 72 } // namespace
66 73
67 const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR"; 74 const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
68 75
69 void SetExecutablePath(const std::string& path) { 76 void SetExecutablePath(const std::string& path) {
70 std::string working_dir = WorkingDir(); 77 std::string working_dir = WorkingDir();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 #ifdef WIN32 205 #ifdef WIN32
199 return _mkdir(directory_name.c_str()) == 0; 206 return _mkdir(directory_name.c_str()) == 0;
200 #else 207 #else
201 return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0; 208 return mkdir(directory_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0;
202 #endif 209 #endif
203 } 210 }
204 return true; 211 return true;
205 } 212 }
206 213
207 std::string ResourcePath(std::string name, std::string extension) { 214 std::string ResourcePath(std::string name, std::string extension) {
215 #if defined(WEBRTC_IOS)
216 return IOSResourcePath(name, extension);
217 #else
208 std::string platform = "win"; 218 std::string platform = "win";
209 #ifdef WEBRTC_LINUX 219 #ifdef WEBRTC_LINUX
210 platform = "linux"; 220 platform = "linux";
211 #endif // WEBRTC_LINUX 221 #endif // WEBRTC_LINUX
212 #ifdef WEBRTC_MAC 222 #ifdef WEBRTC_MAC
213 platform = "mac"; 223 platform = "mac";
214 #endif // WEBRTC_MAC 224 #endif // WEBRTC_MAC
215 225
216 #ifdef WEBRTC_ARCH_64_BITS 226 #ifdef WEBRTC_ARCH_64_BITS
217 std::string architecture = "64"; 227 std::string architecture = "64";
(...skipping 14 matching lines...) Expand all
232 return resource_file; 242 return resource_file;
233 } 243 }
234 // Try without platform. 244 // Try without platform.
235 resource_file = resources_path + name + "_" + architecture + "." + extension; 245 resource_file = resources_path + name + "_" + architecture + "." + extension;
236 if (FileExists(resource_file)) { 246 if (FileExists(resource_file)) {
237 return resource_file; 247 return resource_file;
238 } 248 }
239 249
240 // Fall back on name without architecture or platform. 250 // Fall back on name without architecture or platform.
241 return resources_path + name + "." + extension; 251 return resources_path + name + "." + extension;
252 #endif // defined (WEBRTC_IOS)
242 } 253 }
243 254
244 size_t GetFileSize(std::string filename) { 255 size_t GetFileSize(std::string filename) {
245 FILE* f = fopen(filename.c_str(), "rb"); 256 FILE* f = fopen(filename.c_str(), "rb");
246 size_t size = 0; 257 size_t size = 0;
247 if (f != NULL) { 258 if (f != NULL) {
248 if (fseek(f, 0, SEEK_END) == 0) { 259 if (fseek(f, 0, SEEK_END) == 0) {
249 size = ftell(f); 260 size = ftell(f);
250 } 261 }
251 fclose(f); 262 fclose(f);
252 } 263 }
253 return size; 264 return size;
254 } 265 }
255 266
256 } // namespace test 267 } // namespace test
257 } // namespace webrtc 268 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/test.gyp ('k') | webrtc/test/testsupport/iosfileutils.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698