diff --git a/CHANGELOG.md b/CHANGELOG.md index 4369df7..bd8f4e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ Other changes | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.33.10 | 2017-12-14 | bugfix WMIC blockDevice parse (Windows 7) | | 3.33.9 | 2017-12-14 | bugfix WMIC not found (Windows) | | 3.33.8 | 2017-12-02 | bugfix diskLayout().size (OSX) | | 3.33.7 | 2017-11-28 | bugfix diskLayout().size | diff --git a/lib/filesystem.js b/lib/filesystem.js index 2a9fe89..4ff01ab 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -237,29 +237,31 @@ function blockDevices(callback) { }); } if (_windows) { - exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /format:csv', function (error, stdout) { + let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'] + exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', function (error, stdout) { if (!error) { - let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0); - lines.forEach(function (line) { - if (line !== '') { - line = line.replace('\r', '').split(','); + let devices = stdout.toString().split(/\n\s*\n/); + devices.forEach(function (device) { + let lines = device.split('\r\n'); + let drivetype = util.getValue(lines, 'drivetype', '='); + if (drivetype) { data.push({ - name: line[7], - identifier: line[1], + name: util.getValue(lines, 'name', '='), + identifier: util.getValue(lines, 'caption', '='), type: 'disk', - fstype: line[5].toLowerCase(), - mount: line[1], - size: line[8], - physical: line[4] === '5' ? 'CD/DVD' : 'HDD', - uuid: line[10], - label: line[9], + fstype: util.getValue(lines, 'filesystem', '=').toLowerCase(), + mount: util.getValue(lines, 'caption', '='), + size: util.getValue(lines, 'size', '='), + physical: (drivetype >= 0 && drivetype <= 6) ? drivetypes[drivetype] : drivetypes[0], + uuid: util.getValue(lines, 'volumeserialnumber', '='), + label: util.getValue(lines, 'volumename', '='), model: '', - serial: line[10], - removable: line[4] === '2', + serial: util.getValue(lines, 'volumeserialnumber', '='), + removable: drivetype === '2', protocol: '' }); } - }); + }); } if (callback) { callback(data);