1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-02 07:08:11 +00:00
serenity/Userland/Libraries/LibCore/DirectoryEntry.h
implicitfield 7c9ca8baab LibCore: Fall back to fstat if readdir doesn't produce a valid file type
Per POSIX, It is valid for dirent structures obtained via readdir to
not name a valid type.
2024-01-05 04:00:11 +03:30

36 lines
725 B
C++

/*
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteString.h>
#include <dirent.h>
namespace Core {
struct DirectoryEntry {
enum class Type {
BlockDevice,
CharacterDevice,
Directory,
File,
NamedPipe,
Socket,
SymbolicLink,
Unknown,
Whiteout,
};
Type type;
// FIXME: Once we have a special Path string class, use that.
ByteString name;
ino_t inode_number;
static Type directory_entry_type_from_stat(mode_t st_mode);
static DirectoryEntry from_dirent(dirent const&);
static DirectoryEntry from_stat(DIR*, dirent const&);
};
}