AppleWin/source/frontends/ncurses/resources.cpp
Andrea Odetti 40d3e822e9 Make resource interface based on "char *" as it is easier to detect a nullptr.
Can't change the return type to std::string.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
2020-07-07 20:13:26 +01:00

50 lines
972 B
C++

#include "StdAfx.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "Log.h"
HRSRC FindResource(void *, const char * filename, const char *)
{
HRSRC result;
if (filename)
{
const std::string path = std::string("resource/") + filename;
int fd = open(path.c_str(), O_RDONLY);
if (fd != -1)
{
struct stat stdbuf;
if ((fstat(fd, &stdbuf) == 0) && S_ISREG(stdbuf.st_mode))
{
const off_t size = stdbuf.st_size;
result.data.resize(size);
ssize_t rd = read(fd, result.data.data(), size);
}
close(fd);
}
}
if (result.data.empty())
{
LogFileOutput("FindResource: could not load resource %s\n", filename);
}
return result;
}
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename)
{
LogFileOutput("LoadBitmap: not loading resource %s\n", filename);
return nullptr;
}
LONG GetBitmapBits(HBITMAP hbit, LONG cb, LPVOID lpvBits)
{
memset(lpvBits, 0, cb);
return cb;
}