From 05cafc5002360015a79484e6ee40c159b1c80958 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sun, 21 Feb 2016 19:22:01 -0500 Subject: Replace creat with mknod+open Performance is not an immediate concern, so replace creat with mknod to compact code. --- src/posix_extras.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/posix_extras.cc') diff --git a/src/posix_extras.cc b/src/posix_extras.cc index 359240f..f8274fb 100644 --- a/src/posix_extras.cc +++ b/src/posix_extras.cc @@ -75,6 +75,17 @@ struct stat File::LinkStatAt(const char* const path) const { return result; } +void File::MkNod(const char* const path, const mode_t mode, + const dev_t dev) const { + if (path[0] == '/') { + throw std::invalid_argument("absolute path"); + } + + if (mknodat(fd_, path, mode, dev) == -1) { + throw SystemError(); + } +} + File File::OpenAt(const char* const path, const int flags, const mode_t mode) const { if (path[0] == '/') { -- cgit v1.2.3