summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-server/RemoteCode/FileReader.hpp
blob: 85e5770320f23ac45f35afa9b326dd18f5e527cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <fstream>
#include <cstdint>
#include <vector>
#include <iterator>

using ByteArray = std::vector< uint8_t >;

namespace RemoteCode
{
	class FileReader
	{
		// Contents of the file.
		ByteArray m_Contents;

	public:
		FileReader() = default;

		// Constructor (ignores exception-handling).
		FileReader(const char *FileName) { Start(FileName); }

		// Read a file.
		bool Start(const char *FileName);

		// Self-explanatory.
		size_t GetFileLength() { return m_Contents.size(); }

		// Allow the user to walk the data.
		operator uint8_t *() { return m_Contents.data(); }
	};
}