FreeNOS
|
Directory File functionality. More...
#include <Directory.h>
Public Member Functions | |
Directory (const u32 inode) | |
Constructor. More... | |
virtual | ~Directory () |
Destructor. More... | |
virtual FileSystem::Result | read (IOBuffer &buffer, Size &size, const Size offset) |
Read directory entries. More... | |
virtual File * | lookup (const char *name) |
Retrieve a File from storage. More... | |
void | insert (FileSystem::FileType type, const char *name) |
Insert a new directory entry. More... | |
void | remove (const char *name) |
Remove a directory entry. More... | |
void | clear () |
Clears the internal list of entries. More... | |
Public Member Functions inherited from File | |
File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO) | |
Constructor function. More... | |
virtual | ~File () |
Destructor function. More... | |
u32 | getInode () const |
Get inode number. More... | |
FileSystem::FileType | getType () const |
Retrieve our filetype. More... | |
virtual FileSystem::Result | write (IOBuffer &buffer, Size &size, const Size offset) |
Write bytes to the file. More... | |
virtual FileSystem::Result | status (FileSystem::FileStat &st) |
Retrieve file statistics. More... | |
virtual bool | canRead () const |
Check if the File has data ready for reading. More... | |
virtual bool | canWrite () const |
Check if the File can be written to. More... | |
Private Member Functions | |
Dirent * | get (const char *name) |
Retrieve a directory entry by it's name. More... | |
Private Attributes | |
List< Dirent * > | entries |
List of directory entries. More... | |
Additional Inherited Members | |
Protected Attributes inherited from File | |
const u32 | m_inode |
Inode number. More... | |
const FileSystem::FileType | m_type |
Type of this file. More... | |
UserID | m_uid |
Owner of the file. More... | |
GroupID | m_gid |
Group of the file. More... | |
FileSystem::FileModes | m_access |
Access permissions. More... | |
Size | m_size |
Size of the file, in bytes. More... | |
A Directory is a File which may have several child File's. Each child File which also is a Directory, may in turn have child File's. This way, a FileSystem can form a tree of File's and Directories.
Definition at line 59 of file Directory.h.
Directory::Directory | ( | const u32 | inode | ) |
Constructor.
inode | Inode number for this Directory |
Definition at line 23 of file Directory.cpp.
References FileSystem::DirectoryFile, and insert().
|
virtual |
Destructor.
Definition at line 30 of file Directory.cpp.
References List< T >::clear(), entries, and ListIterator< T >::hasCurrent().
void Directory::clear | ( | ) |
Clears the internal list of entries.
Definition at line 99 of file Directory.cpp.
References List< T >::clear(), entries, and ListIterator< T >::hasCurrent().
|
private |
Retrieve a directory entry by it's name.
name | Name of the entry to get. |
Definition at line 107 of file Directory.cpp.
References String::compareTo(), entries, ListIterator< T >::hasCurrent(), and ZERO.
Referenced by insert().
void Directory::insert | ( | FileSystem::FileType | type, |
const char * | name | ||
) |
Insert a new directory entry.
FileSystem implementations should implement this function to insert a new implementation defined directory entry into the underlying Storage.
type | File type. |
name | Name of the entry to add. |
Definition at line 66 of file Directory.cpp.
References List< T >::append(), assert, MemoryBlock::copy(), DIRENT_LEN, entries, get(), File::m_size, Dirent::name, NULL, Dirent::type, and type.
Referenced by Directory(), and FileSystemServer::registerFile().
|
virtual |
Retrieve a File from storage.
This virtual function is responsible for reading a directory entry from storage which is not already in the FileCache. It creates a File object for the directory entry and returns a pointer to it, if found.
name | Name of the directory entry to lookup. |
Reimplemented in LinnDirectory.
Definition at line 61 of file Directory.cpp.
References ZERO.
Referenced by FileSystemServer::lookupFile().
|
virtual |
Read directory entries.
This default read implementation reads the private List of Dirent entries from memory. It can be usefull for pseudo filesystems which don't have any real data on Storage. Filesystem that do have date on Storage should implement their version of read().
buffer | Input/Output buffer to output bytes to. |
size | Maximum number of bytes to read on input. On output, the actual number of bytes read. |
offset | Offset inside the file to start reading. |
Reimplemented from File.
Reimplemented in LinnDirectory.
Definition at line 38 of file Directory.cpp.
References entries, ListIterator< T >::hasCurrent(), FileSystem::Success, and IOBuffer::write().
void Directory::remove | ( | const char * | name | ) |
Remove a directory entry.
A FileSystem implemenatation should lookup the internal entry for the given name, and update the underlying Storage to remove any references for it inside this Directory.
name | Name of the entry to remove. |
Definition at line 83 of file Directory.cpp.
References String::compareTo(), entries, ListIterator< T >::hasCurrent(), and File::m_size.