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
38class 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 */
Use a file as Storage provider.
Definition FileStorage.h:39
Size m_fd
File descriptor of the file.
Definition FileStorage.h:92
virtual FileSystem::Result initialize()
Initialize the Storage device.
Size m_offset
Offset used as a base for I/O.
FileSystem::FileStat m_stat
Status of the file for Storage I/O.
Definition FileStorage.h:98
virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const
Read a contiguous set of data.
FileSystemClient m_file
Client for file system I/O.
Definition FileStorage.h:95
const char * m_path
Path to the file.
Definition FileStorage.h:89
virtual FileSystem::Result write(const u64 offset, void *buffer, const Size size)
Write a contiguous set of data.
virtual u64 capacity() const
Retrieve maximum storage capacity.
FileSystemClient provides a simple interface to a FileSystemServer.
Provides a storage device to build filesystems on top.
Definition Storage.h:36
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
#define ZERO
Zero value.
Definition Macros.h:43
unsigned long long u64
Unsigned 64-bit number.
Definition Types.h:50
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Contains file information.
Definition FileSystem.h:114