2014-11-22 16:59:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
2015-01-21 11:36:59 -05:00
|
|
|
const binding = process.binding('os');
|
2015-06-13 16:44:39 +00:00
|
|
|
const internalUtil = require('internal/util');
|
2015-01-21 11:36:59 -05:00
|
|
|
const isWindows = process.platform === 'win32';
|
2010-12-11 03:49:38 -05:00
|
|
|
|
2010-12-22 13:55:47 -05:00
|
|
|
exports.hostname = binding.getHostname;
|
|
|
|
exports.loadavg = binding.getLoadAvg;
|
|
|
|
exports.uptime = binding.getUptime;
|
|
|
|
exports.freemem = binding.getFreeMem;
|
|
|
|
exports.totalmem = binding.getTotalMem;
|
|
|
|
exports.cpus = binding.getCPUs;
|
|
|
|
exports.type = binding.getOSType;
|
2011-01-05 03:30:27 +01:00
|
|
|
exports.release = binding.getOSRelease;
|
2011-11-01 17:23:17 +01:00
|
|
|
exports.networkInterfaces = binding.getInterfaceAddresses;
|
2015-05-25 11:01:42 -04:00
|
|
|
exports.homedir = binding.getHomeDirectory;
|
|
|
|
|
2012-06-12 19:05:51 -07:00
|
|
|
|
2011-04-26 20:02:54 -07:00
|
|
|
exports.arch = function() {
|
|
|
|
return process.arch;
|
|
|
|
};
|
2012-06-12 19:05:51 -07:00
|
|
|
|
2011-04-26 20:02:54 -07:00
|
|
|
exports.platform = function() {
|
|
|
|
return process.platform;
|
|
|
|
};
|
2011-11-01 17:23:17 +01:00
|
|
|
|
2015-05-11 12:11:01 -04:00
|
|
|
const trailingSlashRe = isWindows ? /[^:]\\$/
|
|
|
|
: /.\/$/;
|
|
|
|
|
2013-01-29 17:27:33 +01:00
|
|
|
exports.tmpdir = function() {
|
2015-02-06 23:27:22 +01:00
|
|
|
var path;
|
2013-03-19 15:58:44 +09:00
|
|
|
if (isWindows) {
|
2015-02-06 23:27:22 +01:00
|
|
|
path = process.env.TEMP ||
|
2013-03-19 15:58:44 +09:00
|
|
|
process.env.TMP ||
|
2013-03-28 13:19:08 -07:00
|
|
|
(process.env.SystemRoot || process.env.windir) + '\\temp';
|
2013-03-19 15:58:44 +09:00
|
|
|
} else {
|
2015-02-06 23:27:22 +01:00
|
|
|
path = process.env.TMPDIR ||
|
2013-03-19 15:58:44 +09:00
|
|
|
process.env.TMP ||
|
|
|
|
process.env.TEMP ||
|
|
|
|
'/tmp';
|
|
|
|
}
|
2015-05-11 12:11:01 -04:00
|
|
|
if (trailingSlashRe.test(path))
|
2015-02-06 23:27:22 +01:00
|
|
|
path = path.slice(0, -1);
|
|
|
|
return path;
|
2013-03-28 13:19:08 -07:00
|
|
|
};
|
2012-06-12 19:05:51 -07:00
|
|
|
|
2013-01-29 17:27:33 +01:00
|
|
|
exports.tmpDir = exports.tmpdir;
|
|
|
|
|
2015-06-13 16:44:39 +00:00
|
|
|
exports.getNetworkInterfaces = internalUtil.deprecate(function() {
|
2011-11-01 17:23:17 +01:00
|
|
|
return exports.networkInterfaces();
|
2015-06-13 16:44:39 +00:00
|
|
|
}, 'os.getNetworkInterfaces is deprecated. ' +
|
|
|
|
'Use os.networkInterfaces instead.');
|
2012-04-12 01:29:15 -07:00
|
|
|
|
2013-03-19 15:58:44 +09:00
|
|
|
exports.EOL = isWindows ? '\r\n' : '\n';
|
2014-11-11 00:40:58 +01:00
|
|
|
|
|
|
|
if (binding.isBigEndian)
|
|
|
|
exports.endianness = function() { return 'BE'; };
|
|
|
|
else
|
|
|
|
exports.endianness = function() { return 'LE'; };
|