Melon
A C++ library designed for RadishOS.
Loading...
Searching...
No Matches
Melon::FileSystem::File Class Reference

Representation of a file stream. More...

#include <File.hpp>

Public Member Functions

 File (const String::String &path, const String::String &modes)
 Open constructor.
 File (FILE *stream)
 Constructs the object from an existing stream.
 ~File ()
 Destructor.
void close (this File &self)
 Close the file if it is open.
Memory::Buffer< char > readBytes (this File &self, Typing::USize bytes)
 Read bytes from the file.
Memory::Buffer< char > read (this File &self)
 Read until EOF.
String::String readLine (this File &self, Typing::USize lineno)
 Read a line from the file.
int descriptor (this const File &self)
 Gets the file descriptor of this stream.
void seek (this File &self, long offset, SeekOrigin origin)
 Seek to a certain position in the file.
void write (this File &self, const Memory::Buffer< char > &buf, Typing::USize bytes)
 Write bytes to a file.
bool isOpen (this const File &self)
 Checks if the file is open.

Detailed Description

Representation of a file stream.

Constructor & Destructor Documentation

◆ File() [1/2]

Melon::FileSystem::File::File ( const String::String & path,
const String::String & modes )

Open constructor.

Parameters
pathpath to the file
modesopen modes

◆ File() [2/2]

Melon::FileSystem::File::File ( FILE * stream)

Constructs the object from an existing stream.

Parameters
streambase stream

Member Function Documentation

◆ descriptor()

int Melon::FileSystem::File::descriptor ( this const File & self)

Gets the file descriptor of this stream.

Returns
file descriptor

◆ isOpen()

bool Melon::FileSystem::File::isOpen ( this const File & self)

Checks if the file is open.

If the stream is not null, then it is considered as open.

Returns
boolean

◆ read()

Memory::Buffer< char > Melon::FileSystem::File::read ( this File & self)

Read until EOF.

Returns
buffer containing the read bytes

◆ readBytes()

Memory::Buffer< char > Melon::FileSystem::File::readBytes ( this File & self,
Typing::USize bytes )

Read bytes from the file.

Parameters
bytesbytes count
Returns
buffer containing the read bytes

◆ readLine()

String::String Melon::FileSystem::File::readLine ( this File & self,
Typing::USize lineno )

Read a line from the file.

The \n is not preserved.

Parameters
lineno0-based line number
Returns
string containing the line

◆ seek()

void Melon::FileSystem::File::seek ( this File & self,
long offset,
SeekOrigin origin )

Seek to a certain position in the file.

Parameters
offsetoffset from origin
originseek from here

◆ write()

void Melon::FileSystem::File::write ( this File & self,
const Memory::Buffer< char > & buf,
Typing::USize bytes )

Write bytes to a file.

Parameters
bufbytes to write
bytesbyte count

The documentation for this class was generated from the following files:
  • Include/Internal/FileSystem/File.hpp
  • Source/FileSystem/File.cpp