Commits (1)
  • Rob Swindell's avatar
    Init virtual sub-directory name for library sub-dirs · 73922630
    Rob Swindell authored
    When using the "Access to Sub-directories" option for a library, the auto-created directories did not have their virtual sub-directory name set. Pretty sure this was introduced along with the http access to filebases after v3.19b.
    
    Also, only de-dupe the sub-directory names based on the directory name and not the code/code-suffix for now. Next up: auto-gen unique internal code when needed.
    73922630
......@@ -123,6 +123,35 @@ BOOL load_cfg(scfg_t* cfg, char* text[], BOOL prep, BOOL req_node, char* error,
return(TRUE);
}
void pathify(char* str)
{
char* p;
if(strchr(str, '.') == NULL) {
REPLACE_CHARS(str, ' ', '.', p);
} else {
REPLACE_CHARS(str, ' ', '_', p);
}
REPLACE_CHARS(str, '\\', '-', p);
REPLACE_CHARS(str, '/', '-', p);
}
void init_vdir(scfg_t* cfg, dir_t* dir)
{
switch(cfg->lib[dir->lib]->vdir_name) {
case VDIR_NAME_SHORT:
SAFECOPY(dir->vdir, dir->sname);
break;
case VDIR_NAME_LONG:
SAFECOPY(dir->vdir, dir->lname);
break;
default:
SAFECOPY(dir->vdir, dir->code_suffix);
break;
}
pathify(dir->vdir);
}
/****************************************************************************/
/* Prepare configuration for run-time (resolve relative paths, etc) */
/****************************************************************************/
......@@ -192,9 +221,7 @@ void prep_cfg(scfg_t* cfg)
for(j = 0; j < cfg->total_dirs; j++) {
if(cfg->dir[j]->lib != i)
continue;
if(stricmp(cfg->dir[j]->code, dirname) == 0)
break;
if(stricmp(cfg->dir[j]->code_suffix, dirname) == 0)
if(stricmp(cfg->dir[j]->lname, dirname) == 0)
break;
}
if(j < cfg->total_dirs) // duplicate
......@@ -214,6 +241,7 @@ void prep_cfg(scfg_t* cfg)
SAFEPRINTF2(dir.code,"%s%s"
,cfg->lib[i]->code_prefix
,dir.code_suffix);
init_vdir(cfg, &dir);
dir_t** new_dirs;
if((new_dirs=(dir_t **)realloc(cfg->dir, sizeof(dir_t *)*(cfg->total_dirs+2)))==NULL)
......
......@@ -38,6 +38,8 @@ DLLEXPORT ushort sys_timezone(scfg_t* cfg);
DLLEXPORT char * prep_dir(const char* base, char* dir, size_t buflen);
DLLEXPORT char * prep_code(char *str, const char* prefix);
DLLEXPORT int md(const char *path);
DLLEXPORT void pathify(char*);
DLLEXPORT void init_vdir(scfg_t*, dir_t*);
DLLEXPORT int smb_storage_mode(scfg_t*, smb_t*);
DLLEXPORT int smb_open_sub(scfg_t*, smb_t*, unsigned int subnum);
DLLEXPORT BOOL smb_init_dir(scfg_t*, smb_t*, unsigned int dirnum);
......
......@@ -23,19 +23,6 @@
#include "nopen.h"
#include "ars_defs.h"
static void pathify(char* str)
{
char* p;
if(strchr(str, '.') == NULL) {
REPLACE_CHARS(str, ' ', '.', p);
} else {
REPLACE_CHARS(str, ' ', '_', p);
}
REPLACE_CHARS(str, '\\', '-', p);
REPLACE_CHARS(str, '/', '-', p);
}
/****************************************************************************/
/* Reads in FILE.CNF and initializes the associated variables */
/****************************************************************************/
......@@ -363,19 +350,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
cfg->lib[cfg->dir[i]->lib]->offline_dir=i;
get_str(cfg->dir[i]->code_suffix,instream);
switch(cfg->lib[cfg->dir[i]->lib]->vdir_name) {
case VDIR_NAME_SHORT:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->sname);
break;
case VDIR_NAME_LONG:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->lname);
break;
default:
SAFECOPY(cfg->dir[i]->vdir, cfg->dir[i]->code_suffix);
break;
}
pathify(cfg->dir[i]->vdir);
init_vdir(cfg, cfg->dir[i]);
get_str(cfg->dir[i]->data_dir,instream);
get_str(cfg->dir[i]->arstr,instream);
......