FreeNOS
File.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_FILE_H
19#define __LIB_LIBFS_FILE_H
20
21#include <Types.h>
22#include "FileSystemMessage.h"
23#include "FileSystem.h"
24#include "IOBuffer.h"
25
39class File
40{
41 public:
42
51 File(const u32 inode,
53 const UserID uid = ZERO,
54 const GroupID gid = ZERO);
55
59 virtual ~File();
60
66 u32 getInode() const;
67
74
85 virtual FileSystem::Result read(IOBuffer & buffer,
86 Size & size,
87 const Size offset);
88
99 virtual FileSystem::Result write(IOBuffer & buffer,
100 Size & size,
101 const Size offset);
102
111
119 virtual bool canRead() const;
120
128 virtual bool canWrite() const;
129
130 protected:
131
134
137
140
143
146
149};
150
156#endif /* __LIB_LIBFS_FILE_H */
u8 type
Definition IntelACPI.h:0
Represents a file present on a FileSystem.
Definition File.h:40
FileSystem::FileModes m_access
Access permissions.
Definition File.h:145
FileSystem::FileType getType() const
Retrieve our filetype.
Definition File.cpp:43
UserID m_uid
Owner of the file.
Definition File.h:139
u32 getInode() const
Get inode number.
Definition File.cpp:38
const u32 m_inode
Inode number.
Definition File.h:133
Size m_size
Size of the file, in bytes.
Definition File.h:148
virtual bool canRead() const
Check if the File has data ready for reading.
Definition File.cpp:74
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the file.
Definition File.cpp:55
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the file.
Definition File.cpp:48
virtual FileSystem::Result status(FileSystem::FileStat &st)
Retrieve file statistics.
Definition File.cpp:62
const FileSystem::FileType m_type
Type of this file.
Definition File.h:136
GroupID m_gid
Group of the file.
Definition File.h:142
virtual ~File()
Destructor function.
Definition File.cpp:34
virtual bool canWrite() const
Check if the File can be written to.
Definition File.cpp:79
Abstract Input/Output buffer.
Definition IOBuffer.h:38
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned short UserID
User Identity.
Definition Types.h:134
unsigned short GroupID
Group Identity.
Definition Types.h:137
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
#define ZERO
Zero value.
Definition Macros.h:43
FileType
All possible filetypes.
Definition FileSystem.h:71
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
u16 FileModes
Multiple FileMode values combined.
Definition FileSystem.h:108
Contains file information.
Definition FileSystem.h:114