From 9e31e0837ec3c5a88ed477bec3980dd4608046be Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 5 Jan 2011 03:30:27 +0100 Subject: [PATCH] Implement os.isWindows --- doc/api/os.markdown | 4 ++++ lib/os.js | 3 ++- src/node_os.cc | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/api/os.markdown b/doc/api/os.markdown index 3c4e1b44fd..477fcba417 100644 --- a/doc/api/os.markdown +++ b/doc/api/os.markdown @@ -14,6 +14,10 @@ Returns the operating system name. Returns the operating system release. +### os.isWindows + +True on windows, false otherwise. + ### os.uptime() Returns the system uptime in seconds. diff --git a/lib/os.js b/lib/os.js index 5b1bb22d18..007070dc6b 100644 --- a/lib/os.js +++ b/lib/os.js @@ -7,4 +7,5 @@ exports.freemem = binding.getFreeMem; exports.totalmem = binding.getTotalMem; exports.cpus = binding.getCPUs; exports.type = binding.getOSType; -exports.release = binding.getOSRelease; \ No newline at end of file +exports.release = binding.getOSRelease; +exports.isWindows = binding.isWindows; \ No newline at end of file diff --git a/src/node_os.cc b/src/node_os.cc index 758648835e..fd6395e947 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -145,6 +145,12 @@ void OS::Initialize(v8::Handle target) { NODE_SET_METHOD(target, "getCPUs", GetCPUInfo); NODE_SET_METHOD(target, "getOSType", GetOSType); NODE_SET_METHOD(target, "getOSRelease", GetOSRelease); + +#ifdef __POSIX__ + target->Set(String::New("isWindows"), False()); +#else // __MINGW32__ + target->Set(String::New("isWindows"), True()); +#endif }