2014-11-22 16:59:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
2015-01-21 17:36:59 +01:00
|
|
|
const binding = process.binding('os');
|
2016-05-02 19:27:12 +02:00
|
|
|
const constants = process.binding('constants').os;
|
2015-06-13 18:44:39 +02:00
|
|
|
const internalUtil = require('internal/util');
|
2015-01-21 17:36:59 +01:00
|
|
|
const isWindows = process.platform === 'win32';
|
2010-12-11 09:49:38 +01:00
|
|
|
|
2010-12-22 19:55:47 +01: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 17:01:42 +02:00
|
|
|
exports.homedir = binding.getHomeDirectory;
|
2016-04-07 19:45:40 +02:00
|
|
|
exports.userInfo = binding.getUserInfo;
|
2015-05-25 17:01:42 +02:00
|
|
|
|
2016-05-02 19:27:12 +02:00
|
|
|
Object.defineProperty(exports, 'constants', {
|
|
|
|
configurable: false,
|
|
|
|
enumerable: true,
|
|
|
|
value: constants
|
|
|
|
});
|
2012-06-13 04:05:51 +02:00
|
|
|
|
2011-04-27 05:02:54 +02:00
|
|
|
exports.arch = function() {
|
|
|
|
return process.arch;
|
|
|
|
};
|
2012-06-13 04:05:51 +02:00
|
|
|
|
2011-04-27 05:02:54 +02:00
|
|
|
exports.platform = function() {
|
|
|
|
return process.platform;
|
|
|
|
};
|
2011-11-01 17:23:17 +01:00
|
|
|
|
2013-01-29 17:27:33 +01:00
|
|
|
exports.tmpdir = function() {
|
2015-02-06 23:27:22 +01:00
|
|
|
var path;
|
2013-03-19 07:58:44 +01:00
|
|
|
if (isWindows) {
|
2015-02-06 23:27:22 +01:00
|
|
|
path = process.env.TEMP ||
|
2013-03-19 07:58:44 +01:00
|
|
|
process.env.TMP ||
|
2013-03-28 21:19:08 +01:00
|
|
|
(process.env.SystemRoot || process.env.windir) + '\\temp';
|
2016-03-17 05:23:52 +01:00
|
|
|
if (path.length > 1 && path.endsWith('\\') && !path.endsWith(':\\'))
|
|
|
|
path = path.slice(0, -1);
|
2013-03-19 07:58:44 +01:00
|
|
|
} else {
|
2015-02-06 23:27:22 +01:00
|
|
|
path = process.env.TMPDIR ||
|
2013-03-19 07:58:44 +01:00
|
|
|
process.env.TMP ||
|
|
|
|
process.env.TEMP ||
|
|
|
|
'/tmp';
|
2016-03-17 05:23:52 +01:00
|
|
|
if (path.length > 1 && path.endsWith('/'))
|
|
|
|
path = path.slice(0, -1);
|
2013-03-19 07:58:44 +01:00
|
|
|
}
|
2016-03-17 05:23:52 +01:00
|
|
|
|
2015-02-06 23:27:22 +01:00
|
|
|
return path;
|
2013-03-28 21:19:08 +01:00
|
|
|
};
|
2012-06-13 04:05:51 +02:00
|
|
|
|
2016-05-13 18:08:44 +02:00
|
|
|
exports.tmpDir = internalUtil.deprecate(exports.tmpdir,
|
|
|
|
'os.tmpDir() is deprecated. Use os.tmpdir() instead.');
|
2013-01-29 17:27:33 +01:00
|
|
|
|
2015-06-13 18:44:39 +02:00
|
|
|
exports.getNetworkInterfaces = internalUtil.deprecate(function() {
|
2011-11-01 17:23:17 +01:00
|
|
|
return exports.networkInterfaces();
|
2015-06-13 18:44:39 +02:00
|
|
|
}, 'os.getNetworkInterfaces is deprecated. ' +
|
|
|
|
'Use os.networkInterfaces instead.');
|
2012-04-12 10:29:15 +02:00
|
|
|
|
2013-03-19 07:58:44 +01: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'; };
|