Convenience wrapper around FileT.
More...
#include <types.hxx>
|
enum | FileT : mode_t {
NONE = 0
, SOCKET = S_IFSOCK
, LINK = S_IFLNK
, REGULAR = S_IFREG
,
BLOCKDEV = S_IFBLK
, DIRECTORY = S_IFDIR
, CHARDEV = S_IFCHR
, FIFO = S_IFIFO
} |
| File type portion as found in a ModeT. More...
|
|
Convenience wrapper around FileT.
- Note
- You won't need to set the FileType in any API call, you only need to check the FileType reported back from e.g. a stat() system call.
Definition at line 151 of file types.hxx.
◆ FileT
File type portion as found in a ModeT.
Note that these are not bitmask values. Only one of the types can ever be set, no bitmask operations can be performed with this type.
These are the upper 4 bits of the st_mode field in struct stat. You can extract it using FileType.
TODO: This is now no class enum and thus no strong type. Using a strong type would be awkward, because we'd have something like OtherType::SOCKET, or FileType::Type::SOCKET. Once we reach C++20 we can use using enum OtherType
within the FileType class which will solve the problem.
Enumerator |
---|
REGULAR | symbolic link
|
Definition at line 168 of file types.hxx.
168 : mode_t {
169 NONE = 0,
170 SOCKET = S_IFSOCK,
171 LINK = S_IFLNK,
173 BLOCKDEV = S_IFBLK,
174 DIRECTORY = S_IFDIR,
175 CHARDEV = S_IFCHR,
176 FIFO = S_IFIFO
177 };
◆ FileType() [1/2]
cosmos::FileType::FileType |
( |
const FileT | raw | ) |
|
|
inlineexplicit |
◆ FileType() [2/2]
cosmos::FileType::FileType |
( |
const ModeT | raw | ) |
|
|
inlineexplicit |
Definition at line 182 of file types.hxx.
182 :
183 m_raw{
static_cast<FileT>(raw & ModeT::MODE_T_TYPE_MASK)}
184 {}
FileT
File type portion as found in a ModeT.
◆ isBlockDev()
bool cosmos::FileType::isBlockDev |
( |
| ) |
const |
|
inline |
Definition at line 189 of file types.hxx.
189{ return m_raw == BLOCKDEV; }
◆ isCharDev()
bool cosmos::FileType::isCharDev |
( |
| ) |
const |
|
inline |
Definition at line 188 of file types.hxx.
188{ return m_raw == CHARDEV; }
◆ isDirectory()
bool cosmos::FileType::isDirectory |
( |
| ) |
const |
|
inline |
Definition at line 187 of file types.hxx.
187{ return m_raw == DIRECTORY; }
◆ isFIFO()
bool cosmos::FileType::isFIFO |
( |
| ) |
const |
|
inline |
Definition at line 190 of file types.hxx.
190{ return m_raw == FIFO; }
◆ isLink()
bool cosmos::FileType::isLink |
( |
| ) |
const |
|
inline |
Definition at line 191 of file types.hxx.
191{ return m_raw == LINK; }
◆ isRegular()
bool cosmos::FileType::isRegular |
( |
| ) |
const |
|
inline |
◆ isSocket()
bool cosmos::FileType::isSocket |
( |
| ) |
const |
|
inline |
Definition at line 192 of file types.hxx.
192{ return m_raw == SOCKET; }
◆ operator!=()
bool cosmos::FileType::operator!= |
( |
const FileType & | other | ) |
const |
|
inline |
Definition at line 207 of file types.hxx.
207 {
208 return !(*this == other);
209 }
◆ operator==()
bool cosmos::FileType::operator== |
( |
const FileType & | other | ) |
const |
|
inline |
Definition at line 203 of file types.hxx.
203 {
204 return m_raw == other.m_raw;
205 }
◆ raw()
auto cosmos::FileType::raw |
( |
| ) |
const |
|
inline |
◆ symbolic()
char cosmos::FileType::symbolic |
( |
| ) |
const |
Returns a symbolic character representing the type.
This returns a symbolic character like 'd' for directory as known from the ls utility and other tools.
Definition at line 87 of file FileStatus.cxx.
87 {
88 switch(raw()) {
89 default: return '?';
90 case NONE: return '-';
91 case SOCKET: return 's';
92 case LINK: return 'l';
94 case BLOCKDEV: return 'b';
95 case DIRECTORY: return 'd';
96 case CHARDEV: return 'c';
97 case FIFO: return 'p';
98 }
99}
◆ m_raw
FileT cosmos::FileType::m_raw |
|
protected |
The documentation for this class was generated from the following files: