mirror of
				https://github.com/hedge-dev/XenonRecomp.git
				synced 2025-11-04 06:47:09 +00:00 
			
		
		
		
	Unicode support. (#2)
This commit is contained in:
		@@ -1,26 +1,28 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <filesystem>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline std::vector<uint8_t> LoadFile(const char* path)
 | 
					inline std::vector<uint8_t> LoadFile(const std::filesystem::path& path)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    std::vector<uint8_t> data{};
 | 
					    std::ifstream stream(path, std::ios::binary);
 | 
				
			||||||
    auto* stream = fopen(path, "rb");
 | 
					    if (!stream.is_open())
 | 
				
			||||||
    if (stream == nullptr)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return {};
 | 
					        return {};
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fseek(stream, 0, SEEK_END);
 | 
					    stream.seekg(0, std::ios::end);
 | 
				
			||||||
 | 
					    std::streampos size = stream.tellg();
 | 
				
			||||||
    const auto size = ftell(stream);
 | 
					    stream.seekg(0, std::ios::beg);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    fseek(stream, 0, SEEK_SET);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::vector<uint8_t> data;
 | 
				
			||||||
    data.resize(size);
 | 
					    data.resize(size);
 | 
				
			||||||
 | 
					    stream.read((char *)(data.data()), size);
 | 
				
			||||||
    fread(data.data(), 1, data.size(), stream);
 | 
					    if (stream.bad())
 | 
				
			||||||
    fclose(stream);
 | 
					    {
 | 
				
			||||||
 | 
					        return {};
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return data;
 | 
					    return data;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user