blob: 3ba31c2db4a27f06449ab456ef7b34e81081bc7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <fcntl.h>
namespace Hyprutils {
namespace OS {
class CFileDescriptor {
public:
CFileDescriptor() = default;
explicit CFileDescriptor(int const fd);
CFileDescriptor(CFileDescriptor &&) noexcept;
CFileDescriptor &operator=(CFileDescriptor &&) noexcept;
~CFileDescriptor();
CFileDescriptor(const CFileDescriptor &) = delete;
CFileDescriptor &operator=(const CFileDescriptor &) = delete;
bool operator==(const CFileDescriptor &rhs) const {
return m_fd == rhs.m_fd;
}
bool isValid() const;
int get() const;
int getFlags() const;
bool setFlags(int flags);
int take();
void reset();
CFileDescriptor duplicate(int flags = F_DUPFD_CLOEXEC) const;
bool isReadable() const;
bool isClosed() const;
static bool isReadable(int fd);
static bool isClosed(int fd);
private:
int m_fd = -1;
};
}; // namespace OS
}; // namespace Hyprutils
|