The Pedigree Project  0.1
Filesystem.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 FILESYSTEM_H
21 #define FILESYSTEM_H
22 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 #include "pedigree/kernel/utilities/String.h"
26 
27 class Disk;
28 class File;
29 class StringView;
30 
37 {
39  friend class VFS;
40 
41  public:
42  //
43  // Public interface
44  //
45 
47  Filesystem();
49  virtual ~Filesystem();
50 
53  virtual bool initialise(Disk *pDisk) = 0;
54 
58  typedef Filesystem *(*ProbeCallback)(Disk *);
59 
67  virtual File *find(const StringView &path);
68  virtual File *find(const String &path);
69  virtual File *find(const StringView &path, File *pStartNode);
70  virtual File *find(const String &path, File *pStartNode);
71 
73  virtual File *getRoot() const = 0;
74 
76  virtual String getVolumeLabel() const = 0;
77 
80  bool
81  createFile(const StringView &path, uint32_t mask, File *pStartNode = 0);
82 
85  bool createDirectory(
86  const StringView &path, uint32_t mask, File *pStartNode = 0);
87 
89  bool createSymlink(
90  const StringView &path, const String &value, File *pStartNode = 0);
91 
93  bool createLink(const StringView &path, File *target, File *pStartNode = 0);
94 
98  bool remove(const StringView &path, File *pStartNode = 0);
99 
102  {
103  return m_pDisk;
104  }
105 
107  bool isReadOnly()
108  {
109  return m_bReadOnly;
110  }
111 
113  virtual bool isCaseSensitive()
114  {
115  return true;
116  }
117 
120  virtual bool remove(File *parent, File *file) = 0;
121 
122  protected:
124  virtual bool
125  createFile(File *parent, const String &filename, uint32_t mask) = 0;
127  virtual bool
128  createDirectory(File *parent, const String &filename, uint32_t mask) = 0;
130  virtual bool createSymlink(
131  File *parent, const String &filename, const String &value) = 0;
133  virtual bool createLink(File *parent, const String &filename, File *target);
138 
139  private:
141  File *getTrueRoot();
142 
146  File *findNode(File *pNode, StringView path);
147 
152  File *findParent(StringView path, File *pStartNode, String &filename);
153 
155  size_t m_nAliases;
156 
159  Filesystem(const Filesystem &);
162  void operator=(const Filesystem &);
163 };
164 
165 #endif
Disk * m_pDisk
Definition: Filesystem.h:137
File * find(const String &path, File *pStartNode=0)
Definition: VFS.cc:243
bool isReadOnly()
Definition: Filesystem.h:107
bool createLink(const String &path, File *target, File *pStartNode=0)
Definition: VFS.cc:397
size_t m_nAliases
Definition: Filesystem.h:155
Definition: String.h:49
Disk * getDisk()
Definition: Filesystem.h:101
Definition: Disk.h:32
Definition: VFS.h:57
bool createSymlink(const String &path, const String &value, File *pStartNode=0)
Definition: VFS.cc:370
bool createDirectory(const String &path, uint32_t mask, File *pStartNode=0)
Definition: VFS.cc:338
virtual bool isCaseSensitive()
Definition: Filesystem.h:113
bool createFile(const String &path, uint32_t mask, File *pStartNode=0)
Definition: VFS.cc:312
bool m_bReadOnly
Definition: Filesystem.h:135
Definition: File.h:66