|
@@ -1,5 +1,6 @@
|
|
/*
|
|
/*
|
|
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
|
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
|
|
|
+ * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
*/
|
|
@@ -8,17 +9,19 @@
|
|
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Error.h>
|
|
#include <AK/Format.h>
|
|
#include <AK/Format.h>
|
|
|
|
+#include <AK/Function.h>
|
|
|
|
+#include <AK/IterationDecision.h>
|
|
#include <AK/LexicalPath.h>
|
|
#include <AK/LexicalPath.h>
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/Optional.h>
|
|
|
|
+#include <LibCore/DirIterator.h>
|
|
|
|
+#include <LibCore/DirectoryEntry.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibCore/File.h>
|
|
#include <dirent.h>
|
|
#include <dirent.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/stat.h>
|
|
|
|
|
|
namespace Core {
|
|
namespace Core {
|
|
|
|
|
|
-class DirIterator;
|
|
|
|
-
|
|
|
|
// Deal with real system directories. Any Directory instance always refers to a valid existing directory.
|
|
// Deal with real system directories. Any Directory instance always refers to a valid existing directory.
|
|
class Directory {
|
|
class Directory {
|
|
AK_MAKE_NONCOPYABLE(Directory);
|
|
AK_MAKE_NONCOPYABLE(Directory);
|
|
@@ -43,6 +46,10 @@ public:
|
|
|
|
|
|
LexicalPath const& path() const { return m_path; }
|
|
LexicalPath const& path() const { return m_path; }
|
|
|
|
|
|
|
|
+ using ForEachEntryCallback = Function<ErrorOr<IterationDecision>(DirectoryEntry const&, Directory const& parent)>;
|
|
|
|
+ static ErrorOr<void> for_each_entry(StringView path, DirIterator::Flags, ForEachEntryCallback);
|
|
|
|
+ ErrorOr<void> for_each_entry(DirIterator::Flags, ForEachEntryCallback);
|
|
|
|
+
|
|
ErrorOr<void> chown(uid_t, gid_t);
|
|
ErrorOr<void> chown(uid_t, gid_t);
|
|
|
|
|
|
static ErrorOr<bool> is_valid_directory(int fd);
|
|
static ErrorOr<bool> is_valid_directory(int fd);
|