Commit 78367e33 authored by Claes Sjofors's avatar Claes Sjofors

pwr_projectlist.dat, old versions stored

parent a3b4c58e
......@@ -107,6 +107,7 @@ char *dcli_fgetname( FILE *fp, char *name, char *def_name);
int dcli_translate_filename( char *out, const char *in);
pwr_tStatus dcli_file_time( char *filename, pwr_tTime *time);
pwr_tStatus dcli_file_ctime( char *filename, pwr_tTime *time);
void dcli_save_file_versions( char *fname);
/* Functions in module co_dcli_dir */
......
......@@ -522,3 +522,29 @@ pwr_tStatus dcli_file_ctime( char *filename, pwr_tTime *time)
return DCLI__NOFILE;
}
void dcli_save_file_versions( char *fname)
{
pwr_tFileName newname;
pwr_tFileName oldname;
char cmd[400];
int i;
pwr_tTime t;
int sts;
for ( i = 9; i >= 0; i--) {
snprintf( newname, sizeof(newname), "%s.%d", fname, i+1);
if ( i == 0 )
strncpy( oldname, fname, sizeof(oldname));
else
snprintf( oldname, sizeof(oldname), "%s.%d", fname, i);
sts = dcli_file_time( oldname, &t);
if ( EVEN(sts))
continue;
snprintf( cmd, sizeof(cmd), "mv -f %s %s", oldname, newname);
// printf( "%s -> %s\n", oldname, newname);
system( cmd);
}
}
......@@ -477,6 +477,7 @@ void wb_pvd_pl::save_list( pwr_tStatus *sts)
*sts = LDH__SUCCESS;
dcli_translate_filename( fname, "$pwra_db/pwr_projectlist.dat");
dcli_save_file_versions( fname);
of.open( fname);
if ( !of) {
*sts = LDH__FILEOPEN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment