diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-21 19:22:01 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2016-02-21 20:38:02 -0500 |
commit | 05cafc5002360015a79484e6ee40c159b1c80958 (patch) | |
tree | 7443cf8226d198d1fd42540475b2f05bc23e2f28 /src/posix_extras.cc | |
parent | 08268425d61bd2b08a31d5589a4e7f1a62ac333d (diff) |
Replace creat with mknod+open
Performance is not an immediate concern, so replace creat with mknod to
compact code.
Diffstat (limited to 'src/posix_extras.cc')
-rw-r--r-- | src/posix_extras.cc | 11 |
1 files changed, 11 insertions, 0 deletions
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] == '/') { |