mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 23:00:42 -07:00
Initial commit for GitHub migration based on spice2x-25-03-03
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include "resutils.h"
|
||||
#include "util/utils.h"
|
||||
|
||||
const char *resutil::load_file(int name, DWORD *size, LPCSTR type) {
|
||||
HMODULE handle = GetModuleHandle(NULL);
|
||||
HRSRC rc = FindResource(handle, MAKEINTRESOURCE(name), type);
|
||||
HGLOBAL rcData = LoadResource(handle, rc);
|
||||
if (size != nullptr)
|
||||
*size = SizeofResource(handle, rc);
|
||||
return static_cast<const char*>(LockResource(rcData));
|
||||
}
|
||||
|
||||
std::string resutil::load_file_string(int name, LPCSTR type) {
|
||||
DWORD size = 0;
|
||||
auto data = resutil::load_file(name, &size, type);
|
||||
return std::string(data, size);
|
||||
}
|
||||
|
||||
std::string resutil::load_file_string_crlf(int name, LPCSTR type) {
|
||||
std::string s = load_file_string(name, type);
|
||||
strreplace(s, "\n", "\r\n");
|
||||
return s;
|
||||
}
|
||||
Reference in New Issue
Block a user