mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
notcurses_data_path: allow overrides
This commit is contained in:
parent
16c9e9f101
commit
b57d6eb8d8
@ -119,20 +119,25 @@ int clock_nanosleep(clockid_t clockid, int flags,
|
||||
const struct timespec *request,
|
||||
struct timespec *remain);
|
||||
|
||||
__attribute__ ((nonnull (2))) __attribute__ ((malloc))
|
||||
static inline char*
|
||||
notcurses_data_path(const char* f){
|
||||
char* datadir = notcurses_data_dir();
|
||||
if(datadir == NULL){
|
||||
return NULL;
|
||||
notcurses_data_path(const char* ddir, const char* f){
|
||||
char* datadir = NULL;
|
||||
if(ddir == NULL){
|
||||
datadir = notcurses_data_dir();
|
||||
if(datadir == NULL){
|
||||
return NULL;
|
||||
}
|
||||
ddir = datadir;
|
||||
}
|
||||
const size_t dlen = strlen(datadir);
|
||||
const size_t dlen = strlen(ddir);
|
||||
// cast is for benefit of c++ callers, sigh
|
||||
char* path = (char*)malloc(dlen + 1 + strlen(f) + 1);
|
||||
if(path == NULL){
|
||||
free(datadir);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(path, datadir);
|
||||
strcpy(path, ddir);
|
||||
free(datadir);
|
||||
path[dlen] = path_separator();
|
||||
strcpy(path + dlen + 1, f);
|
||||
|
@ -44,7 +44,7 @@ const demoresult* demoresult_lookup(int idx){
|
||||
}
|
||||
|
||||
char* find_data(const char* datum){
|
||||
return notcurses_data_path(datum);
|
||||
return notcurses_data_path(datadir, datum);
|
||||
}
|
||||
|
||||
float delaymultiplier = 1;
|
||||
@ -510,7 +510,6 @@ int main(int argc, char** argv){
|
||||
sigaddset(&sigmask, SIGWINCH);
|
||||
pthread_sigmask(SIG_BLOCK, &sigmask, NULL);
|
||||
#endif
|
||||
datadir = notcurses_data_dir();
|
||||
const char* spec;
|
||||
FILE* json = NULL; // emit JSON summary to this file? (-J)
|
||||
notcurses_options nopts = {};
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
std::mutex ncmtx;
|
||||
|
||||
const std::string BackgroundFile = notcurses_data_path("tetris-background.jpg");
|
||||
const std::string LogoFile = notcurses_data_path("notcurses.png");
|
||||
const std::string BackgroundFile = notcurses_data_path(nullptr, "tetris-background.jpg");
|
||||
const std::string LogoFile = notcurses_data_path(nullptr, "notcurses.png");
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user