From 43056a8684c6f44c74aab955bcb98b2bd7713e75 Mon Sep 17 00:00:00 2001 From: stasoid Date: Fri, 15 Nov 2024 19:02:27 +0500 Subject: [PATCH] LibCore: Port Directory to Windows --- Libraries/LibCore/Directory.cpp | 10 +++++----- Libraries/LibCore/Directory.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Libraries/LibCore/Directory.cpp b/Libraries/LibCore/Directory.cpp index 482ae4ecce0..61807d14941 100644 --- a/Libraries/LibCore/Directory.cpp +++ b/Libraries/LibCore/Directory.cpp @@ -4,10 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include "Directory.h" -#include "DirIterator.h" -#include "System.h" -#include +#include +#include namespace Core { @@ -31,6 +29,7 @@ Directory::~Directory() MUST(System::close(m_directory_fd)); } +#ifndef AK_OS_WINDOWS ErrorOr Directory::chown(uid_t uid, gid_t gid) { if (m_directory_fd == -1) @@ -38,6 +37,7 @@ ErrorOr Directory::chown(uid_t uid, gid_t gid) TRY(Core::System::fchown(m_directory_fd, uid, gid)); return {}; } +#endif ErrorOr Directory::is_valid_directory(int fd) { @@ -69,7 +69,7 @@ ErrorOr Directory::create(LexicalPath path, CreateDirectories create_ ErrorOr Directory::ensure_directory(LexicalPath const& path, mode_t creation_mode) { - if (path.basename() == "/" || path.basename() == ".") + if (path.is_root() || path.string() == ".") return {}; TRY(ensure_directory(path.parent(), creation_mode)); diff --git a/Libraries/LibCore/Directory.h b/Libraries/LibCore/Directory.h index 9f9b401ad93..6b257339e56 100644 --- a/Libraries/LibCore/Directory.h +++ b/Libraries/LibCore/Directory.h @@ -10,14 +10,11 @@ #include #include #include -#include #include #include -#include #include #include #include -#include #include namespace Core { @@ -51,7 +48,9 @@ public: static ErrorOr for_each_entry(StringView path, DirIterator::Flags, ForEachEntryCallback); ErrorOr for_each_entry(DirIterator::Flags, ForEachEntryCallback); +#ifndef AK_OS_WINDOWS ErrorOr chown(uid_t, gid_t); +#endif static ErrorOr is_valid_directory(int fd);