| 1872 | } |
| 1873 | |
| 1874 | void ScriptEngine::LoadSharedStorage() |
| 1875 | { |
| 1876 | InitSharedStorage(); |
| 1877 | |
| 1878 | auto path = _env.GetFilePath(PathId::pluginStore); |
| 1879 | try |
| 1880 | { |
| 1881 | if (File::Exists(path)) |
| 1882 | { |
| 1883 | auto data = File::ReadAllBytes(path); |
| 1884 | // quickjs wants a null terminator not counted in the buf_len |
| 1885 | data.push_back(0); |
| 1886 | JSValue result = JS_ParseJSON( |
| 1887 | _replContext, reinterpret_cast<const char*>(data.data()), data.size() - 1, path.c_str()); |
| 1888 | if (JS_IsObject(result)) |
| 1889 | { |
| 1890 | JS_FreeValue(_replContext, _sharedStorage); |
| 1891 | _sharedStorage = result; |
| 1892 | } |
| 1893 | else |
| 1894 | { |
| 1895 | Console::Error::WriteLine("Unable to load plugin shared storage"); |
| 1896 | } |
| 1897 | } |
| 1898 | } |
| 1899 | catch (const std::exception&) |
| 1900 | { |
| 1901 | Console::Error::WriteLine("Unable to read '%s'", path.c_str()); |
| 1902 | } |
| 1903 | } |
| 1904 | |
| 1905 | void ScriptEngine::SaveSharedStorage() |
| 1906 | { |
nothing calls this directly
no test coverage detected