home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 8 / IOPROG_8.ISO / install / fips / source / save.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-25  |  2.3 KB  |  69 lines

  1. /*
  2.  
  3.     FIPS - the First nondestructive Interactive Partition Splitting program
  4.  
  5.  
  6.  
  7.     Module save.cpp
  8.  
  9.  
  10.  
  11.     RCS - Header:
  12.  
  13.     $Header: c:/daten/fips/source/main/RCS/save.cpp 1.4 1995/01/19 00:01:24 schaefer Exp schaefer $
  14.  
  15.  
  16.  
  17.     Copyright (C) 1993 Arno Schaefer
  18.  
  19.  
  20.  
  21.     This program is free software; you can redistribute it and/or modify
  22.  
  23.     it under the terms of the GNU General Public License as published by
  24.  
  25.     the Free Software Foundation; either version 2 of the License, or
  26.  
  27.     (at your option) any later version.
  28.  
  29.  
  30.  
  31.     This program is distributed in the hope that it will be useful,
  32.  
  33.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  34.  
  35.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  36.  
  37.     GNU General Public License for more details.
  38.  
  39.  
  40.  
  41.     You should have received a copy of the GNU General Public License
  42.  
  43.     along with this program; if not, write to the Free Software
  44.  
  45.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.     Report problems and direct all questions to:
  52.  
  53.  
  54.  
  55.     schaefer@rbg.informatik.th-darmstadt.de
  56.  
  57. */
  58.  
  59.  
  60.  
  61. #include <stdio.h>
  62.  
  63. #include <io.h>
  64.  
  65. #include "global.h"
  66.  
  67. #include "hdstruct.h"
  68.  
  69.  
  70.  
  71. /* ----------------------------------------------------------------------- */
  72.  
  73. /* Save root- and boot sector to floppy disk                               */
  74.  
  75. /* ----------------------------------------------------------------------- */
  76.  
  77.  
  78.  
  79. void save_root_and_boot (harddrive *drive,partition *partition)
  80.  
  81. {
  82.  
  83.     FILE *save_file;
  84.  
  85.  
  86.  
  87.     char *filename = "a:\\rootboot.000";
  88.  
  89.  
  90.  
  91.     while (access (filename,0) == 0)
  92.  
  93.     {
  94.  
  95.         if (++filename[14] > '9')
  96.  
  97.             error ("Too many save files on disk");
  98.  
  99.     }
  100.  
  101.  
  102.  
  103.     if ((save_file = fopen (filename,"wb")) == NULL)
  104.  
  105.         error ("Can't open file: %s",filename);
  106.  
  107.  
  108.  
  109.     printx ("\nWriting file %s\n", filename);
  110.  
  111.  
  112.  
  113.     if (fwrite (drive->root_sector->data,1,512,save_file) != 512)
  114.  
  115.         error ("Error writing file: %s",filename);
  116.  
  117.     if (fwrite (partition->boot_sector->data,1,512,save_file) != 512)
  118.  
  119.         error ("Error writing file: %s",filename);
  120.  
  121.     if (fputc (drive->number,save_file) != drive->number)
  122.  
  123.         error ("Error writing file: %s",filename);
  124.  
  125.     if (fputc (partition->number,save_file) != partition->number)
  126.  
  127.         error ("Error writing file: %s",filename);
  128.  
  129.  
  130.  
  131.     if (fclose (save_file))
  132.  
  133.         error ("Error closing file: %s",filename);
  134.  
  135. }
  136.  
  137.