Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 688x 688x 688x 688x 1x 1771x 1x 1x 1x 1x 1773x | /** * GPII SettingsDir.js * * Determines the user's settings directory on a variety of platforms, * and manages establishment of a subdirectory "/gpii" to hold writable files * for the system's journal and other purposes * * Copyright 2016 Raising the Floor - International * * Licensed under the New BSD license. You may not use this file except in * compliance with this License. * */ "use strict"; var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"), os = require("os"), fs = require("fs"); fluid.defaults("gpii.settingsDir", { gradeNames: ["fluid.component", "fluid.contextAware"], contextAwareness: { platform: { checks: { test: { contextValue: "{gpii.contexts.test}", gradeNames: "gpii.settingsDir.temp", priority: "first" }, windows: { contextValue: "{gpii.contexts.windows}", gradeNames: "gpii.settingsDir.windows" }, linux: { contextValue: "{gpii.contexts.linux}", gradeNames: "gpii.settingsDir.standard" } }, defaultGradeNames: "gpii.settingsDir.temp" } }, members: { gpiiSettingsDir: "@expand:{that}.getGpiiSettingsDir()" }, invokers: { getGpiiSettingsDir: "gpii.settingsDir.gpii({that}.getBaseSettingsDir)", getBaseSettingsDir: "fluid.notImplemented" }, listeners: { "onCreate.createGpiiDir": "gpii.settingsDir.createGpii" } }); fluid.defaults("gpii.settingsDir.temp", { invokers: { getBaseSettingsDir: "gpii.settingsDir.baseDir.temp" } }); fluid.defaults("gpii.settingsDir.windows", { invokers: { getBaseSettingsDir: "gpii.settingsDir.baseDir.windows" } }); fluid.defaults("gpii.settingsDir.standard", { invokers: { getBaseSettingsDir: "gpii.settingsDir.baseDir.standard" } }); gpii.settingsDir.createGpii = function (that) { fluid.log(fluid.logLevel.WARN, "Creating GPII settings directory in ", that.gpiiSettingsDir); try { // See code skeleton in http://stackoverflow.com/questions/13696148/node-js-create-folder-or-use-existing fs.mkdirSync(that.gpiiSettingsDir); } catch (e) { Iif (e.code !== "EEXIST") { fluid.fail("Unable to create GPII settings directory, code is " + e.code + ": exception ", e); } } }; gpii.settingsDir.gpii = function (getBaseSettingsDir) { return getBaseSettingsDir() + "/gpii"; }; fluid.registerNamespace("gpii.settingsDir.baseDir"); gpii.settingsDir.baseDir.windows = function () { return process.env.APPDATA; }; gpii.settingsDir.baseDir.standard = function () { return os.homedir(); }; gpii.settingsDir.baseDir.temp = function () { return os.tmpdir(); }; |