diff options
author | Sam Smith <sesmith177@gmail.com> | 2018-08-09 10:46:22 -0400 |
---|---|---|
committer | Akshat Gokhale <agokhale@pivotal.io> | 2018-08-09 10:46:22 -0400 |
commit | 84963a55110dd5e95d6d4d90fbe48b4a2addc4ff (patch) | |
tree | e95ce0e824ca096ac96c968293e4b1ab91c9990c /src | |
parent | 9bbc4b1fab8262958c172f2d8e87b486c950a051 (diff) | |
download | protobuf-84963a55110dd5e95d6d4d90fbe48b4a2addc4ff.tar.gz protobuf-84963a55110dd5e95d6d4d90fbe48b4a2addc4ff.tar.bz2 protobuf-84963a55110dd5e95d6d4d90fbe48b4a2addc4ff.zip |
Fix TryCreateParentDirectory on Windows
On Windows, both '/' and '\' are valid path separators. So when creating
the parent directories, split the filename on both
Signed-off-by: Akshat Gokhale <agokhale@pivotal.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/command_line_interface.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 8380367f..12dec9c2 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -168,7 +168,12 @@ bool VerifyDirectoryExists(const string& path) { // directories listed in |filename|. bool TryCreateParentDirectory(const string& prefix, const string& filename) { // Recursively create parent directories to the output file. +#if defined(_WIN32) + // on Windows, both '/' and '\' are valid path separators + std::vector<string> parts = Split(filename, "/\\", true); +#else std::vector<string> parts = Split(filename, "/", true); +#endif string path_so_far = prefix; for (int i = 0; i < parts.size() - 1; i++) { path_so_far += parts[i]; |