• R/O
  • SSH

posixpp: Commit

The main posixpp library and associated tests.


Commit MetaInfo

Revisiona3ea6857c2f8588330ef6ca4f3f7bd87f997586e (tree)
Time2021-01-21 06:57:12
AuthorEric Hopper <hopper@omni...>
CommiterEric Hopper

Log Message

Update interface for tests.

Change Summary

Incremental Difference

diff -r a206782e27d7 -r a3ea6857c2f8 pubincludes/posixpp/fd.h
--- a/pubincludes/posixpp/fd.h Wed Jan 20 12:16:45 2021 -0800
+++ b/pubincludes/posixpp/fd.h Wed Jan 20 13:57:12 2021 -0800
@@ -6,6 +6,7 @@
66 #include <fcntl.h>
77
88 #include <posixpp/expected.h>
9+#include <posixpp/fdflags.h>
910 #include <syscalls/linux/simple_io.h>
1011
1112 namespace posixpp {
@@ -36,33 +37,54 @@
3637
3738 ///@{
3839 [[nodiscard]] static expected<fd>
39- open(char const *pathname, int flags) noexcept {
40+ open(char const *pathname, openflags flags) noexcept {
4041 return openat(fd(-100), pathname, flags, 0);
4142 }
42-
4343 [[nodiscard]] static expected<fd>
44- open(char const *pathname, int flags, ::mode_t mode) noexcept
45- {
46- return openat(fd(-100), pathname, flags, mode);
44+ open(char const *pathname, fdflags flags) noexcept {
45+ return open(pathname, openflags{flags});
4746 }
4847
4948 [[nodiscard]] static expected<fd>
50- openat(fd const &dirfd, char const *pathname, int flags) noexcept
49+ open(char const *pathname, openflags flags, ::mode_t mode) noexcept
50+ {
51+ return openat(fd(-100), pathname, flags, mode);
52+ }
53+ [[nodiscard]] static expected<fd>
54+ open(char const *pathname, fdflags flags, ::mode_t mode) noexcept
55+ {
56+ return open(pathname, openflags{flags}, mode);
57+ }
58+
59+ [[nodiscard]] static expected<fd>
60+ openat(fd const &dirfd, char const *pathname, openflags flags) noexcept
5161 {
5262 using ::syscalls::linux::openat;
5363 using posixpp::error_cascade;
54- return error_cascade(openat(dirfd.as_fd(), pathname, flags, 0),
64+ return error_cascade(openat(dirfd.as_fd(), pathname, flags.getbits(), 0),
5565 [](auto r) { return fd{static_cast<int>(r)}; });
5666 }
67+ [[nodiscard]] static expected<fd>
68+ openat(fd const &dirfd, char const *pathname, fdflags flags) noexcept
69+ {
70+ return openat(dirfd, pathname, openflags{flags});
71+ }
5772
5873 [[nodiscard]] static expected<fd>
59- openat(fd const &dirfd, char const *pathname, int flags, ::mode_t mode) noexcept
74+ openat(fd const &dirfd, char const *pathname,
75+ openflags flags, ::mode_t mode) noexcept
6076 {
6177 using ::syscalls::linux::openat;
6278 using posixpp::error_cascade;
63- return error_cascade(openat(dirfd.as_fd(), pathname, flags, mode),
79+ return error_cascade(openat(dirfd.as_fd(), pathname, flags.getbits(), mode),
6480 [](auto r) { return fd{static_cast<int>(r)}; });
6581 }
82+ [[nodiscard]] static expected<fd>
83+ openat(fd const &dirfd, char const *pathname,
84+ fdflags flags, ::mode_t mode) noexcept
85+ {
86+ return openat(dirfd, pathname, openflags{flags}, mode);
87+ }
6688 ///@}
6789
6890 expected<::std::size_t>
diff -r a206782e27d7 -r a3ea6857c2f8 tests/simplefd.cpp
--- a/tests/simplefd.cpp Wed Jan 20 12:16:45 2021 -0800
+++ b/tests/simplefd.cpp Wed Jan 20 13:57:12 2021 -0800
@@ -16,11 +16,13 @@
1616
1717 WHEN("A file 'foo' is opened with O_CREAT in this directory.") {
1818 using ::posixpp::fd;
19+ using ::posixpp::openflags;
20+ using ::posixpp::fdflags;
1921 using ::std::move;
2022 auto foo{
2123 move(fd::open(
2224 fooname.string().c_str(),
23- O_CREAT | O_WRONLY, 0666
25+ openflags::creat | fdflags::wronly, 0666
2426 ).result())
2527 };
2628
Show on old repository browser