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