FreeNOS
FileStorage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 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 __FILESYSTEM_FILESTORAGE_H
19 #define __FILESYSTEM_FILESTORAGE_H
20 
21 #include <Types.h>
22 #include "FileSystemClient.h"
23 #include "Storage.h"
24 
38 class FileStorage : public Storage
39 {
40  public:
41 
48  FileStorage(const char *path, Size offset = ZERO);
49 
56 
66  virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const;
67 
77  virtual FileSystem::Result write(const u64 offset, void *buffer, const Size size);
78 
84  virtual u64 capacity() const;
85 
86  private:
87 
89  const char *m_path;
90 
93 
96 
99 
102 };
103 
109 #endif /* __FILESYSTEM_STORAGE_H */
FileStorage::read
virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const
Read a contiguous set of data.
Definition: FileStorage.cpp:39
Types.h
FileSystemClient
FileSystemClient provides a simple interface to a FileSystemServer.
Definition: FileSystemClient.h:42
Storage.h
FileStorage::FileStorage
FileStorage(const char *path, Size offset=ZERO)
Constructor function.
Definition: FileStorage.cpp:21
FileStorage::initialize
virtual FileSystem::Result initialize()
Initialize the Storage device.
Definition: FileStorage.cpp:28
FileStorage::m_fd
Size m_fd
File descriptor of the file.
Definition: FileStorage.h:92
u64
unsigned long long u64
Unsigned 64-bit number.
Definition: Types.h:50
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
FileStorage::capacity
virtual u64 capacity() const
Retrieve maximum storage capacity.
Definition: FileStorage.cpp:71
FileStorage::m_stat
FileSystem::FileStat m_stat
Status of the file for Storage I/O.
Definition: FileStorage.h:98
FileStorage::m_path
const char * m_path
Path to the file.
Definition: FileStorage.h:89
FileStorage::write
virtual FileSystem::Result write(const u64 offset, void *buffer, const Size size)
Write a contiguous set of data.
Definition: FileStorage.cpp:55
FileStorage::m_file
FileSystemClient m_file
Client for file system I/O.
Definition: FileStorage.h:95
FileStorage
Use a file as Storage provider.
Definition: FileStorage.h:38
FileSystemClient.h
FileSystem::FileStat
Contains file information.
Definition: FileSystem.h:113
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
FileStorage::m_offset
Size m_offset
Offset used as a base for I/O.
Definition: FileStorage.h:101
ZERO
#define ZERO
Zero value.
Definition: Macros.h:43
Storage
Provides a storage device to build filesystems on top.
Definition: Storage.h:35