-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsample.js
34 lines (25 loc) · 986 Bytes
/
sample.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
const fs = require('fs');
const config = {
steamUserId: process.env.STEAM_USER_ID,
steamDirectory: process.env.STEAM_DIRECTORY || 'C:/Program Files (x86)/Steam'
};
const shortcut = require('./lib');
const filePath = config.steamDirectory + '/userdata/' + config.steamUserId + '/config/shortcuts.vdf';
const writePath = filePath.replace('shortcuts', 'shortcuts_write');
shortcut.parseFile(filePath,
{ autoConvertArrays: true, autoConvertBooleans: true, dateProperties: ['LastPlayTime'] },
function (err, obj, inputBuffer) {
if (err) {
console.log('failed to read ' + filePath);
return;
}
//Buffer read from file
console.log('Raw Buffer:', inputBuffer);
//Parsed Object
console.log(JSON.stringify(obj, null, 2));
shortcut.writeFile(writePath, obj, function (err) {
if (err) {
console.log('failed to write ' + writePath);
}
});
});