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
39typedef struct Dirent
40{
43
46}
48
59class 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 */
u8 type
Definition IntelACPI.h:0
Directory File functionality.
Definition Directory.h:60
virtual File * lookup(const char *name)
Retrieve a File from storage.
Definition Directory.cpp:61
void remove(const char *name)
Remove a directory entry.
Definition Directory.cpp:83
void clear()
Clears the internal list of entries.
Definition Directory.cpp:99
Dirent * get(const char *name)
Retrieve a directory entry by it's name.
List< Dirent * > entries
List of directory entries.
Definition Directory.h:176
void insert(FileSystem::FileType type, const char *name)
Insert a new directory entry.
Definition Directory.cpp:66
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read directory entries.
Definition Directory.cpp:38
virtual ~Directory()
Destructor.
Definition Directory.cpp:30
Represents a file present on a FileSystem.
Definition File.h:40
Abstract Input/Output buffer.
Definition IOBuffer.h:38
Simple linked list template class.
Definition List.h:37
#define DIRENT_LEN
Maximum length of a filename.
Definition Directory.h:34
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
FileType
All possible filetypes.
Definition FileSystem.h:71
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Describes an entry inside a Directory.
Definition Directory.h:40
FileSystem::FileType type
Type of file.
Definition Directory.h:45
char name[DIRENT_LEN]
Name of the file.
Definition Directory.h:42