windows95/src/state.js
Felix Rieseberg 8a3e36a2cf 🚀 Oh look, it works!
2018-08-22 22:03:28 -07:00

25 lines
520 B
JavaScript

const fs = require('fs-extra')
const path = require('path')
const { remote } = require('electron')
const DEFAULT_PATH = path.join(__dirname, 'renderer/images/default-state.bin')
const STATE_PATH = path.join(remote.app.getPath('userData'), 'state.bin')
function getState() {
const statePath = fs.existsSync(STATE_PATH)
? STATE_PATH
: DEFAULT_PATH
return fs.readFileSync(statePath).buffer
}
function resetState() {
fs.removeSync(STATE_PATH)
}
module.exports = {
STATE_PATH,
resetState,
getState
}