| 1903 | } |
| 1904 | |
| 1905 | void ScriptEngine::SaveSharedStorage() |
| 1906 | { |
| 1907 | auto path = _env.GetFilePath(PathId::pluginStore); |
| 1908 | try |
| 1909 | { |
| 1910 | JSValue jsonVal = JS_JSONStringify(_replContext, _sharedStorage, JS_UNDEFINED, JS_UNDEFINED); |
| 1911 | if (JS_IsString(jsonVal)) |
| 1912 | { |
| 1913 | // inefficient to copy the whole string out first, but we have to do this to avoid breaking the exception flow |
| 1914 | std::string json = JSToStdString(_replContext, jsonVal); |
| 1915 | JS_FreeValue(_replContext, jsonVal); |
| 1916 | File::WriteAllBytes(path, json.c_str(), json.size()); |
| 1917 | return; |
| 1918 | } |
| 1919 | JS_FreeValue(_replContext, jsonVal); |
| 1920 | Console::Error::WriteLine("Unable to stringify shared storage JSON"); |
| 1921 | } |
| 1922 | catch (const std::exception&) |
| 1923 | { |
| 1924 | Console::Error::WriteLine("Unable to write to '%s'", path.c_str()); |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | void ScriptEngine::ClearParkStorage() |
| 1929 | { |
no test coverage detected