We recover the data by reading the information of the file(s) from the Root Directory and then integrate the file to the destination path and recover the file. Our next program performs the following steps to recover the data:
- Read the Root Directory entries and Display them on the screen with all information such as File/Directory name, Extension of the File, Starting cluster size of the files in Bytes.
- Read the Files and Directories information in the Subdirectories and display them if required.
- Confirm the File name to be recovered and continue recovery.
- Calculate the CHS (Cylinder, Head, and Sector) info for the Specified file to be recovered.
- Integrate the data of the file from the data area of the disk and save the recovered file to the specified destination file name in specified path.
This Program does not care if the boot information of the floppy is readable or not. Therefore you can recover even deleted data from the corrupted floppy disk too. Let us see the coding of the program:
/* Program to recover the data from the Floppy disk by Reading file information from the Root Directory */
#include<stdio.h>
#include<bios.h>
#include<dos.h>
void main()
{
void Display_Information(unsigned int,unsigned int, unsigned int);
unsigned int track=0,head=1,sector=2;
Display_Information(track,head,sector);
} /*End of main */
void Display_Information(unsigned int track, unsigned int head,
unsigned int sector)
{
void recover(unsigned int *,unsigned int);
char buf[512]; // Buffer of 512 Bytes
char ch;
struct diskinfo_t finfo; //Structure, Used by _bios_disk
unsigned int result,i,j, count=0; /* Unsigned Integers
Defined */
unsigned int file_no; /* Unsigned Integer
for File Number */
struct
{
unsigned int name[8],ext[3]; /* File Name for DOS in 8.3 (Eight Dot Three) Format */
unsigned int attribute; // File/Directory Attribute
unsigned int start; // Starting Cluster of the File
long unsigned int size; // Size of the File in Bytes
}root[32]; /* 32 Bytes Information of
File/Directory in Root
Directory */
clrscr();
|