Skip to content
Snippets Groups Projects
Commit bd320417 authored by rswindell's avatar rswindell
Browse files

Created getfilepath() function return full path of file_t reference.

parent 1acc0255
No related branches found
No related tags found
No related merge requests found
......@@ -629,10 +629,7 @@ void synclist(char *inpath, int dirnum)
continue;
}
removefiledat(&scfg,&f);
sprintf(str,"%s%s"
,f.altpath>0 && f.altpath<=scfg.altpaths ? scfg.altpath[f.altpath-1]
: scfg.dir[f.dir]->path,fname);
if(remove(str))
if(remove(getfilepath(&scfg,&f,str))
printf("Error removing %s\n",str);
removed++;
printf("Removed from database\n");
......
......@@ -42,9 +42,10 @@
/****************************************************************************/
void sbbs_t::fileinfo(file_t* f)
{
char fname[13],ext[513];
char ext[513];
char tmp[512];
char path[MAX_PATH+1];
char fpath[MAX_PATH+1];
uint i,j;
for(i=0;i<usrlibs;i++)
......@@ -54,29 +55,14 @@ void sbbs_t::fileinfo(file_t* f)
if(usrdir[i][j]==f->dir)
break;
unpadfname(f->name,fname);
sprintf(path,"%s%s",f->altpath>0 && f->altpath<=cfg.altpaths
? cfg.altpath[f->altpath-1]:cfg.dir[f->dir]->path
,fname);
getfilepath(&cfg,f,path);
bprintf(text[FiLib],i+1,cfg.lib[cfg.dir[f->dir]->lib]->lname);
bprintf(text[FiDir],j+1,cfg.dir[f->dir]->lname);
bprintf(text[FiFilename],fname);
#ifdef _WIN32
if(f->size!=-1) {
WIN32_FIND_DATA finddata;
HANDLE h=FindFirstFile(path,&finddata);
if(h!=INVALID_HANDLE_VALUE) {
if(stricmp(finddata.cFileName,fname))
bprintf(text[FiFilename],finddata.cFileName);
FindClose(h);
}
}
#endif
bprintf(text[FiFilename],getfname(path));
SAFECOPY(fpath,path);
fexistcase(fpath);
if(strcmp(path,fpath)) /* Different "actual" filename */
bprintf(text[FiFilename],getfname(fpath));
if(f->size!=-1L)
bprintf(text[FiFileSize],ultoac(f->size,tmp));
......@@ -94,9 +80,11 @@ void sbbs_t::fileinfo(file_t* f)
if(f->altpath) {
if(f->altpath<=cfg.altpaths) {
if(SYSOP)
bprintf(text[FiAlternatePath],cfg.altpath[f->altpath-1]); }
bprintf(text[FiAlternatePath],cfg.altpath[f->altpath-1]);
}
else
bprintf(text[InvalidAlternatePathN],f->altpath); }
bprintf(text[InvalidAlternatePathN],f->altpath);
}
CRLF;
if(f->misc&FM_EXTDESC) {
getextdesc(&cfg,f->dir,f->datoffset,ext);
......
......@@ -44,7 +44,7 @@
/****************************************************************************/
BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
{
char buf[F_LEN+1],str[256],tmp[128];
char buf[F_LEN+1],str[256];
int file;
long length;
......@@ -73,9 +73,7 @@ BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
f->cdt=atol(str);
if(!f->size) { /* only read disk if this is null */
sprintf(str,"%s%s"
,f->altpath>0 && f->altpath<=cfg->altpaths ? cfg->altpath[f->altpath-1]
: cfg->dir[f->dir]->path,unpadfname(f->name,tmp));
getfilepath(cfg,f,str);
f->size=flength(str);
f->date=fdate(str);
/*
......@@ -655,3 +653,18 @@ int DLLCALL update_uldate(scfg_t* cfg, file_t* f)
close(file);
return(0);
}
/****************************************************************************/
/* Returns full path to specified file */
/****************************************************************************/
char* DLLCALL getfilepath(scfg_t* cfg, file_t* f, char* path)
{
char fname[MAX_PATH+1];
unpadfname(f->name,fname);
sprintf(path,"%s%s",f->altpath>0 && f->altpath<=cfg->altpaths
? cfg->altpath[f->altpath-1] : cfg->dir[f->dir]->path
,fname);
return(path);
}
......@@ -782,6 +782,7 @@ extern "C" {
DLLEXPORT BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT void DLLCALL putextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext);
DLLEXPORT void DLLCALL getextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext);
DLLEXPORT char* DLLCALL getfilepath(scfg_t* cfg, file_t* f, char* path);
DLLEXPORT BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment