-
Notifications
You must be signed in to change notification settings - Fork 3
/
loc.js
80 lines (70 loc) · 1.53 KB
/
loc.js
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
'use strict'
const path = require('path')
const util = require('./util.js')
/* outcome/
* Return the base location of our application - where we can store
* configuration files, data etc
*/
function home() {
if(process.env.DESKTOP_AVATAR_HOME) return process.env.DESKTOP_AVATAR_HOME
let root = process.env.APPDATA
if(root) {
root = path.join(root, "Local")
} else {
root = process.env.HOME
}
return path.join(root, "desktop-avatar")
}
/* outcome/
* Return the location of the database directory
*/
function db() {
return path.join(home(), 'db')
}
/* outcome/
* Return the location of the plugin directory
*/
function plugin() {
return path.join(home(), 'plugins')
}
/* outcome/
* Return the location of the cookies directory
*/
function cookies() {
return path.join(home(), 'cookies')
}
/* outcome/
* return the location of a user's cookie file
*/
function cookieFile(userid) {
return path.join(cookies(), `${userid}`)
}
/* outcome/
* Return the location of the user-saved cookies directory
*/
function savedCookies() {
return path.join(home(), 'saved-cookies')
}
/* outcome/
* return the location of a saved user cookie file
*/
function savedCookieFile(userid) {
return path.join(savedCookies(), `${userid}`)
}
/* outcome/
* Return the location of a dumpfile for errors.
*/
function dmp() {
let t = (new Date()).toISOString()
return path.join(home(), `dmp-${t}.html`)
}
module.exports = {
home,
db,
plugin,
cookies,
cookieFile,
savedCookies,
savedCookieFile,
dmp,
}