int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; FILE* boot; unsigned char bootcode[1024]; boot=fopen(argv[1],"rb"); if (!boot) { fprintf(stderr, "can't mount volume\n"); exit(1); } fread(bootcode, sizeof(unsigned char), 1024, boot); fclose(boot); adfEnvInitDefault(); /* create and mount one device */ hd = adfCreateDumpDevice("newdev", 80, 2, 11); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfDeviceInfo(hd); if (adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE )!=RC_OK) { fprintf(stderr, "can't create floppy\n"); adfUnMountDev(hd); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfInstallBootBlock(vol, bootcode); adfVolumeInfo(vol); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; FILE* boot; unsigned char bootcode[1024]; boot=fopen(argv[1],"rb"); if (!boot) { fprintf(stderr, "can't mount volume\n"); exit(1); } fread(bootcode, sizeof(unsigned char), 1024, boot); fclose(boot); adfEnvInitDefault(); hd = adfMountDev(argv[2],FALSE); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfInstallBootBlock(vol, bootcode); adfVolumeInfo(vol); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int amigados_mountImage(FSMNG * fsmng, FLOPPY *floppy) { unsigned char sectorbuffer[512]; int nbsector,fdcstatus,badsectorfound; struct Volume * adfvolume; struct Device * adfdevice; badsectorfound = 0; if(!floppy || !fsmng) return HXCFE_BADPARAMETER; adfEnvInitDefault(); HxCadfInitNativeFct(); adfChgEnvProp(PR_EFCT,adlib_printerror); adfChgEnvProp(PR_WFCT,adlib_printwarning); adfChgEnvProp(PR_VFCT,adlib_printdebug); fsmng->fp = floppy; if(fsmng->fp->floppyNumberOfTrack>83) fsmng->trackperdisk = 83; else fsmng->trackperdisk = fsmng->fp->floppyNumberOfTrack; fsmng->sectorpertrack = 11; fsmng->sidepertrack = fsmng->fp->floppyNumberOfSide; fsmng->sectorsize = 512; memset(fsmng->dirhandletable,0xFF,sizeof(fsmng->dirhandletable)); memset(fsmng->handletable,0xFF,sizeof(fsmng->handletable)); if(fsmng->fdc) hxcfe_deinitFDC (fsmng->fdc); fsmng->fdc = hxcfe_initFDC (fsmng->hxcfe); if(fsmng->fdc) { if(hxcfe_insertDiskFDC (fsmng->fdc,floppy) == HXCFE_NOERROR) { // Count the number of sector nbsector = 0; while(hxcfe_readSectorFDC(fsmng->fdc,40,0,(unsigned char)(nbsector),512,AMIGA_MFM_ENCODING,1,(unsigned char*)sectorbuffer,sizeof(sectorbuffer),&fdcstatus)) { if(fdcstatus == FDC_BAD_DATA_CRC) badsectorfound++; nbsector++; } fsmng->sidepertrack = 2; fsmng->sectorpertrack = nbsector; if(fsmng->sectorpertrack && !badsectorfound) { fsmng->hxcfe->hxc_printf(MSG_DEBUG,"AMIGADOSFS : %d Sectors per track (%d Bytes per sector)",fsmng->sectorpertrack,fsmng->sectorsize); fsmng->device = (void*)adfMountDev("HXCDOSDISKBROWSER",0); adfdevice = (struct Device *)fsmng->device; if(adfdevice) { fsmng->volume = (void*)adfMount(adfdevice, 0, 0); adfvolume = (struct Volume *)fsmng->volume; if(adfvolume) { floppycontext->hxc_printf(MSG_DEBUG,"adfMount ok"); return HXCFE_NOERROR; } } } } } return HXCFE_INTERNALERROR; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list; SECTNUM nSect; adfEnvInitDefault(); /* mount existing device */ hd = adfMountDev( argv[1], FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfCreateDir(vol,vol->curDirPtr,"newdir"); /* cd dir_2 */ nSect = adfChangeDir(vol, "same_hash"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); /* not empty */ adfRemoveEntry(vol, vol->curDirPtr, "mon.paradox"); /* first in same hash linked list */ adfRemoveEntry(vol, vol->curDirPtr, "file_3a"); /* second */ adfRemoveEntry(vol, vol->curDirPtr, "dir_3"); /* last */ adfRemoveEntry(vol, vol->curDirPtr, "dir_1a"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfParentDir(vol); adfRemoveEntry(vol, vol->curDirPtr, "mod.And.DistantCall"); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); putchar('\n'); adfVolumeInfo(vol); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *out; long len; struct List *list; adfEnvInitDefault(); /* create and mount one device */ hd = adfCreateDumpDevice("newdev", 80, 11, 2); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE ); vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); /* the directory */ list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); /* write one file */ file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; out = fopen("Check/MOON.GIF","rb"); if (!out) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,out); while(!feof(out)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,out); } if (n>0) adfWriteFile(file, n, buf); fclose(out); adfCloseFile(file); /* the directory */ list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int AMIGADOSFSDK_libLoad_DiskFile(HXCFLOPPYEMULATOR* floppycontext,FLOPPY * floppydisk,char * imgfile,void * parameters) { unsigned int i,j; unsigned int file_offset; struct Device * adfdevice; struct Volume * adfvolume; unsigned char * flatimg; unsigned char * flatimg2; unsigned char * repname; int flatimgsize; int numberoftrack; int numberofsectorpertrack; unsigned short sectorsize; unsigned char gap3len,skew,trackformat,interleave; struct stat repstate; struct tm * ts; struct DateTime reptime; // FILE * debugadf; int rc; CYLINDER* currentcylinder; numberoftrack=80; numberofsectorpertrack=11; floppycontext->hxc_printf(MSG_DEBUG,"AMIGADOSFSDK_libLoad_DiskFile %s",imgfile); stat(imgfile,&repstate); ts=localtime(&repstate.st_ctime); if(repstate.st_mode&S_IFDIR) { global_floppycontext=floppycontext; adfEnvInitDefault(); adfChgEnvProp(PR_EFCT,adlib_printerror); adfChgEnvProp(PR_WFCT,adlib_printwarning); adfChgEnvProp(PR_VFCT,adlib_printdebug); floppycontext->hxc_printf(MSG_DEBUG,"ADFLib %s %s",adfGetVersionNumber(), adfGetVersionDate()); adfdevice = adfCreateMemoryDumpDevice(numberoftrack, 2, numberofsectorpertrack,&flatimg,&flatimgsize); if(adfdevice) { repname=(unsigned char *)malloc(strlen(imgfile)+1); memset(repname,0,strlen(imgfile)+1); i=strlen(imgfile); if( (imgfile[i]=='\\' || imgfile[i]=='/') && i) { imgfile[i]=0; i--; } while(i && (imgfile[i]!='\\' && imgfile[i]!='/')) { i--; } if((imgfile[i]=='\\' || imgfile[i]=='/')) { i++; } sprintf(repname,"%s",&imgfile[i]); if(ts) { reptime.year=ts->tm_year; /* since 1900 */ reptime.mon=ts->tm_mon+1; reptime.day=ts->tm_mday; reptime.hour=ts->tm_hour; reptime.min=ts->tm_min; reptime.sec=ts->tm_sec; } else { reptime.year=0; reptime.mon=0; reptime.day=0; reptime.hour=0; reptime.min=0; reptime.sec=0; } rc=adfCreateFlop(adfdevice, repname, 0,&reptime ); free(repname); if (rc==RC_OK) { adfvolume = adfMount(adfdevice, 0, 0); if(adfvolume) { floppycontext->hxc_printf(MSG_DEBUG,"adfCreateFlop ok"); if(adfInstallBootBlock(adfvolume, stdboot3)!=RC_OK) { floppycontext->hxc_printf(MSG_ERROR,"adflib: adfInstallBootBlock error!"); } if(ScanFile(floppycontext,adfvolume,imgfile,"*.*")) { floppycontext->hxc_printf(MSG_DEBUG,"ScanFile error!"); return LOADER_INTERNALERROR; } flatimg2=(unsigned char*)malloc(flatimgsize); memcpy(flatimg2,flatimg,flatimgsize); adfUnMountDev(adfdevice); /*//////// debugadf=fopen("d:\\debug.adf","wb"); if(debugadf) { fwrite(flatimg2,flatimgsize,1,debugadf); fclose(debugadf); } //////////*/ } else { floppycontext->hxc_printf(MSG_ERROR,"adflib: adfMount error!"); return LOADER_INTERNALERROR; } } else { floppycontext->hxc_printf(MSG_ERROR,"adflib: Error while creating the virtual floppy!"); return LOADER_INTERNALERROR; } } else { floppycontext->hxc_printf(MSG_ERROR,"adflib: adfCreateMemoryDumpDevice error!"); return LOADER_INTERNALERROR; } if(flatimg2) { sectorsize=512; interleave=1; gap3len=0; skew=0; trackformat=AMIGAFORMAT_DD; floppydisk->floppySectorPerTrack=numberofsectorpertrack; floppydisk->floppyNumberOfSide=2; floppydisk->floppyNumberOfTrack=numberoftrack; floppydisk->floppyBitRate=DEFAULT_AMIGA_BITRATE; floppydisk->floppyiftype=AMIGA_DD_FLOPPYMODE; floppydisk->tracks=(CYLINDER**)malloc(sizeof(CYLINDER*)*floppydisk->floppyNumberOfTrack); for(j=0;j<floppydisk->floppyNumberOfTrack;j++) { floppydisk->tracks[j]=allocCylinderEntry(DEFAULT_AMIGA_RPM,floppydisk->floppyNumberOfSide); currentcylinder=floppydisk->tracks[j]; for(i=0;i<floppydisk->floppyNumberOfSide;i++) { file_offset=(sectorsize*(j*floppydisk->floppySectorPerTrack*floppydisk->floppyNumberOfSide))+ (sectorsize*(floppydisk->floppySectorPerTrack)*i); currentcylinder->sides[i]=tg_generatetrack(&flatimg2[file_offset],sectorsize,floppydisk->floppySectorPerTrack,(unsigned char)j,(unsigned char)i,0,interleave,(unsigned char)(((j<<1)|(i&1))*skew),floppydisk->floppyBitRate,currentcylinder->floppyRPM,trackformat,gap3len,2500,-11150); } } free(flatimg2); floppycontext->hxc_printf(MSG_INFO_1,"AMIGADOSFSDK Loader : tracks file successfully loaded and encoded!"); return LOADER_NOERROR; } floppycontext->hxc_printf(MSG_ERROR,"flatimg==0 !?"); return LOADER_INTERNALERROR; } else { floppycontext->hxc_printf(MSG_ERROR,"not a directory !"); return LOADER_BADFILE; } }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list, *cell; BOOL boolPr; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device */ hd = adfMountDev( argv[1],FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* not empty */ adfRemoveEntry(vol, vol->curDirPtr, "dir_2"); /* cd dir_2 */ boolPr = TRUE; adfChgEnvProp(PR_USEDIRC, (void*)&boolPr); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
void NewCreateFile(void *lpVoid) { struct Device *dev; int iType; char tempStr[31]; HWND dlg = (HWND)lpVoid; int type = 0; char strNewFileName[MAX_PATH * 2]; struct Volume *vol; HXCFLOPPYEMULATOR* hxcfe; FLOPPY * fp; int loaderId; Percent = 0; iType = SendMessage(GetDlgItem(dlg, IDC_NEWHFE), BM_GETCHECK, 0, 0l); if(iType == BST_CHECKED) { strcpy(strNewFileName, dirTemp); MakeSureDirectoryPathExists(dirTemp); // Create temp dir. strcat(strNewFileName,"newfile.adf"); } else { strcpy(strNewFileName,gstrFileName); } if (Size == 1760) /* 880KB Floppy */ dev = adfCreateDumpDevice(strNewFileName, 80, 2, 11); else if (Size == (1760 * 2)) /* HD Floppy */ dev = adfCreateDumpDevice(strNewFileName, 80, 2, 22); else /* hardfile */ dev = adfCreateDumpDevice(strNewFileName, Size, 1, 1); GetDlgItemText(dlg, IDC_NEWLABEL, tempStr, sizeof(tempStr)); if (SendMessage(GetDlgItem(dlg, IDC_NEWFFS), BM_GETCHECK, 0, 0l) == BST_CHECKED) type += FSMASK_FFS; if (SendMessage(GetDlgItem(dlg, IDC_NEWINTL), BM_GETCHECK, 0, 0l) == BST_CHECKED) type += FSMASK_INTL; if (SendMessage(GetDlgItem(dlg, IDC_NEWDIRC), BM_GETCHECK, 0, 0l) == BST_CHECKED) type += FSMASK_DIRCACHE; if ((Size == 1760) || (Size == 1760 * 2)){ adfCreateFlop(dev, tempStr, type); // Install bootblock if "Bootable" selected. if(SendMessage(GetDlgItem(dlg, IDC_NEWBOOTABLE), BM_GETCHECK, 0, 0l) == BST_CHECKED){ vol = adfMount(dev, 0, FALSE); InstallBootBlock(dlg, vol, TRUE); } } else adfCreateHdFile(dev, tempStr, type); adfUnMountDev(dev); if(iType == BST_CHECKED) { hxcfe=hxcfe_init(); fp=0; // Load the image loaderId=hxcfe_autoSelectLoader(hxcfe,strNewFileName,0); // Load the image if(loaderId>=0) fp=hxcfe_floppyLoad(hxcfe,strNewFileName,loaderId,0); if(fp) { // Select the HFE loader/exporter. loaderId=hxcfe_getLoaderID(hxcfe,"HXC_HFE"); // Save the file... hxcfe_floppyExport(hxcfe,fp,gstrFileName,loaderId); // Free the loaded image hxcfe_floppyUnload(hxcfe,fp); } hxcfe_deinit(hxcfe); // Delete intermediate adf. remove(strNewFileName); } Done = TRUE; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *fic; unsigned char buf[1]; struct List *list, *cell; struct GenBlock *block; BOOL true = TRUE; adfEnvInitDefault(); adfChgEnvProp(PR_USEDIRC,&true); /* display or not the physical / logical blocks and W or R */ adfChgEnvProp(PR_USE_RWACCESS,&true); /* create and mount one device */ hd = adfCreateDumpDevice("newdev", 80, 2, 11); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfDeviceInfo(hd); if (adfCreateFlop( hd, "empty", FSMASK_FFS|FSMASK_DIRCACHE )!=RC_OK) { fprintf(stderr, "can't create floppy\n"); adfUnMountDev(hd); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } fic = adfOpenFile(vol, "file_1a","w"); if (!fic) { adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); exit(1); } adfWriteFile(fic,1,buf); adfCloseFile(fic); puts("\ncreate file_1a"); adfVolumeInfo(vol); adfCreateDir(vol,vol->curDirPtr,"dir_5u"); puts("\ncreate dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol, vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); puts("\nremove file_1a"); adfRemoveEntry(vol,vol->curDirPtr,"file_1a"); adfVolumeInfo(vol); adfRemoveEntry(vol,vol->curDirPtr,"dir_5u"); puts("\nremove dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDelEnt(vol); while(cell) { block =(struct GenBlock*) cell->content; printf("%s %d %d %ld\n",block->name,block->type,block->secType, block->sect); cell = cell->next; } adfFreeDelList(list); adfUndelEntry(vol,vol->curDirPtr,883); // file_1a puts("\nundel file_1a"); adfVolumeInfo(vol); adfUndelEntry(vol,vol->curDirPtr,885); // dir_5u puts("\nundel dir_5u"); adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol, vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char* argv[]) { int i, j; BOOL rflag, lflag, xflag, cflag, vflag, sflag, dflag, pflag, qflag; struct List* files, *rtfiles; char *devname, *dirname; char strbuf[80]; unsigned char *extbuf; int vInd, dInd, fInd, aInd; BOOL nextArg; struct Device *dev; struct Volume *vol; struct List *list, *cell; int volNum; BOOL true = TRUE; if (argc<2) { help(); exit(0); } rflag = lflag = cflag = vflag = sflag = dflag = pflag = qflag = FALSE; vInd = dInd = fInd = aInd = -1; xflag = TRUE; dirname = NULL; devname = NULL; files = rtfiles = NULL; volNum = 0; fprintf(stderr,"unADF v%s : a unzip like for .ADF files, powered by ADFlib (v%s - %s)\n\n", UNADF_VERSION, adfGetVersionNumber(),adfGetVersionDate()); /* parse options */ i=1; while(i<argc) { if (argv[i][0]=='-') { j=1; nextArg = FALSE; while(j<(int)strlen(argv[i]) && !nextArg) { switch(argv[i][j]) { case 'v': vflag = TRUE; if ((i+1)<(argc-1)) { i++; nextArg = TRUE; errno = 0; volNum = atoi(argv[i]); if (errno!=0 || volNum<0) { fprintf(stderr,"invalid volume number, aborting.\n"); exit(1); } } else fprintf(stderr,"no volume number, -v option ignored.\n"); break; case 'l': lflag = TRUE; xflag = FALSE; break; case 's': sflag = TRUE; break; case 'c': cflag = TRUE; break; case 'r': rflag = TRUE; break; case 'd': if (devname!=NULL && xflag && (i+1)==(argc-1)) { i++; dirname = argv[i]; if (dirname[strlen(dirname)-1]==DIRSEP) dirname[strlen(dirname)-1]='\0'; nextArg = TRUE; dflag = TRUE; } break; case 'p': if (xflag) { fprintf(stderr,"sending files to pipe.\n"); pflag = TRUE; qflag = TRUE; } else fprintf(stderr,"-p option must be used with extraction, ignored.\n"); break; case 'h': default: help(); exit(0); } /* switch */ j++; } /* while */ } /* if */ else { /* the last non option string is taken as a filename */ if (devname==NULL) /* if the device name has been already given */ devname = argv[i]; else { if (xflag) { if (rtfiles==NULL) rtfiles = files = newCell(NULL, (void*)argv[i]); else files = newCell(files, (void*)argv[i]); } else fprintf(stderr,"Must be used with extraction, ignored.\n"); } } i++; } /* while */ extbuf =(unsigned char*)malloc(EXTBUFL*sizeof(char)); if (!extbuf) { fprintf(stderr,"malloc error\n"); exit(1); } /* initialize the library */ adfEnvInitDefault(); dev = adfMountDev( devname,TRUE ); if (!dev) { sprintf(strbuf,"Can't mount the dump device '%s'.\n", devname); fprintf(stderr, strbuf); adfEnvCleanUp(); exit(1); } if (!qflag) printDev(dev); if (volNum>=dev->nVol) { fprintf(stderr,"This device has only %d volume(s), aborting.\n",dev->nVol); exit(1); } vol = adfMount(dev, volNum, TRUE); if (!vol) { adfUnMountDev(dev); fprintf(stderr, "Can't mount the volume\n"); adfEnvCleanUp(); exit(1); } if (!qflag) { printVol(vol, volNum); putchar('\n'); } if (cflag && isDIRCACHE(vol->dosType) && lflag) { adfChgEnvProp(PR_USEDIRC,&true); if (!qflag) puts("Using dir cache blocks."); } if (lflag) { if (!rflag) { cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEnt(vol,cell->content,"", sflag); cell = cell->next; } adfFreeDirList(list); } else { cell = list = adfGetRDirEnt(vol,vol->curDirPtr,TRUE); printTree(vol,cell,"", sflag); adfFreeDirList(list); } }else if (xflag) { if (rtfiles!=NULL) { files = rtfiles; while(files!=NULL) { if (dirname!=NULL) processFile(vol, (char*)files->content, dirname, extbuf, pflag, qflag); else processFile(vol, (char*)files->content, "", extbuf, pflag, qflag); files = files->next; } freeList(rtfiles); } else { cell = list = adfGetRDirEnt(vol,vol->curDirPtr,TRUE); if (dirname==NULL) extractTree(vol, cell, "", extbuf, pflag, qflag); else extractTree(vol, cell, dirname, extbuf, pflag, qflag); adfFreeDirList(list); } } else help(); free(extbuf); adfUnMount(vol); adfUnMountDev(dev); adfEnvCleanUp(); return(0); }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct List *list, *cell; SECTNUM nSect; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device */ /* testffs.adf */ hd = adfMountDev( argv[1],FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* cd dir_2 */ nSect = adfChangeDir(vol, "dir_2"); cell = list = adfGetDirEnt(vol,vol->curDirPtr); while(cell) { printEntry(cell->content); cell = cell->next; } adfFreeDirList(list); putchar('\n'); /* cd .. */ adfParentDir(vol); list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *in; long len; struct List *list; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device : FFS */ hd = adfMountDev( "testffs.bak",FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } vol = adfMount(hd, 0, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); list = adfGetDirEnt(vol, vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); // adfCreateDir(vol,vol->curDirPtr,"dir_1a"); adfCreateDir(vol,vol->curDirPtr,"dir_1b"); file = adfOpenFile(vol, "newfile","w"); adfCloseFile(file); file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; in = fopen("Check/MOON.GIF","rb"); if (!in) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,in); while(!feof(in)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,in); } if (n>0) adfWriteFile(file, n, buf); // adfFlushFile(file); adfCloseFile(file); fclose(in); adfRemoveEntry(vol,vol->curDirPtr, "dir_1b"); list = adfGetDirEnt(vol, vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }
int main(int argc, char *argv[]) { struct Device *hd; struct Volume *vol; struct File *file; unsigned char buf[600]; long n; FILE *out; long len; struct List *list; adfEnvInitDefault(); // adfSetEnvFct(0,0,MyVer,0); /* mount existing device : FFS */ hd = adfMountDev( "hd.adf",FALSE ); if (!hd) { fprintf(stderr, "can't mount device\n"); adfEnvCleanUp(); exit(1); } adfDeviceInfo(hd); vol = adfMount(hd, 1, FALSE); if (!vol) { adfUnMountDev(hd); fprintf(stderr, "can't mount volume\n"); adfEnvCleanUp(); exit(1); } adfVolumeInfo(vol); /* write one file */ file = adfOpenFile(vol, "moon_gif","w"); if (!file) return 1; out = fopen("Check/MOON.GIF","rb"); if (!out) return 1; len = 600; n = fread(buf,sizeof(unsigned char),len,out); while(!feof(out)) { adfWriteFile(file, n, buf); n = fread(buf,sizeof(unsigned char),len,out); } if (n>0) adfWriteFile(file, n, buf); fclose(out); adfCloseFile(file); /* the directory */ /* list = adfGetDirEnt(vol,vol->curDirPtr); while(list) { printEntry(list->content); adfFreeEntry(list->content); list = list->next; } freeList(list); */ /* re read this file */ file = adfOpenFile(vol, "moon_gif","r"); if (!file) return 1; out = fopen("moon__gif","wb"); if (!out) return 1; len = 300; n = adfReadFile(file, len, buf); while(!adfEndOfFile(file)) { fwrite(buf,sizeof(unsigned char),n,out); n = adfReadFile(file, len, buf); } if (n>0) fwrite(buf,sizeof(unsigned char),n,out); fclose(out); adfCloseFile(file); adfUnMount(vol); adfUnMountDev(hd); adfEnvCleanUp(); return 0; }