Browse Source

Merge pull request #5024 from greenhouse-org/fix-windows-path

Fix TryCreateParentDirectory on Windows
Feng Xiao 7 years ago
parent
commit
fa252ec2a5
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/google/protobuf/compiler/command_line_interface.cc

+ 2 - 1
src/google/protobuf/compiler/command_line_interface.cc

@@ -168,7 +168,8 @@ bool VerifyDirectoryExists(const string& path) {
 // directories listed in |filename|.
 // directories listed in |filename|.
 bool TryCreateParentDirectory(const string& prefix, const string& filename) {
 bool TryCreateParentDirectory(const string& prefix, const string& filename) {
   // Recursively create parent directories to the output file.
   // Recursively create parent directories to the output file.
-  std::vector<string> parts = Split(filename, "/", true);
+  // On Windows, both '/' and '\' are valid path separators.
+  std::vector<string> parts = Split(filename, "/\\", true);
   string path_so_far = prefix;
   string path_so_far = prefix;
   for (int i = 0; i < parts.size() - 1; i++) {
   for (int i = 0; i < parts.size() - 1; i++) {
     path_so_far += parts[i];
     path_so_far += parts[i];