?? dolba.h
字號:
#include <bios.h>
#include <io.h>
#include <conio.h>
#include <stdio.h>
int YesNo(char *s, char *filename)
//char *s,fil;
{
//getchar();
char *c="\0";
printf("%s %s ? (Y/N)",s,filename);
do {
//c=getchar();
//c=toupper(c);
gets(c);
} while (*c=='\0');
if (strcmp(strupr(c),"Y")==0) return 1;
else
printf("\nNothing done.\n");
return 0;
}
void doLBA(char *prompt,unsigned int cmd,
unsigned int hardDisk,
unsigned long startSector,
unsigned long nSectorVar,
char *filename,char *showFileName)
{
unsigned int head=0;
unsigned int cylinder=0;
unsigned int sector=0;
unsigned char pBuffer[32256];
FILE *f;
unsigned int allowednSector=0;
unsigned int doReadSector=0;
unsigned long sectorWrite=0;
unsigned int x=0,y=0;
unsigned long nSector=nSectorVar;
long filesize;
if(YesNo(prompt,showFileName)!=1) return;
x=wherex();
y=wherey();
//printf("%lu,%lu\n",startSector,nSectorVar);
cylinder=((startSector+nSector-1)/(255*63));
if(cylinder>1022)
{
printf("\n%u out of hard disk's cylinder range(0-1022)\n",cylinder);
return;
}
if(cmd==2)
{
if((f=fopen(filename,"wb"))==NULL)
{
printf("File Error : %s\n",showFileName);
return;
}
//fclose(f);
}
else if(cmd==3)
{
if((f=fopen(filename,"rb"))==NULL)
{printf("File Error : %s\n",showFileName); return;}
filesize=filelength(fileno(f));
//fclose(checkFile);
if((filesize==0) || (filesize % 512)!=0)
{printf("the size of the file is 0 or not an integer in sectors!\n");
return;}
nSector=filesize/512;
if(YesNo("Are you sure","")!=1) return;
}
cylinder=startSector/(255*63);
head=(startSector/63)%255;
sector=startSector%63+1;
allowednSector=63-sector+1;
if(nSector<=allowednSector)
doReadSector=nSector;
else doReadSector= allowednSector;
while(sectorWrite<nSector)
{
if(bioskey(1)!=0)
{
if(bioskey(0)==0x11B)
{
printf("\nStopped.\n");
return;
}
}
if(cylinder>1022)
{printf("\nout of hard disk's cylinder range(0-1022)\n");
return;}
if(cmd==2)
{
biosdisk(cmd,hardDisk,head,cylinder,sector,doReadSector,pBuffer);
//doFile(2,"ab+",pBuffer,doReadSector,filename,0);
fwrite(pBuffer,doReadSector*512,1,f);
}
else if(cmd==3)
{
//doFile(3,"rb",pBuffer,doReadSector,filename,sectorWrite);
fread(pBuffer,doReadSector*512,1,f);
biosdisk(cmd,hardDisk,head,cylinder,sector,doReadSector,pBuffer);
}
sectorWrite+= doReadSector;
gotoxy(x,y);
cprintf("%lu%c sectors done.",sectorWrite*100/nSector,'%');
head++;sector=1;
if (head>254) {cylinder++; head=0; sector=1;}
//if (cylinder>1022)
//{printf("\nout of hard disk's cylinder range(0-1022)\n");
//return;}
doReadSector=63;
if(nSector-sectorWrite<63) doReadSector=nSector-sectorWrite;
}
fclose(f);
printf("\nDone.");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -