PixelBullet
0.0.1
A C++ game engine
Loading...
Searching...
No Matches
engine
src
PixelBullet
Filesystem
File.hpp
1
#pragma once
2
3
#include "PixelBullet/Filesystem/VirtualPath.hpp"
4
5
#include <fstream>
6
#include <iterator>
7
#include <optional>
8
#include <sstream>
9
#include <string>
10
#include <vector>
11
12
namespace
PixelBullet
13
{
14
15
class
File
16
{
17
public
:
18
static
std::optional<std::string> Read(
const
VirtualPath
& path)
19
{
20
std::ifstream file(std::string(path), std::ios::binary);
21
if
(!file)
22
{
23
return
std::nullopt;
24
}
25
std::stringstream buffer;
26
buffer << file.rdbuf();
27
return
buffer.str();
28
}
29
32
static
std::vector<unsigned char>
ReadBytes
(
const
VirtualPath
& path)
33
{
34
std::ifstream file(std::string(path), std::ios::binary);
35
if
(!file)
36
{
37
return
{};
38
}
39
return
std::vector<unsigned char>(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
40
}
41
};
42
}
// namespace PixelBullet
PixelBullet::File
Definition
File.hpp:16
PixelBullet::File::ReadBytes
static std::vector< unsigned char > ReadBytes(const VirtualPath &path)
Definition
File.hpp:32
PixelBullet::VirtualPath
Definition
VirtualPath.hpp:11
Generated by
1.12.0