Terminate the output directory argument of flatc.

Given the command

flatc -o . -c test.fbs

it would generate header file

.test_generated.h

rather than

./test_generated.h

This fixes this issue.

Tested:
Manually verified that flatc generates the correct output files given output
paths ending with and without '/' on Linux and Windows.

Bug: 16464827
Change-Id: I854cb881286f22690f1885f942cf3fd2fc59ca8d
This commit is contained in:
Stewart Miles
2014-07-21 17:56:53 -07:00
parent 3fb6a86d02
commit 60acef94e1
3 changed files with 13 additions and 6 deletions

View File

@@ -134,6 +134,10 @@ int main(int argc, const char *argv[]) {
case 'o':
if (++i >= argc) Error("missing path following", arg, true);
output_path = argv[i];
if (!(output_path.back() == flatbuffers::kPathSeparator ||
output_path.back() == flatbuffers::kPosixPathSeparator)) {
output_path += flatbuffers::kPathSeparator;
}
break;
case 'S':
opts.strict_json = true;
@@ -212,4 +216,3 @@ int main(int argc, const char *argv[]) {
return 0;
}