From: Christopher Dykes Date: Wed, 10 Aug 2016 19:35:31 +0000 (-0700) Subject: Special-case /dev/null in open in the portability header X-Git-Tag: v2016.08.15.00~23 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c326c636c394b6b8c2ea170bafb89e7a00d8e828;p=folly.git Special-case /dev/null in open in the portability header Summary: `/dev/null` doesn't exist on Windows, but thankfully, `NUL` does, and has the same semantics. Reviewed By: meyering Differential Revision: D3698007 fbshipit-source-id: 5ef31c6576f988dd747ea3c39e296c244bc640b7 --- diff --git a/folly/portability/Fcntl.cpp b/folly/portability/Fcntl.cpp index 015f4a6d..9cbfa5bf 100755 --- a/folly/portability/Fcntl.cpp +++ b/folly/portability/Fcntl.cpp @@ -96,6 +96,11 @@ int open(char const* fn, int of, int pm) { // none are. return -1; } + if (!strcmp(fn, "/dev/null")) { + // Windows doesn't have a /dev/null, but it does have + // NUL, which achieves the same result. + fn = "NUL"; + } errno_t res = _sopen_s(&fh, fn, of, _SH_DENYNO, realMode); return res ? -1 : fh; }