Support logs directory for Arma, Arma 2 and Arma 2 OA

This commit is contained in:
Björn Dahlgren 2017-10-04 00:50:07 +02:00 committed by Björn Dahlgren
parent 056150a30a
commit 7dedbc9f45

View File

@ -4,6 +4,14 @@ var filesize = require('filesize')
var path = require('path')
var userhome = require('userhome')
var gamesLogFolder = {
arma1: 'ArmA',
arma2: 'ArmA 2',
arma2oa: 'ArmA 2 OA',
arma3: 'Arma 3',
arma3_x64: 'Arma 3'
}
var Logs = function (config) {
this.config = config
@ -29,13 +37,19 @@ Logs.prototype.logsPath = function () {
return path.join(this.config.path, 'logs')
}
var gameLogFolder = gamesLogFolder[this.config.game]
if (!gameLogFolder) {
return null
}
if (this.config.type === 'windows') {
return userhome('AppData', 'Local', 'Arma 3')
return userhome('AppData', 'Local', gameLogFolder)
}
if (this.config.type === 'wine') {
var username = process.env.USER
return userhome('.wine', 'drive_c', 'users', username, 'Local Settings', 'Application Data', 'Arma 3')
return userhome('.wine', 'drive_c', 'users', username, 'Local Settings', 'Application Data', gameLogFolder)
}
return null
@ -45,7 +59,7 @@ Logs.prototype.logFiles = function (callback) {
var directory = this.logsPath()
if (directory === null) {
callback(null, [])
return callback(null, [])
}
fs.readdir(directory, function (err, files) {