Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::filesystem::File Class Reference

Handles file operations and information. More...

#include <filesystem.h>

Inheritance diagram for MaxOS::filesystem::File:
MaxOS::filesystem::format::Fat32File MaxOS::filesystem::format::ext2::Ext2File

Public Member Functions

virtual void write (common::buffer_t *data, size_t size)
 write data to the file
 
virtual void read (common::buffer_t *data, size_t size)
 read data from the file
 
virtual void flush ()
 Flush the file to the disk.
 
void seek (SeekType seek_type, size_t offset)
 Seek to a position in the file.
 
uint32_t position () const
 Get where the file is currently at (amount read/write/seeked)
 
size_t size () const
 Get the size of the file.
 
string name ()
 Get the name of the file.
 

Protected Attributes

uint32_t m_offset = 0
 The current offset in the file.
 
string m_name
 The name of the file.
 
size_t m_size = 0
 The size of the file.
 

Detailed Description

Handles file operations and information.

Definition at line 31 of file filesystem.h.

Member Function Documentation

◆ flush()

void File::flush ( )
virtual

◆ name()

string File::name ( )

Get the name of the file.

Returns
The name of the file

Definition at line 82 of file filesystem.cpp.

82 {
83 return m_name;
84}
string m_name
The name of the file.
Definition filesystem.h:35

References m_name.

Referenced by MaxOS::filesystem::format::ext2::Ext2File::Ext2File(), MaxOS::filesystem::format::Fat32File::Fat32File(), and MaxOS::filesystem::Directory::rename_file().

◆ position()

uint32_t File::position ( ) const

Get where the file is currently at (amount read/write/seeked)

Returns
The current position in the file

Definition at line 73 of file filesystem.cpp.

73 {
74 return m_offset;
75}
uint32_t m_offset
The current offset in the file.
Definition filesystem.h:34

References m_offset.

Referenced by MaxOS::filesystem::FileResource::read().

◆ read()

void File::read ( common::buffer_t data,
size_t  amount 
)
virtual

read data from the file

Parameters
dataThe byte buffer to read into
amountThe amount of data to read

Reimplemented in MaxOS::filesystem::format::ext2::Ext2File, and MaxOS::filesystem::format::Fat32File.

Definition at line 35 of file filesystem.cpp.

35 {
36}

Referenced by MaxOS::filesystem::FileResource::read().

◆ seek()

void File::seek ( SeekType  seek_type,
size_t  offset 
)

Seek to a position in the file.

Parameters
seek_typeThe type of seek to perform (where to seek to)
offsetThe amount to seek

Definition at line 50 of file filesystem.cpp.

50 {
51
52 // Seek based on the type
53 switch (seek_type) {
54 case SeekType::SET:
55 m_offset = offset;
56 break;
57
58 case SeekType::CURRENT:
59 m_offset += offset;
60 break;
61
62 case SeekType::END:
63 m_offset = size() - offset;
64 break;
65 }
66}
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
size_t size() const
Get the size of the file.

References m_offset, and size().

Referenced by MaxOS::filesystem::FileResource::write().

◆ size()

size_t File::size ( ) const

Get the size of the file.

Returns
The size of the file (in bytes)

Definition at line 91 of file filesystem.cpp.

91 {
92 return m_size;
93}
size_t m_size
The size of the file.
Definition filesystem.h:36

References m_size.

Referenced by MaxOS::filesystem::FileResource::read(), and seek().

◆ write()

void File::write ( common::buffer_t data,
size_t  amount 
)
virtual

write data to the file

Parameters
dataThe byte buffer to write
amountThe amount of data to write

Reimplemented in MaxOS::filesystem::format::ext2::Ext2File, and MaxOS::filesystem::format::Fat32File.

Definition at line 26 of file filesystem.cpp.

26 {
27}

Referenced by MaxOS::filesystem::FileResource::write().

Member Data Documentation

◆ m_name

string MaxOS::filesystem::File::m_name
protected

◆ m_offset

◆ m_size


The documentation for this class was generated from the following files: