mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
add prefix_data()
This commit is contained in:
parent
a17800b034
commit
6f1bbf82d0
@ -1763,6 +1763,30 @@ typedef struct ncvisual_implementation {
|
||||
// populated by libnotcurses.so if linked with multimedia
|
||||
API extern ncvisual_implementation visual_implementation;
|
||||
|
||||
static inline char
|
||||
path_seperator(void){
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
return '\\';
|
||||
#else
|
||||
return '/';
|
||||
#endif
|
||||
}
|
||||
|
||||
// prepend base with the Notcurses data directory as configured.
|
||||
static inline char*
|
||||
prefix_data(const char* base){
|
||||
// need a byte for each of directory separator and nul terminator
|
||||
const size_t dlen = strlen(NOTCURSES_SHARE);
|
||||
size_t len = dlen + strlen(base) + 2;
|
||||
char* path = (char*)malloc(len); // cast for C++ includers
|
||||
if(path){
|
||||
memcpy(path, NOTCURSES_SHARE, dlen);
|
||||
path[dlen] = path_seperator();
|
||||
strcpy(path + dlen + 1, base);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
#undef ALLOC
|
||||
#undef API
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user