Exemple #1
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();

    /* 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;
    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;
}
Exemple #3
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;
}
Exemple #4
0
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;
}