/************************************************************ * Delete an ADAM file ************************************************************* * 1.00 Chris Braymen Creation * 1.01 12/1/94 Chris Braymen Fixes writeDircetory bugs * with multiple directories *************************************************************/ #define TRUE 1 #define FALSE 0 #define BUFSIZE 1024 /* not less that 1024! */ #define BDRESET 0x00 #define BDSTATUS 0x01 #define BDREAD 0x02 #define BDWRITE 0x03 #define BDVERIFY 0x04 #define BDFORMAT 0x05 #define FLOPPY1 0x00 #define HEAD0 0x00 #define HEAD1 0x01 #define ONESECTOR 0x01 #include #include #include #include #include #include "adamfcb.h" #define MAX_FCB 8*NUM_FCB_IN_BLOCK /* maximum # of directory entries */ unsigned char buffer[BUFSIZE]; struct EOS_FCB myDir[MAX_FCB]; char delFileName[255]; char version[] = "v1.01"; /**************************** * Prototypes *****************************/ int processArgs(int,char**); int readDirectory(void); int verifyEOS(unsigned char*); int writeDirectory(void); int deleteFile(char*); int compareName(char*,char*); int findFCB(char*); #include "ReadBlk.c" #include "WriteBlk.c" int main(argc,argv) int argc; char *argv[]; { int block; int result; if(!processArgs(argc,argv)) exit(0); if(!readDirectory()) { exit(0); } deleteFile(delFileName); return 0; } /******************************************************* * processArgs - process the command line args * sets globals inFileName,outFileName ********************************************************/ processArgs(argc,argv) int argc; char *argv[]; { if(argc!=2) { printf("DELADAM %s - Public Domain from Bonafide Systems\n\n",version); puts("Usage: DELADAM \n"); return(FALSE); } strcpy(delFileName,argv[1]); return(TRUE); } /***************************************************** * readDirectory * reads the EOS directory in the myDir array of FCB structures * returns 0 if OK, BIOSDISK error code if error *****************************************************/ int readDirectory() { int result,i,j,done=FALSE; int fcbCount=0; int dirBlocks,blockCount=1; char *bytePtr; if(result=readBlock(blockCount,buffer)) { /* read directory block */ printf("Error reading block: %d, errcode=%d\n",blockCount,result); return(FALSE); } if((dirBlocks=verifyEOS(buffer))==0) { /* get directory size */ puts("Not an EOS directory!"); return(FALSE); } if(dirBlocks * NUM_FCB_IN_BLOCK > MAX_FCB) { printf("A %d block directory is too big!\n",dirBlocks); return(FALSE); } while(!done) { if(blockCount>dirBlocks) { puts("Error: No 'hole' found"); return(FALSE); } if(result=readBlock(blockCount,buffer)) { printf("Error reading block: %d, errcode=%d\n",blockCount,result); return(FALSE); } for(i=0;i