How to use the electron-json-storage.getDefaultDataPath function in electron-json-storage

To help you get started, we’ve selected a few electron-json-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yafp / ttth / app / js / ttth / ttth.js View on Github external
function readLocalUserSetting (key, optional = false) {
    const storage = require('electron-json-storage')
    const remote = require('electron').remote
    const app = remote.app
    const path = require('path')

    writeLog('info', 'readLocalUserSetting ::: Trying to read value of key: ' + key)

    const defaultDataPath = storage.getDefaultDataPath() // get default storage path
    const userSettingsPath = path.join(app.getPath('userData'), 'ttthUserSettings') // change path for userSettings
    storage.setDataPath(userSettingsPath)

    // read the json file
    storage.get(key, function (error, data) {
        if (error) {
            writeLog('error', 'readLocalUserSetting ::: Got error while reading a json file with the name: _' + key + '_. Error: ' + error)
            throw error
        }

        var value = data.setting // store the read value in a variable

        writeLog('info', 'readLocalUserSetting ::: key: _' + key + '_ - got value: _' + value + '_')
        storage.setDataPath(defaultDataPath) // revert storage path

        // setting DefaultView
github yafp / ttth / app / js / ttth / ttth.js View on Github external
function writeLocalUserSetting (key, value) {
    const storage = require('electron-json-storage')
    const remote = require('electron').remote
    const app = remote.app
    const path = require('path')

    const defaultDataPath = storage.getDefaultDataPath() // get default storage path
    const userSettingsPath = path.join(app.getPath('userData'), 'ttthUserSettings') // set new path for userUsettings
    storage.setDataPath(userSettingsPath)

    // write the user setting
    storage.set(key, { setting: value }, function (error) {
        if (error) {
            writeLog('error', 'writeLocalUserSetting ::: Got an error while trying to write a user setting with key: _' + key + '_ and value: _' + value + '_. Error: ' + error)
            throw error
        }
        writeLog('info', 'writeLocalUserSetting ::: key: _' + key + '_ - new value: _' + value + '_')
        storage.setDataPath(defaultDataPath) // revert to default path
    })
}
github CityOfZion / neon-wallet / app / hocs / withCopyCanvasToClipboard.js View on Github external
handleCopy = async (ref: ?HTMLCanvasElement, fileName: string) => {
      this.handleCopyIcon()
      function writeFile(fileName, data, type) {
        return new Promise((resolve, reject) => {
          fs.writeFile(fileName, data, type, err => {
            if (err) reject(err)
            else resolve(data)
          })
        })
      }
      // $FlowFixMe
      const url = ref.toDataURL('image/jpg', 0.8)
      const base64Data = url.replace(/^data:image\/png;base64,/, '')
      const storagePath = storage.getDefaultDataPath()
      await writeFile(`${storagePath}/${fileName}.jpg`, base64Data, 'base64')
      clipboard.writeImage(`${storagePath}/${fileName}.jpg`)
    }
github willnewii / qiniuClient / src / main / index.js View on Github external
click() {
                        shell.showItemInFolder(storage.getDefaultDataPath());
                    }
                },
github phodal / phodit / src / native / main.ts View on Github external
import {EventConstants} from "../common/constants/event.constants";
import {IFileSave} from "../common/interface/IFileSave";
import {git} from "./features/git";
import {pandoc} from "./features/pandoc";
import {buildMenu} from "./i18n/menu/menu";
import {dockMenu} from "./i18n/menu/menu.dock";
import {createHelpPage} from "./pages/help.page";
import {openHtmlPage} from "./pages/html.page";
import {createSlidePage} from "./pages/silde.page";

const tmp = require("tmp");
const chokidar = require("chokidar");

const windowStateKeeper = require("electron-window-state");
const storage = require("electron-json-storage");
const defaultDataPath = storage.getDefaultDataPath();
const blogpostData = require("../../assets/data/output.json");

const lunr = require("lunr");
const dataWithIndex: any[] = [];
let lunrIdx: any;
let currentFile: string;

let mainWindow: Electron.BrowserWindow;
let dir;

function dirTree(filename: string) {
  const stats = fs.lstatSync(filename);
  const info: any = {
    filename,
    module: path.basename(filename),
  };