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

Moved update_uldate() from upload.cpp to filedat.c (dll exported now).

parent 38240f1a
No related branches found
No related tags found
No related merge requests found
......@@ -655,3 +655,50 @@ void DLLCALL putextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext)
write(file,ext,F_EXBSIZE);
close(file);
}
/****************************************************************************/
/* Update the upload date for the file 'f' */
/****************************************************************************/
int DLLCALL update_uldate(scfg_t* cfg, file_t* f)
{
char str[256],fname[13];
int i,file;
long l,length;
/*******************/
/* Update IXB File */
/*******************/
sprintf(str,"%s%s.ixb",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
if((file=nopen(str,O_RDWR))==-1)
return(errno);
length=filelength(file);
if(length%F_IXBSIZE) {
close(file);
return(-1);
}
strcpy(fname,f->name);
for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[i]=fname[i+1];
for(l=0;l<length;l+=F_IXBSIZE) {
read(file,str,F_IXBSIZE); /* Look for the filename in the IXB file */
str[11]=0;
if(!strcmp(fname,str)) break; }
if(l>=length) {
close(file);
return(-2);
}
lseek(file,l+14,SEEK_SET);
write(file,&f->dateuled,4);
close(file);
/*******************************************/
/* Update last upload date/time stamp file */
/*******************************************/
sprintf(str,"%s%s.dab",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
return(errno);
write(file,&f->dateuled,4);
close(file);
return(0);
}
......@@ -567,7 +567,6 @@ public:
char sbbsfilename[128],sbbsfiledesc[128]; /* env vars */
bool upload(uint dirnum);
char upload_lastdesc[LEN_FDESC+1];
void update_uldate(file_t* f);
bool bulkupload(uint dirnum);
/* download.cpp */
......@@ -771,6 +770,7 @@ extern "C" {
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
DLLEXPORT long DLLCALL getfiles(scfg_t* cfg, uint dirnum);
DLLEXPORT int DLLCALL update_uldate(scfg_t* cfg, file_t* f);
/* str_util.c */
DLLEXPORT void DLLCALL truncsp(char *str); /* Truncates white spaces off end of str */
......
......@@ -216,55 +216,6 @@ bool sbbs_t::uploadfile(file_t *f)
return(true);
}
/****************************************************************************/
/* Update the upload date for the file 'f' */
/****************************************************************************/
void sbbs_t::update_uldate(file_t* f)
{
char str[256],fname[13];
int i,file;
long l,length;
/*******************/
/* Update IXB File */
/*******************/
sprintf(str,"%s%s.ixb",cfg.dir[f->dir]->data_dir,cfg.dir[f->dir]->code);
if((file=nopen(str,O_RDWR))==-1) {
errormsg(WHERE,ERR_OPEN,str,O_RDWR);
return; }
length=filelength(file);
if(length%F_IXBSIZE) {
close(file);
errormsg(WHERE,ERR_LEN,str,length);
return; }
strcpy(fname,f->name);
for(i=8;i<12;i++) /* Turn FILENAME.EXT into FILENAMEEXT */
fname[i]=fname[i+1];
for(l=0;l<length;l+=F_IXBSIZE) {
read(file,str,F_IXBSIZE); /* Look for the filename in the IXB file */
str[11]=0;
if(!strcmp(fname,str)) break; }
if(l>=length) {
close(file);
errormsg(WHERE,ERR_CHK,f->name,length);
return; }
lseek(file,l+14,SEEK_SET);
write(file,&f->dateuled,4);
close(file);
/*******************************************/
/* Update last upload date/time stamp file */
/*******************************************/
sprintf(str,"%s%s.dab",cfg.dir[f->dir]->data_dir,cfg.dir[f->dir]->code);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
errormsg(WHERE,ERR_OPEN,str,O_WRONLY|O_CREAT);
else {
write(file,&f->dateuled,4);
close(file);
}
}
/****************************************************************************/
/* Uploads files */
/****************************************************************************/
......
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