FreeNOS
File.cpp
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#include <FreeNOS/User.h>
19#include "File.h"
20
21File::File(const u32 inode,
23 const UserID uid,
24 const GroupID gid)
25 : m_inode(inode)
26 , m_type(type)
27 , m_uid(uid)
28 , m_gid(gid)
29 , m_access(FileSystem::OwnerRWX)
30 , m_size(0)
31{
32}
33
35{
36}
37
39{
40 return m_inode;
41}
42
44{
45 return m_type;
46}
47
49 Size & size,
50 const Size offset)
51{
53}
54
56 Size & size,
57 const Size offset)
58{
60}
61
63{
64 st.type = m_type;
65 st.inode = m_inode;
66 st.access = m_access;
67 st.size = m_size;
68 st.userID = m_uid;
69 st.groupID = m_gid;
70
72}
73
74bool File::canRead() const
75{
76 return true;
77}
78
79bool File::canWrite() const
80{
81 return true;
82}
u8 type
Definition IntelACPI.h:0
FileSystem::FileModes m_access
Access permissions.
Definition File.h:145
File(const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
Constructor function.
Definition File.cpp:21
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
FileType
All possible filetypes.
Definition FileSystem.h:71
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Contains file information.
Definition FileSystem.h:114
UserID userID
< Size of the file in bytes.
Definition FileSystem.h:120
u32 inode
< File type.
Definition FileSystem.h:116
FileModes access
< Process identifier of filesystem
Definition FileSystem.h:118
Size size
< File access permission bits.
Definition FileSystem.h:119
GroupID groupID
< User identity.
Definition FileSystem.h:121