mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 16:40:21 +00:00
LibCore: Port Directory to Windows
This commit is contained in:
parent
a423493dd8
commit
43056a8684
Notes:
github-actions[bot]
2024-11-20 05:08:09 +00:00
Author: https://github.com/stasoid Commit: https://github.com/LadybirdBrowser/ladybird/commit/43056a8684c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2188 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 7 additions and 8 deletions
|
@ -4,10 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Directory.h"
|
||||
#include "DirIterator.h"
|
||||
#include "System.h"
|
||||
#include <dirent.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/System.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -31,6 +29,7 @@ Directory::~Directory()
|
|||
MUST(System::close(m_directory_fd));
|
||||
}
|
||||
|
||||
#ifndef AK_OS_WINDOWS
|
||||
ErrorOr<void> Directory::chown(uid_t uid, gid_t gid)
|
||||
{
|
||||
if (m_directory_fd == -1)
|
||||
|
@ -38,6 +37,7 @@ ErrorOr<void> Directory::chown(uid_t uid, gid_t gid)
|
|||
TRY(Core::System::fchown(m_directory_fd, uid, gid));
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
ErrorOr<bool> Directory::is_valid_directory(int fd)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ ErrorOr<Directory> Directory::create(LexicalPath path, CreateDirectories create_
|
|||
|
||||
ErrorOr<void> 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));
|
||||
|
|
|
@ -10,14 +10,11 @@
|
|||
#include <AK/Error.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/IterationDecision.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/DirectoryEntry.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace Core {
|
||||
|
@ -51,7 +48,9 @@ public:
|
|||
static ErrorOr<void> for_each_entry(StringView path, DirIterator::Flags, ForEachEntryCallback);
|
||||
ErrorOr<void> for_each_entry(DirIterator::Flags, ForEachEntryCallback);
|
||||
|
||||
#ifndef AK_OS_WINDOWS
|
||||
ErrorOr<void> chown(uid_t, gid_t);
|
||||
#endif
|
||||
|
||||
static ErrorOr<bool> is_valid_directory(int fd);
|
||||
|
||||
|
|
Loading…
Reference in a new issue