mirror of
				https://github.com/hedge-dev/XenonRecomp.git
				synced 2025-10-30 07:11:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			545 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			545 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <filesystem>
 | |
| #include <fstream>
 | |
| #include <vector>
 | |
| 
 | |
| inline std::vector<uint8_t> LoadFile(const std::filesystem::path& path)
 | |
| {
 | |
|     std::ifstream stream(path, std::ios::binary);
 | |
|     if (!stream.is_open())
 | |
|     {
 | |
|         return {};
 | |
|     }
 | |
| 
 | |
|     stream.seekg(0, std::ios::end);
 | |
|     std::streampos size = stream.tellg();
 | |
|     stream.seekg(0, std::ios::beg);
 | |
| 
 | |
|     std::vector<uint8_t> data;
 | |
|     data.resize(size);
 | |
|     stream.read((char *)(data.data()), size);
 | |
|     if (stream.bad())
 | |
|     {
 | |
|         return {};
 | |
|     }
 | |
| 
 | |
|     return data;
 | |
| }
 | 
