TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: All
from: Frank Adam
date: 1996-10-26 13:03:16
subject: fatread.c 3/6

>>> Part 3 of 6...

        }
       else printf("Excellent filename ! :-)");
       PrintFlag = 1;
       break;
   default  : stream = stdout;PrintFlag = 0;
   }

  if(!GetBoot(drive -1,FATSHOW))
    printf("Boot read failed !");
  if(!GetFat(drive - 1,1,FATSHOW))
    printf("Fat read failed !");

}


void FatSave( int drive )
{
 int newdat = 0;
 FILE *datfile;

 if(!GetBoot(drive -1,FATSAVE))
  printf("Boot read failed !");
 if(!GetFat(drive - 1,1,FATSAVE))
  printf("Fat read failed !");

   bupdat.drive = dpb.Driveno;
   bupdat.fss = 1;
   bupdat.bps = dpb.Bpersec;
   bupdat.spf = dpb.SecPerFat;
   bupdat.fats = dpb.NumFats;
   strcpy(fname,"fatbak.dat");
   if((datfile = fopen(fname,"rb+")) == NULL)
   {
    newdat = 1;
    if((datfile = fopen(fname,"wb")) == NULL)
     {
      printf("\n *** Could not save backup data !!! *** ");
      exit(1);
      }
    }

   if(!newdat) SeekBackupPos(datfile,dpb.Driveno);

   {
    fwrite(&bupdat,sizeof(struct BackupData),1,datfile);
    }
   printf("\nBackup completed. Control file's name FATBAK.DAT");
}


void SeekBackupPos(FILE *fh,int drive)
{
 struct BackupData temp;
 if(fseek(fh,0L,SEEK_SET)) return;

 while(!feof(fh))
 {
  fread(&temp,sizeof(struct BackupData),1,fh);
  if(temp.drive == drive)
  {
   fseek(fh,-(long)sizeof(struct BackupData),SEEK_CUR);
   return;
   }
  }
 fseek(fh,0L,SEEK_END);
}


int ParseArg(char* args[], int *drv,int *sw)
{
 char d,s;

  if(*args[1] == '/')
  {
   d = *args[2];
   s = args[1][1];
   }

   else if(*args[2] == '/')
   {
    d = *args[1];
    s = args[2][1];
    }
     else
    {
     printf("Incorrect argument(s) !");
     return 0;
     }

*drv = toupper(d) - 'A' + 1;

switch(toupper(s))
{
 case 'S' : *sw = FATSAVE;PrintFlag = 0; return 1;
 case 'R' : *sw = RESTORE;PrintFlag = 0; return 1;
 case 'P' : *sw = FATSHOW; return 1;

 >>> Continued to next message...

___ Blue Wave/DOS v2.21

---
* Origin: Melbourne PC User Group BBS (3:632/309)
SEEN-BY: 633/267 270
@PATH: 632/309 107 635/503 50/99 635/728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.