Correct path to default NVR files on Linux

This commit is contained in:
SarahW 2021-06-03 20:36:30 +01:00
commit 5f772fdf70
4 changed files with 21 additions and 5 deletions

View file

@ -48,11 +48,7 @@ FILE *nvrfopen(char *fn, char *mode)
if (mode[0] == 'r') if (mode[0] == 'r')
{ {
strcpy(s, nvr_path); snprintf(s, 512, "%s%s", nvr_default_path, fn);
put_backslash(s);
strcat(s, "default");
put_backslash(s);
strcat(s, fn);
return fopen(s, mode); return fopen(s, mode);
} }
else else

View file

@ -25,6 +25,8 @@ char logs_path[512];
/* this is where screenshots as stored */ /* this is where screenshots as stored */
char screenshots_path[512]; char screenshots_path[512];
char nvr_default_path[512];
char get_path_separator() char get_path_separator()
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -129,6 +131,11 @@ void set_default_nvr_path(char *s)
set_nvr_path(s); set_nvr_path(s);
} }
static void set_default_nvr_default_path(char *s)
{
safe_strncpy(nvr_default_path, s, 512);
}
/* set the default logs path, this makes it permanent */ /* set the default logs path, this makes it permanent */
void set_default_logs_path(char *s) void set_default_logs_path(char *s)
{ {
@ -203,6 +210,7 @@ void paths_onconfigloaded()
void paths_init() void paths_init()
{ {
char s[512]; char s[512];
char base_path[512];
char *p; char *p;
get_pcem_path(pcem_path, 512); get_pcem_path(pcem_path, 512);
@ -221,6 +229,10 @@ void paths_init()
set_screenshots_path(s); set_screenshots_path(s);
set_logs_path(pcem_path); set_logs_path(pcem_path);
get_pcem_base_path(base_path, 512);
append_filename(s, base_path, "nvr/default/", 512);
set_default_nvr_default_path(s);
add_config_callback(paths_loadconfig, paths_saveconfig, paths_onconfigloaded); add_config_callback(paths_loadconfig, paths_saveconfig, paths_onconfigloaded);
} }

View file

@ -4,8 +4,10 @@ extern char configs_path[512];
extern char nvr_path[512]; extern char nvr_path[512];
extern char logs_path[512]; extern char logs_path[512];
extern char screenshots_path[512]; extern char screenshots_path[512];
extern char nvr_default_path[512];
void get_pcem_path(char *s, int size); void get_pcem_path(char *s, int size);
void get_pcem_base_path(char *s, int size);
char get_path_separator(); char get_path_separator();
void paths_init(); void paths_init();
int dir_exists(char* path); int dir_exists(char* path);

View file

@ -263,6 +263,12 @@ void get_pcem_path(char *s, int size)
#endif #endif
} }
void get_pcem_base_path(char *s, int size)
{
char* path = SDL_GetBasePath();
strcpy(s, path);
}
void set_window_title(const char *s) void set_window_title(const char *s)
{ {
sdl_set_window_title(s); sdl_set_window_title(s);