home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / install / fips / source / save.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-11  |  2.2 KB  |  67 lines

  1. /* 
  2.     FIPS - the First nondestructive Interactive Partition Splitting program 
  3.  
  4.     Module save.cpp 
  5.  
  6.     RCS - Header: 
  7.     $Header: c:/daten/fips/source/main/RCS/save.cpp 1.1 1994/05/25 22:20:17 schaefer Exp schaefer $ 
  8.  
  9.     Copyright (C) 1993 Arno Schaefer 
  10.  
  11.     This program is free software; you can redistribute it and/or modify 
  12.     it under the terms of the GNU General Public License as published by 
  13.     the Free Software Foundation; either version 2 of the License, or 
  14.     (at your option) any later version. 
  15.  
  16.     This program is distributed in the hope that it will be useful, 
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of 
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  19.     GNU General Public License for more details. 
  20.  
  21.     You should have received a copy of the GNU General Public License 
  22.     along with this program; if not, write to the Free Software 
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  24.  
  25.  
  26.     Report problems and direct all questions to: 
  27.  
  28.     schaefer@rbg.informatik.th-darmstadt.de 
  29. */ 
  30.  
  31. #include <stdio.h> 
  32. #include <io.h> 
  33. #include "global.h" 
  34. #include "hdstruct.h" 
  35.  
  36. /* ----------------------------------------------------------------------- */ 
  37. /* Save root- and bootsector to floppy disk                                */ 
  38. /* ----------------------------------------------------------------------- */ 
  39.  
  40. void save_root_and_boot (harddrive *drive,partition *partition) 
  41.     FILE *save_file; 
  42.  
  43.     char *filename = "a:\\rootboot.000"; 
  44.  
  45.     while (access (filename,0) == 0) 
  46.     { 
  47.         if (++filename[14] > '9') 
  48.             error ("Too many save files on disk"); 
  49.     } 
  50.  
  51.     if ((save_file = fopen (filename,"wb")) == NULL) 
  52.         error ("Can't open file: %s",filename); 
  53.  
  54.     if (fwrite (drive->rootsector->data,1,512,save_file) != 512) 
  55.         error ("Error writing file: %s",filename); 
  56.     if (fwrite (partition->bootsector->data,1,512,save_file) != 512) 
  57.         error ("Error writing file: %s",filename); 
  58.     if (fputc (drive->number,save_file) != drive->number) 
  59.         error ("Error writing file: %s",filename); 
  60.     if (fputc (partition->number,save_file) != partition->number) 
  61.         error ("Error writing file: %s",filename); 
  62.  
  63.     if (fclose (save_file)) 
  64.         error ("Error closing file: %s",filename); 
  65.