Consolidate test file path on Android
BUG=None TEST=local Review URL: https://webrtc-codereview.appspot.com/879004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2934 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -36,13 +36,15 @@ static const char* kPathDelimiter = "\\";
|
|||||||
#else
|
#else
|
||||||
static const char* kPathDelimiter = "/";
|
static const char* kPathDelimiter = "/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WEBRTC_ANDROID
|
||||||
|
static const char* kRootDirName = "/sdcard/";
|
||||||
|
static const char* kResourcesDirName = "resources";
|
||||||
|
#else
|
||||||
// The file we're looking for to identify the project root dir.
|
// The file we're looking for to identify the project root dir.
|
||||||
static const char* kProjectRootFileName = "DEPS";
|
static const char* kProjectRootFileName = "DEPS";
|
||||||
static const char* kOutputDirName = "out";
|
static const char* kOutputDirName = "out";
|
||||||
static const char* kFallbackPath = "./";
|
static const char* kFallbackPath = "./";
|
||||||
#ifdef WEBRTC_ANDROID
|
|
||||||
static const char* kResourcesDirName = "/sdcard/";
|
|
||||||
#else
|
|
||||||
static const char* kResourcesDirName = "resources";
|
static const char* kResourcesDirName = "resources";
|
||||||
#endif
|
#endif
|
||||||
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
|
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
|
||||||
@ -64,6 +66,22 @@ bool FileExists(std::string& file_name) {
|
|||||||
return stat(file_name.c_str(), &file_info) == 0;
|
return stat(file_name.c_str(), &file_info) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WEBRTC_ANDROID
|
||||||
|
|
||||||
|
std::string ProjectRootPath() {
|
||||||
|
return kRootDirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string OutputPath() {
|
||||||
|
return kRootDirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string WorkingDir() {
|
||||||
|
return kRootDirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // WEBRTC_ANDROID
|
||||||
|
|
||||||
std::string ProjectRootPath() {
|
std::string ProjectRootPath() {
|
||||||
std::string path = WorkingDir();
|
std::string path = WorkingDir();
|
||||||
if (path == kFallbackPath) {
|
if (path == kFallbackPath) {
|
||||||
@ -88,16 +106,6 @@ std::string ProjectRootPath() {
|
|||||||
return kCannotFindProjectRootDir;
|
return kCannotFindProjectRootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WEBRTC_ANDROID
|
|
||||||
|
|
||||||
std::string OutputPath() {
|
|
||||||
// We need to touch this variable so it doesn't get flagged as unused.
|
|
||||||
(void)kOutputDirName;
|
|
||||||
return "/sdcard/";
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // WEBRTC_ANDROID
|
|
||||||
|
|
||||||
std::string OutputPath() {
|
std::string OutputPath() {
|
||||||
std::string path = ProjectRootPath();
|
std::string path = ProjectRootPath();
|
||||||
if (path == kCannotFindProjectRootDir) {
|
if (path == kCannotFindProjectRootDir) {
|
||||||
@ -110,8 +118,6 @@ std::string OutputPath() {
|
|||||||
return path + kPathDelimiter;
|
return path + kPathDelimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !WEBRTC_ANDROID
|
|
||||||
|
|
||||||
std::string WorkingDir() {
|
std::string WorkingDir() {
|
||||||
char path_buffer[FILENAME_MAX];
|
char path_buffer[FILENAME_MAX];
|
||||||
if (!GET_CURRENT_DIR(path_buffer, sizeof(path_buffer))) {
|
if (!GET_CURRENT_DIR(path_buffer, sizeof(path_buffer))) {
|
||||||
@ -122,6 +128,8 @@ std::string WorkingDir() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !WEBRTC_ANDROID
|
||||||
|
|
||||||
bool CreateDirectory(std::string directory_name) {
|
bool CreateDirectory(std::string directory_name) {
|
||||||
struct stat path_info = {0};
|
struct stat path_info = {0};
|
||||||
// Check if the path exists already:
|
// Check if the path exists already:
|
||||||
@ -157,9 +165,6 @@ std::string ResourcePath(std::string name, std::string extension) {
|
|||||||
std::string architecture = "32";
|
std::string architecture = "32";
|
||||||
#endif // WEBRTC_ARCH_64_BITS
|
#endif // WEBRTC_ARCH_64_BITS
|
||||||
|
|
||||||
#ifdef WEBRTC_ANDROID
|
|
||||||
std::string resources_path = kResourcesDirName;
|
|
||||||
#else
|
|
||||||
std::string resources_path = ProjectRootPath() + kResourcesDirName +
|
std::string resources_path = ProjectRootPath() + kResourcesDirName +
|
||||||
kPathDelimiter;
|
kPathDelimiter;
|
||||||
std::string resource_file = resources_path + name + "_" + platform + "_" +
|
std::string resource_file = resources_path + name + "_" + platform + "_" +
|
||||||
@ -177,7 +182,7 @@ std::string ResourcePath(std::string name, std::string extension) {
|
|||||||
if (FileExists(resource_file)) {
|
if (FileExists(resource_file)) {
|
||||||
return resource_file;
|
return resource_file;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Fall back on name without architecture or platform.
|
// Fall back on name without architecture or platform.
|
||||||
return resources_path + name + "." + extension;
|
return resources_path + name + "." + extension;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user