Melon
A C++ library designed for RadishOS.
Toggle main menu visibility
Loading...
Searching...
No Matches
File.hpp
1
#pragma once
2
3
#include "../../String.hpp"
4
#include "../Memory/Buffer.hpp"
5
6
#include <stdio.h>
7
8
namespace
Melon::FileSystem
9
{
11
enum class
SeekOrigin
12
{
13
Begin
= SEEK_SET,
14
Curr
= SEEK_CUR,
15
End
= SEEK_END
16
};
17
19
class
File
20
{
21
FILE *stream;
22
23
public
:
27
File
(
const
String::String
&path,
const
String::String
&modes);
28
31
File
(FILE *stream);
32
34
~File
();
35
37
void
close
(
this
File
&self);
38
42
Memory::Buffer<char>
readBytes
(
this
File
&self,
Typing::USize
bytes);
43
46
Memory::Buffer<char>
read
(
this
File
&self);
47
53
String::String
readLine
(
this
File
&self,
Typing::USize
lineno);
54
57
int
descriptor
(
this
const
File
&self);
58
62
void
seek
(
this
File
&self,
long
offset,
SeekOrigin
origin);
63
67
void
write
(
this
File
&self,
const
Memory::Buffer<char>
&buf,
Typing::USize
bytes);
68
73
bool
isOpen
(
this
const
File
&self);
74
};
75
}
// namespace Melon::FileSystem
Melon::FileSystem::File::descriptor
int descriptor(this const File &self)
Gets the file descriptor of this stream.
Definition
File.cpp:88
Melon::FileSystem::File::read
Memory::Buffer< char > read(this File &self)
Read until EOF.
Definition
File.cpp:51
Melon::FileSystem::File::close
void close(this File &self)
Close the file if it is open.
Definition
File.cpp:32
Melon::FileSystem::File::File
File(const String::String &path, const String::String &modes)
Open constructor.
Definition
File.cpp:13
Melon::FileSystem::File::seek
void seek(this File &self, long offset, SeekOrigin origin)
Seek to a certain position in the file.
Definition
File.cpp:93
Melon::FileSystem::File::readLine
String::String readLine(this File &self, Typing::USize lineno)
Read a line from the file.
Definition
File.cpp:64
Melon::FileSystem::File::isOpen
bool isOpen(this const File &self)
Checks if the file is open.
Definition
File.cpp:103
Melon::FileSystem::File::write
void write(this File &self, const Memory::Buffer< char > &buf, Typing::USize bytes)
Write bytes to a file.
Definition
File.cpp:98
Melon::FileSystem::File::readBytes
Memory::Buffer< char > readBytes(this File &self, Typing::USize bytes)
Read bytes from the file.
Definition
File.cpp:40
Melon::Memory::Buffer
Container for raw memory.
Definition
Buffer.hpp:18
Melon::String::String
A dynamic string.
Definition
String.hpp:11
Melon::FileSystem
Contains functions and classes to interact with the filesystem.
Definition
FileSystem.hpp:5
Melon::FileSystem::SeekOrigin
SeekOrigin
All possible values for File::seek().
Definition
File.hpp:12
Melon::FileSystem::SeekOrigin::Begin
@ Begin
Beginning of the file.
Definition
File.hpp:13
Melon::FileSystem::SeekOrigin::Curr
@ Curr
Current cursor position.
Definition
File.hpp:14
Melon::FileSystem::SeekOrigin::End
@ End
End of the file.
Definition
File.hpp:15
Melon::Typing::USize
size_t USize
Biggest unsigned type.
Definition
Typing.hpp:38
Include
Internal
FileSystem
File.hpp
Generated by
1.18.0