pathname conversion -- handle dev:null, dev:stdout, dev:stdin, dev:stderr

This commit is contained in:
Kelvin Sherlock
2016-02-10 23:51:37 -05:00
parent 1339c0891f
commit a8920e2f53
2 changed files with 39 additions and 4 deletions

View File

@@ -13,7 +13,10 @@
namespace ToolBox {
std::string MacToUnix(const std::string path);
std::string UnixToMac(const std::string path);
}
template<class T>
T pop(std::vector<T> &v) {
@@ -42,7 +45,9 @@ int open(const std::string &name, int flags) {
// dup2 does not copy the O_CLOEXEC flag so it's safe to use.
int fd = ::open(name.c_str(), flags | O_CLOEXEC, 0666);
std::string uname = ToolBox::MacToUnix(name);
int fd = ::open(uname.c_str(), flags | O_CLOEXEC, 0666);
if (fd < 0) {
open_error(name);
return -1;