Move FindResource to the interface as in QT it will be handled differently.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
ce124e0aa0
commit
0c37816c28
4 changed files with 44 additions and 31 deletions
|
@ -45,6 +45,7 @@ add_executable(applen
|
||||||
source/frontends/ncurses/asciiart.cpp
|
source/frontends/ncurses/asciiart.cpp
|
||||||
source/frontends/ncurses/input.cpp
|
source/frontends/ncurses/input.cpp
|
||||||
source/frontends/ncurses/benchmark.cpp
|
source/frontends/ncurses/benchmark.cpp
|
||||||
|
source/frontends/ncurses/resources.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(applen
|
target_link_libraries(applen
|
||||||
|
|
39
source/frontends/ncurses/resources.cpp
Normal file
39
source/frontends/ncurses/resources.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "StdAfx.h"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "Log.h"
|
||||||
|
#include "linux/wwrapper.h"
|
||||||
|
|
||||||
|
HRSRC FindResource(void *, const std::string & filename, const char *)
|
||||||
|
{
|
||||||
|
HRSRC result;
|
||||||
|
|
||||||
|
if (!filename.empty())
|
||||||
|
{
|
||||||
|
const std::string path = "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.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// Resources
|
||||||
|
|
||||||
|
HRSRC FindResource(void *, const std::string & filename, const char *);
|
||||||
|
|
||||||
// Frame
|
// Frame
|
||||||
|
|
||||||
void FrameDrawDiskLEDS(HDC x);
|
void FrameDrawDiskLEDS(HDC x);
|
||||||
|
|
|
@ -177,37 +177,6 @@ std::string MAKEINTRESOURCE(int x)
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRSRC FindResource(void *, const std::string & filename, const char *)
|
|
||||||
{
|
|
||||||
HRSRC result;
|
|
||||||
|
|
||||||
if (!filename.empty())
|
|
||||||
{
|
|
||||||
const std::string path = "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.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD SizeofResource(void *, const HRSRC & res)
|
DWORD SizeofResource(void *, const HRSRC & res)
|
||||||
{
|
{
|
||||||
return res.data.size();
|
return res.data.size();
|
||||||
|
|
Loading…
Add table
Reference in a new issue