FreeNOS
Directory.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBFS_DIRECTORY_H
19 #define __LIB_LIBFS_DIRECTORY_H
20 
21 #include <List.h>
22 #include "FileSystem.h"
23 #include "File.h"
24 
34 #define DIRENT_LEN 64
35 
39 typedef struct Dirent
40 {
43 
46 }
47 Dirent;
48 
59 class Directory : public File
60 {
61  public:
62 
68  Directory(const u32 inode);
69 
73  virtual ~Directory();
74 
95  virtual FileSystem::Result read(IOBuffer & buffer,
96  Size & size,
97  const Size offset);
98 
115  virtual File * lookup(const char *name);
116 
131  void insert(FileSystem::FileType type, const char *name);
132 
145  void remove(const char *name);
146 
150  void clear();
151 
152  private:
153 
161  Dirent * get(const char *name);
162 
163  private:
164 
177 };
178 
184 #endif /* __LIB_LIBFS_DIRECTORY_H */
FileSystem.h
Dirent::name
char name[DIRENT_LEN]
Name of the file.
Definition: Directory.h:42
Directory::lookup
virtual File * lookup(const char *name)
Retrieve a File from storage.
Definition: Directory.cpp:61
FileSystem::FileType
FileType
All possible filetypes.
Definition: FileSystem.h:70
Dirent
struct Dirent Dirent
Describes an entry inside a Directory.
Directory
Directory File functionality.
Definition: Directory.h:59
Directory::insert
void insert(FileSystem::FileType type, const char *name)
Insert a new directory entry.
Definition: Directory.cpp:66
Directory::get
Dirent * get(const char *name)
Retrieve a directory entry by it's name.
Definition: Directory.cpp:107
Directory::~Directory
virtual ~Directory()
Destructor.
Definition: Directory.cpp:30
File
Represents a file present on a FileSystem.
Definition: File.h:39
Directory::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read directory entries.
Definition: Directory.cpp:38
Dirent::type
FileSystem::FileType type
Type of file.
Definition: Directory.h:45
Directory::Directory
Directory(const u32 inode)
Constructor.
Definition: Directory.cpp:23
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
Directory::entries
List< Dirent * > entries
List of directory entries.
Definition: Directory.h:176
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
Directory::clear
void clear()
Clears the internal list of entries.
Definition: Directory.cpp:99
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
List< Dirent * >
DIRENT_LEN
#define DIRENT_LEN
Maximum length of a filename.
Definition: Directory.h:34
type
u8 type
Definition: IntelACPI.h:63
Dirent
Describes an entry inside a Directory.
Definition: Directory.h:39
File.h
Directory::remove
void remove(const char *name)
Remove a directory entry.
Definition: Directory.cpp:83
List.h