Unify two rmgen and GUI JSON file loading script functions, refs #4868.

Revert the introduction of the exact copies of FileExists ReadJSONFile
functions in MapGenerator.cpp introduced by 871ed04521.
Include JSInterface_VFS.cpp from MapGenerator.cpp to remove that code
while gaining the other missing VFS file loading functions in rmgen/.
Split RegisterScriptFunctions of JSInterface_VFS.cpp from eb4e66aab3
into RegisterReadOnlyScriptFunctions and RegisterWriteScriptFunctions to
prevent unintentional write access.

This was SVN commit r20507.
This commit is contained in:
elexis
2017-11-24 17:19:16 +00:00
parent 7a17a3152c
commit 4275a8a33c
4 changed files with 11 additions and 20 deletions
+5 -1
View File
@@ -203,7 +203,7 @@ void JSI_VFS::WriteJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::w
g_VFS->CreateFile(path, buf.Data(), buf.Size());
}
void JSI_VFS::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
void JSI_VFS::RegisterReadOnlyScriptFunctions(const ScriptInterface& scriptInterface)
{
scriptInterface.RegisterFunction<JS::Value, std::wstring, std::wstring, bool, &JSI_VFS::BuildDirEntList>("BuildDirEntList");
scriptInterface.RegisterFunction<bool, CStrW, JSI_VFS::FileExists>("FileExists");
@@ -212,5 +212,9 @@ void JSI_VFS::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<JS::Value, std::wstring, &JSI_VFS::ReadFile>("ReadFile");
scriptInterface.RegisterFunction<JS::Value, std::wstring, &JSI_VFS::ReadFileLines>("ReadFileLines");
scriptInterface.RegisterFunction<JS::Value, std::wstring, &ReadJSONFile>("ReadJSONFile");
}
void JSI_VFS::RegisterWriteScriptFunctions(const ScriptInterface& scriptInterface)
{
scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &WriteJSONFile>("WriteJSONFile");
}