save.cpp
资源名称:fips15.zip [点击查看]
上传用户:yingdiyu
上传日期:2007-01-06
资源大小:116k
文件大小:2k
源码类别:
磁盘编程
开发平台:
Others
- /*
- FIPS - the First nondestructive Interactive Partition Splitting program
- Module save.cpp
- RCS - Header:
- $Header: c:/daten/fips/source/main/RCS/save.cpp 1.4 1995/01/19 00:01:24 schaefer Exp schaefer $
- Copyright (C) 1993 Arno Schaefer
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- Report problems and direct all questions to:
- schaefer@rbg.informatik.th-darmstadt.de
- */
- #include <stdio.h>
- #include <io.h>
- #include "global.h"
- #include "hdstruct.h"
- /* ----------------------------------------------------------------------- */
- /* Save root- and boot sector to floppy disk */
- /* ----------------------------------------------------------------------- */
- void save_root_and_boot (harddrive *drive,partition *partition)
- {
- FILE *save_file;
- char *filename = "a:\rootboot.000";
- while (access (filename,0) == 0)
- {
- if (++filename[14] > '9')
- error ("Too many save files on disk");
- }
- if ((save_file = fopen (filename,"wb")) == NULL)
- error ("Can't open file: %s",filename);
- printx ("nWriting file %sn", filename);
- if (fwrite (drive->root_sector->data,1,512,save_file) != 512)
- error ("Error writing file: %s",filename);
- if (fwrite (partition->boot_sector->data,1,512,save_file) != 512)
- error ("Error writing file: %s",filename);
- if (fputc (drive->number,save_file) != drive->number)
- error ("Error writing file: %s",filename);
- if (fputc (partition->number,save_file) != partition->number)
- error ("Error writing file: %s",filename);
- if (fclose (save_file))
- error ("Error closing file: %s",filename);
- }