mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
8a16c69e3e
* Mod info * Size * Steam Workshop info
31 lines
693 B
JavaScript
31 lines
693 B
JavaScript
var armaClassParser = require('arma-class-parser')
|
|
var fs = require('fs')
|
|
var path = require('path')
|
|
|
|
function stripBOM (data) {
|
|
if (data.charCodeAt(0) === 0xFEFF) {
|
|
return data.slice(1)
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
module.exports = function (modPath, config, callback) {
|
|
var modCpp = path.resolve(config.path, modPath, 'mod.cpp')
|
|
fs.readFile(modCpp, 'utf8', function (err, data) {
|
|
if (err) {
|
|
return callback(null, null)
|
|
}
|
|
|
|
try {
|
|
var meta = armaClassParser.parse(stripBOM(data))
|
|
callback(null, {
|
|
name: meta.name
|
|
})
|
|
} catch (err) {
|
|
console.log('Error parsing mod.cpp for ' + modPath + ', ' + err)
|
|
callback(null, null)
|
|
}
|
|
})
|
|
}
|