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 
21 File::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 
71  return FileSystem::Success;
72 }
73 
74 bool File::canRead() const
75 {
76  return true;
77 }
78 
79 bool File::canWrite() const
80 {
81  return true;
82 }
File::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the file.
Definition: File.cpp:55
File::canRead
virtual bool canRead() const
Check if the File has data ready for reading.
Definition: File.cpp:74
File::~File
virtual ~File()
Destructor function.
Definition: File.cpp:34
FileSystem::FileType
FileType
All possible filetypes.
Definition: FileSystem.h:70
GroupID
unsigned short GroupID
Group Identity.
Definition: Types.h:137
FileSystem::FileStat::inode
u32 inode
< File type.
Definition: FileSystem.h:116
File::getType
FileSystem::FileType getType() const
Retrieve our filetype.
Definition: File.cpp:43
FileSystem::FileStat::access
FileModes access
< Process identifier of filesystem
Definition: FileSystem.h:118
FileSystem::Success
@ Success
Definition: FileSystem.h:54
File::getInode
u32 getInode() const
Get inode number.
Definition: File.cpp:38
File::m_type
const FileSystem::FileType m_type
Type of this file.
Definition: File.h:136
FileSystem::FileStat::groupID
GroupID groupID
< User identity.
Definition: FileSystem.h:121
FileSystem::FileStat::type
FileType type
Definition: FileSystem.h:115
FileSystem::NotSupported
@ NotSupported
Definition: FileSystem.h:61
File::m_access
FileSystem::FileModes m_access
Access permissions.
Definition: File.h:145
FileSystem::FileStat::size
Size size
< File access permission bits.
Definition: FileSystem.h:119
File::m_size
Size m_size
Size of the file, in bytes.
Definition: File.h:148
FileSystem::FileStat::userID
UserID userID
< Size of the file in bytes.
Definition: FileSystem.h:120
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
File::m_uid
UserID m_uid
Owner of the file.
Definition: File.h:139
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
File::status
virtual FileSystem::Result status(FileSystem::FileStat &st)
Retrieve file statistics.
Definition: File.cpp:62
File::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the file.
Definition: File.cpp:48
File::m_inode
const u32 m_inode
Inode number.
Definition: File.h:133
UserID
unsigned short UserID
User Identity.
Definition: Types.h:134
FileSystem::FileStat
Contains file information.
Definition: FileSystem.h:113
File::m_gid
GroupID m_gid
Group of the file.
Definition: File.h:142
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
FileSystem
Definition: FileSystem.h:31
File::canWrite
virtual bool canWrite() const
Check if the File can be written to.
Definition: File.cpp:79
type
u8 type
Definition: IntelACPI.h:63
File::File
File(const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
Constructor function.
Definition: File.cpp:21
File.h
FileSystem::OwnerRWX
@ OwnerRWX
Definition: FileSystem.h:92