summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/FSKit/IndexableProperty.h
blob: 84da861ea0a70c556e687e89790a4c7aba5b2458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -------------------------------------------

  Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.

------------------------------------------- */

#pragma once

#include <CFKit/Property.h>
#include <CompilerKit/CompilerKit.h>
#include <KernelKit/DriveMgr.h>

#define kIndexerCatalogNameLength (256U)
#define kIndexerClaimed (0xCF)
#define kIndexerUnclaimed (0xCA)

namespace Kernel {
namespace Indexer {
  struct Index final {
   public:
    Char Drive[kDriveNameLen]{};
    Char Path[kIndexerCatalogNameLength]{};
  };

  class IndexableProperty final : public Property {
   public:
    explicit IndexableProperty() : Property() {
      KBasicString<> strProp(kMaxPropLen);
      strProp += "/prop/indexable";

      this->GetKey() = strProp;
    }

    ~IndexableProperty() override = default;

    NE_COPY_DEFAULT(IndexableProperty)

   public:
    Index& Leak() noexcept;

   public:
    Void  AddFlag(UInt16 flag);
    Void  RemoveFlag(UInt16 flag);
    UInt16 HasFlag(UInt16 flag);

   private:
    Index  fIndex;
    UInt32 fFlags{};
  };

  /// @brief Index a file into the indexer instance.
  /// @param filename path
  /// @param filenameLen used bytes in path.
  /// @param indexer the filesystem indexer.
  /// @return none.
  Void fs_index_file(const Char* filename, SizeT filenameLen, IndexableProperty& indexer);
}  // namespace Indexer
}  // namespace Kernel