The Pedigree Project 0.1
FatDirectory.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef FAT_DIRECTORY_H
21#define FAT_DIRECTORY_H
22
23#include "pedigree/kernel/process/Mutex.h"
24#include "pedigree/kernel/processor/types.h"
25#include "pedigree/kernel/utilities/String.h"
26
27#include "fat.h"
28#include "modules/system/vfs/Directory.h"
29
30class File;
31
33class FatDirectory : public Directory {
34 friend class FatFilesystem;
35
36 private:
39 FatDirectory& operator=(const FatDirectory&);
40
41 public:
43 FatDirectory(String name, uintptr_t cluster, class FatFilesystem* pFs, File* pParent,
44 FatFileInfo& info, uint32_t dirClus = 0, uint32_t dirOffset = 0);
46 ~FatDirectory() override;
47
48 void truncate() override {}
49
51 void cacheDirectoryContents() override;
52
54 virtual bool addEntry(String filename, File* pFile, size_t type, bool publish = true);
56 virtual bool removeEntry(const String& filename, File* pFile);
57
59 void fileAttributeChanged() override;
60 bool sync() override;
61 bool sync(size_t, bool) override {
62 return sync();
63 }
64 Attributes getAttributes() const override;
65
67 void setInode(uintptr_t inode) override;
68
69 uint32_t getDirCluster() {
70 return m_DirClus;
71 }
72 void setDirCluster(uint32_t custom) {
73 m_DirClus = custom;
74 }
75 uint32_t getDirOffset() {
76 return m_DirOffset;
77 }
78 void setDirOffset(uint32_t custom) {
79 m_DirOffset = custom;
80 }
81
82 static const String& symlinkSuffix() {
83 static String s(".__sym");
84 return s;
85 }
86
87 private:
88 class NamespaceEdit;
89 bool encodeEntrySet(const String& filename, const Dir& metadata, Vector<Dir>& entries);
90
91 struct ScannedEntry {
92 String name;
93 Dir entry;
94 uint32_t directoryCluster;
95 uint32_t directoryOffset;
96 Directory::EntryType type;
97 };
98
99 using ScanEmitter = bool (*)(void*, const ScannedEntry&, uint64_t, uint64_t);
100
101 LookupStatus resolveChild(const StringView& name, File*& child) override;
102 LookupStatus resolveChildAt(uint64_t cookie, const StringView& name, File*& child) override;
103 ReadStatus readDirectory(uint64_t& cookie, DirectoryEntryEmitter emitter, void* context) override;
104
105 ReadStatus scanDirectory(uint64_t& cookie, ScanEmitter emitter, void* context);
106 File* materialize(const ScannedEntry& entry);
107
108 uint32_t m_DirClus;
109 uint32_t m_DirOffset;
110 bool m_Unlinked;
111
112 FatType m_Type;
113 uintptr_t m_BlockSize;
114 bool m_bRootDir;
115
118
121};
122
123#endif
void truncate() override
LookupStatus resolveChildAt(uint64_t cookie, const StringView &name, File *&child) override
FatDirectory(const FatDirectory &file)
virtual bool removeEntry(const String &filename, File *pFile)
ReadStatus readDirectory(uint64_t &cookie, DirectoryEntryEmitter emitter, void *context) override
virtual bool addEntry(String filename, File *pFile, size_t type, bool publish=true)
void setInode(uintptr_t inode) override
uint32_t m_DirBlockSize
void fileAttributeChanged() override
bool sync(size_t, bool) override
void cacheDirectoryContents() override
LookupStatus resolveChild(const StringView &name, File *&child) override
~FatDirectory() override
Definition File.h:75
Definition Mutex.h:56
A vector / dynamic array.
Definition Vector.h:33
Definition ext2.h:201