Fixed flatc not writing Java files without namespace.
If the schema didn't contain a namespace, paths would contain a leading /, causing files not to be written. Change-Id: I508772cbf6d18d464ef7d9f8842d0dbff14358a3 Tested: on Linux. Bug: 19067493
This commit is contained in:
parent
2b01247b30
commit
f60276f54b
|
@ -605,15 +605,14 @@ static bool SaveClass(const LanguageParameters &lang, const Parser &parser,
|
|||
if (!classcode.length()) return true;
|
||||
|
||||
std::string namespace_general;
|
||||
std::string namespace_dir = path;
|
||||
std::string namespace_dir = path; // Either empty or ends in separator.
|
||||
auto &namespaces = parser.namespaces_.back()->components;
|
||||
for (auto it = namespaces.begin(); it != namespaces.end(); ++it) {
|
||||
if (namespace_general.length()) {
|
||||
namespace_general += ".";
|
||||
namespace_dir += kPathSeparator;
|
||||
}
|
||||
namespace_general += *it;
|
||||
namespace_dir += *it;
|
||||
namespace_dir += *it + kPathSeparator;
|
||||
}
|
||||
EnsureDirExists(namespace_dir);
|
||||
|
||||
|
@ -623,8 +622,7 @@ static bool SaveClass(const LanguageParameters &lang, const Parser &parser,
|
|||
if (needs_includes) code += lang.includes;
|
||||
code += classcode;
|
||||
code += lang.namespace_end;
|
||||
auto filename = namespace_dir + kPathSeparator + def.name +
|
||||
lang.file_extension;
|
||||
auto filename = namespace_dir + def.name + lang.file_extension;
|
||||
return SaveFile(filename.c_str(), code, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue