Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/ModInstaller.cpp
Show All 16 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "ModInstaller.h" | #include "ModInstaller.h" | ||||
#include "lib/file/vfs/vfs_util.h" | #include "lib/file/vfs/vfs_util.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "scriptinterface/ScriptInterface.h" | |||||
#include "scriptinterface/JSON.h" | |||||
#ifdef OS_WIN | #ifdef OS_WIN | ||||
#include <fstream> | #include <fstream> | ||||
#endif | #endif | ||||
CModInstaller::CModInstaller(const OsPath& modsdir, const OsPath& tempdir) : | CModInstaller::CModInstaller(const OsPath& modsdir, const OsPath& tempdir) : | ||||
m_ModsDir(modsdir), m_TempDir(tempdir / "_modscache"), m_CacheDir("cache/") | m_ModsDir(modsdir), m_TempDir(tempdir / "_modscache"), m_CacheDir("cache/") | ||||
{ | { | ||||
Show All 31 Lines | CModInstaller::ModInstallationResult CModInstaller::Install( | ||||
// Extract the name of the mod | // Extract the name of the mod | ||||
CStr modName; | CStr modName; | ||||
{ | { | ||||
ScriptInterface scriptInterface("Engine", "ModInstaller", scriptContext); | ScriptInterface scriptInterface("Engine", "ModInstaller", scriptContext); | ||||
ScriptRequest rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
JS::RootedValue json_val(rq.cx); | JS::RootedValue json_val(rq.cx); | ||||
if (!scriptInterface.ParseJSON(modinfo.GetAsString(), &json_val)) | if (!Script::ParseJSON(rq, modinfo.GetAsString(), &json_val)) | ||||
return FAIL_ON_PARSE_JSON; | return FAIL_ON_PARSE_JSON; | ||||
JS::RootedObject json_obj(rq.cx, json_val.toObjectOrNull()); | JS::RootedObject json_obj(rq.cx, json_val.toObjectOrNull()); | ||||
JS::RootedValue name_val(rq.cx); | JS::RootedValue name_val(rq.cx); | ||||
if (!JS_GetProperty(rq.cx, json_obj, "name", &name_val)) | if (!JS_GetProperty(rq.cx, json_obj, "name", &name_val)) | ||||
return FAIL_ON_EXTRACT_NAME; | return FAIL_ON_EXTRACT_NAME; | ||||
Script::FromJSVal(rq, name_val, modName); | Script::FromJSVal(rq, name_val, modName); | ||||
if (modName.empty()) | if (modName.empty()) | ||||
return FAIL_ON_EXTRACT_NAME; | return FAIL_ON_EXTRACT_NAME; | ||||
Show All 35 Lines |
Wildfire Games · Phabricator