mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibCore: Add methods to convert DirectoryEntry types to names
We can either convert DirectoryEntry::type to its representative name or to the POSIX DT_* name.
This commit is contained in:
parent
90152dc859
commit
d568b09632
2 changed files with 53 additions and 0 deletions
|
@ -9,6 +9,56 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
StringView DirectoryEntry::posix_name_from_directory_entry_type(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Type::BlockDevice:
|
||||
return "DT_BLK"sv;
|
||||
case Type::CharacterDevice:
|
||||
return "DT_CHR"sv;
|
||||
case Type::Directory:
|
||||
return "DT_DIR"sv;
|
||||
case Type::File:
|
||||
return "DT_REG"sv;
|
||||
case Type::NamedPipe:
|
||||
return "DT_FIFO"sv;
|
||||
case Type::Socket:
|
||||
return "DT_SOCK"sv;
|
||||
case Type::SymbolicLink:
|
||||
return "DT_LNK"sv;
|
||||
case Type::Unknown:
|
||||
return "DT_UNKNOWN"sv;
|
||||
case Type::Whiteout:
|
||||
return "DT_WHT"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
StringView DirectoryEntry::representative_name_from_directory_entry_type(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Type::BlockDevice:
|
||||
return "BlockDevice"sv;
|
||||
case Type::CharacterDevice:
|
||||
return "CharacterDevice"sv;
|
||||
case Type::Directory:
|
||||
return "Directory"sv;
|
||||
case Type::File:
|
||||
return "File"sv;
|
||||
case Type::NamedPipe:
|
||||
return "NamedPipe"sv;
|
||||
case Type::Socket:
|
||||
return "Socket"sv;
|
||||
case Type::SymbolicLink:
|
||||
return "SymbolicLink"sv;
|
||||
case Type::Unknown:
|
||||
return "Unknown"sv;
|
||||
case Type::Whiteout:
|
||||
return "Whiteout"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
DirectoryEntry::Type DirectoryEntry::directory_entry_type_from_stat(mode_t st_mode)
|
||||
{
|
||||
switch (st_mode & S_IFMT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue