The Pedigree Project 0.1
Iso9660Directory.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 ISO9660DIRECTORY_H
21#define ISO9660DIRECTORY_H
22
23#include "pedigree/kernel/Log.h"
24#include "pedigree/kernel/machine/Disk.h"
25#include "pedigree/kernel/processor/types.h"
26#include "pedigree/kernel/time/Time.h"
27#include "pedigree/kernel/utilities/String.h"
28#include "pedigree/kernel/utilities/utility.h"
29
30#include "Iso9660File.h"
31#include "Iso9660Filesystem.h"
32#include "iso9660.h"
33#include "modules/system/vfs/Directory.h"
34
35class File;
36
38 friend class Iso9660File;
39
40 private:
42 Iso9660Directory& operator=(const Iso9660Directory&);
43
44 public:
45 Iso9660Directory(String name, size_t inode, class Iso9660Filesystem* pFs, File* pParent,
46 Iso9660DirRecord& dirRec, Time::Timestamp accessedTime = 0,
47 Time::Timestamp modifiedTime = 0, Time::Timestamp creationTime = 0)
48 : Directory(name, accessedTime, modifiedTime, creationTime, inode, pFs, 0, pParent),
49 m_pFs(pFs),
50 m_Dir(dirRec) {}
51 virtual ~Iso9660Directory();
52
53 virtual bool addEntry(String filename, File* pFile, size_t type) {
54 return false;
55 }
56
57 virtual bool removeEntry(File* pFile) {
58 return false;
59 }
60
61 void fileAttributeChanged() override {}
62
63 inline Iso9660DirRecord& getDirRecord() {
64 return m_Dir;
65 }
66
67 protected:
68 LookupStatus resolveChild(const StringView& name, File*& child) override;
69 LookupStatus resolveChildAt(uint64_t cookie, const StringView& name, File*& child) override;
70 ReadStatus readDirectory(uint64_t& cookie, DirectoryEntryEmitter emitter, void* context) override;
71
72 private:
73 struct ScannedEntry {
74 const String* name;
75 Iso9660DirRecord* record;
76 uint64_t currentCookie;
77 uint64_t nextCookie;
78 };
79
80 using ScannedEntryEmitter = bool (*)(void*, const ScannedEntry&);
81
83 Iso9660Directory* directory;
84 StringView name;
85 File* child;
86 uint64_t expectedCookie;
87 bool checkCookie;
88 };
89
90 struct ReadContext {
91 DirectoryEntryEmitter emitter;
92 void* context;
93 };
94
95 ReadStatus scanDirectory(uint64_t& cookie, ScannedEntryEmitter emitter, void* context);
96 static bool resolveEntry(void* context, const ScannedEntry& entry);
97 static bool emitEntry(void* context, const ScannedEntry& entry);
98
99 // Filesystem object
100 Iso9660Filesystem* m_pFs;
101
102 // Our internal directory information (info about *this* directory, not the
103 // child)
104 Iso9660DirRecord m_Dir;
105};
106
107#endif
Definition File.h:74
LookupStatus resolveChild(const StringView &name, File *&child) override
LookupStatus resolveChildAt(uint64_t cookie, const StringView &name, File *&child) override
ReadStatus readDirectory(uint64_t &cookie, DirectoryEntryEmitter emitter, void *context) override