aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtest-filepath.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-04-28 00:28:09 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-04-28 00:28:09 +0000
commitc78ae6196dc9c24380b5cf86f8fd75a4d3edc704 (patch)
treeea5077b43fd8b0e10aedb67eb7488254efff7814 /src/gtest-filepath.cc
parentf2334aa19555063791ec16fe2b476ec00195bbb8 (diff)
downloadgoogletest-c78ae6196dc9c24380b5cf86f8fd75a4d3edc704.tar.gz
googletest-c78ae6196dc9c24380b5cf86f8fd75a4d3edc704.tar.bz2
googletest-c78ae6196dc9c24380b5cf86f8fd75a4d3edc704.zip
Ports gtest to C++Builder, by Josh Kelley.
Diffstat (limited to 'src/gtest-filepath.cc')
-rw-r--r--src/gtest-filepath.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc
index 3180d0d5..f966352b 100644
--- a/src/gtest-filepath.cc
+++ b/src/gtest-filepath.cc
@@ -88,10 +88,10 @@ FilePath FilePath::GetCurrentDir() {
// something reasonable.
return FilePath(kCurrentDirectoryString);
#elif GTEST_OS_WINDOWS
- char cwd[GTEST_PATH_MAX_ + 1] = {};
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#else
- char cwd[GTEST_PATH_MAX_ + 1] = {};
+ char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
#endif
}
@@ -127,8 +127,13 @@ FilePath FilePath::RemoveDirectoryName() const {
// On Windows platform, '\' is the path separator, otherwise it is '/'.
FilePath FilePath::RemoveFileName() const {
const char* const last_sep = strrchr(c_str(), kPathSeparator);
- return FilePath(last_sep ? String(c_str(), last_sep + 1 - c_str())
- : String(kCurrentDirectoryString));
+ String dir;
+ if (last_sep) {
+ dir = String(c_str(), last_sep + 1 - c_str());
+ } else {
+ dir = kCurrentDirectoryString;
+ }
+ return FilePath(dir);
}
// Helper functions for naming files in a directory for xml output.
@@ -141,11 +146,13 @@ FilePath FilePath::MakeFileName(const FilePath& directory,
const FilePath& base_name,
int number,
const char* extension) {
- const FilePath file_name(
- (number == 0) ?
- String::Format("%s.%s", base_name.c_str(), extension) :
- String::Format("%s_%d.%s", base_name.c_str(), number, extension));
- return ConcatPaths(directory, file_name);
+ String file;
+ if (number == 0) {
+ file = String::Format("%s.%s", base_name.c_str(), extension);
+ } else {
+ file = String::Format("%s_%d.%s", base_name.c_str(), number, extension);
+ }
+ return ConcatPaths(directory, FilePath(file));
}
// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".