DirectoryEntry.h 893 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteString.h>
  8. #include <AK/StringView.h>
  9. #include <dirent.h>
  10. namespace Core {
  11. struct DirectoryEntry {
  12. enum class Type {
  13. BlockDevice,
  14. CharacterDevice,
  15. Directory,
  16. File,
  17. NamedPipe,
  18. Socket,
  19. SymbolicLink,
  20. Unknown,
  21. Whiteout,
  22. };
  23. Type type;
  24. // FIXME: Once we have a special Path string class, use that.
  25. ByteString name;
  26. ino_t inode_number;
  27. static StringView posix_name_from_directory_entry_type(Type);
  28. static StringView representative_name_from_directory_entry_type(Type);
  29. static Type directory_entry_type_from_stat(mode_t st_mode);
  30. static DirectoryEntry from_dirent(dirent const&);
  31. static DirectoryEntry from_stat(DIR*, dirent const&);
  32. };
  33. }