当前位置: 首页>>代码示例>>Java>>正文


Java Disk类代码示例

本文整理汇总了Java中com.webcodepro.applecommander.storage.Disk的典型用法代码示例。如果您正苦于以下问题:Java Disk类的具体用法?Java Disk怎么用?Java Disk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Disk类属于com.webcodepro.applecommander.storage包,在下文中一共展示了Disk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextPane

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Get the next WizardPane.
 * Note that the order and size are set, or defaults are
 * chosen.
 */
public WizardPane getNextPane() {
	switch (wizard.getFormat()) {
		case DiskImageWizard.FORMAT_DOS33:
		case DiskImageWizard.FORMAT_RDOS:
		case DiskImageWizard.FORMAT_CPM:
			wizard.setOrder(DiskImageWizard.ORDER_DOS);
			wizard.setSize(Disk.APPLE_140KB_DISK);
			return new DiskImageNamePane(parent, wizard);
		case DiskImageWizard.FORMAT_UNIDOS:
			wizard.setOrder(DiskImageWizard.ORDER_DOS);
			wizard.setSize(Disk.APPLE_800KB_2IMG_DISK);
			return new DiskImageNamePane(parent, wizard);
		case DiskImageWizard.FORMAT_OZDOS:
			wizard.setOrder(DiskImageWizard.ORDER_PRODOS);
			wizard.setSize(Disk.APPLE_800KB_2IMG_DISK);
			return new DiskImageNamePane(parent, wizard);
		case DiskImageWizard.FORMAT_PASCAL:
		case DiskImageWizard.FORMAT_PRODOS:
			wizard.setOrder(DiskImageWizard.ORDER_PRODOS);
			return new DiskImageSizePane(parent, wizard);
	}
	return null;
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:29,代码来源:DiskImageFormatPane.java

示例2: deleteFile

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Delete the file named fileName from the disk named imageName.
 */
static void deleteFile(String imageName, String fileName)
	throws IOException {
	Disk disk = new Disk(imageName);
	Name name = new Name(fileName);
	if (!disk.isSDK() && !disk.isDC42()) {
		FormattedDisk[] formattedDisks = disk.getFormattedDisks();
		for (int i = 0; i < formattedDisks.length; i++) {
			FormattedDisk formattedDisk = formattedDisks[i];
			FileEntry entry = name.getEntry(formattedDisk);
			if (entry != null) {
				entry.delete();
				disk.save();
			} else {
				System.err.println(textBundle.format(
						"CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$
			}
		}
	}
	else
		throw new IOException(textBundle.get("CommandLineSDKReadOnly"));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:25,代码来源:ac.java

示例3: getFiles

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Extract all files in the image according to their respective filetype.
 */
static void getFiles(String imageName, String directory) throws IOException {
	Disk disk = new Disk(imageName);
	if ((directory != null) && (directory.length() > 0)) {
		// Add a final directory separator if the user didn't supply one
		if (!directory.endsWith(File.separator))
			directory = directory + File.separator;
	} else {
		directory = "."+File.separator;
	}
	FormattedDisk[] formattedDisks = disk.getFormattedDisks();
	for (int i = 0; i < formattedDisks.length; i++) {
		FormattedDisk formattedDisk = formattedDisks[i];
		writeFiles(formattedDisk.getFiles(), directory);			
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:19,代码来源:ac.java

示例4: showDirectory

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Display a directory listing of each disk in args.
 */
static void showDirectory(String[] args, int display) throws IOException {
	for (int d = 1; d < args.length; d++) {
		try {
			Disk disk = new Disk(args[d]);
			FormattedDisk[] formattedDisks = disk.getFormattedDisks();
			for (int i = 0; i < formattedDisks.length; i++) {
				FormattedDisk formattedDisk = formattedDisks[i];
				System.out.print(args[d] + " ");
				System.out.println(formattedDisk.getDiskName());
				List files = formattedDisk.getFiles();
				if (files != null) {
					showFiles(files, "", display); //$NON-NLS-1$
				}
				System.out.println(textBundle.format("CommandLineStatus", //$NON-NLS-1$
					new Object[] { formattedDisk.getFormat(),
					new Integer(formattedDisk.getFreeSpace()),
					new Integer(formattedDisk.getUsedSpace()) }));
				System.out.println();
			}
		} catch (RuntimeException e) {
			System.out.println(args[d] + ": " + e.getMessage()); //$NON-NLS-1$
			System.out.println();
		}
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:29,代码来源:ac.java

示例5: getDiskInfo

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Display information about each disk in args.
 */
static void getDiskInfo(String[] args) throws IOException {
	for (int d = 1; d < args.length; d++) {
		Disk disk = new Disk(args[d]);
		FormattedDisk[] formattedDisks = disk.getFormattedDisks();
		for (int i = 0; i < formattedDisks.length; i++) {
			FormattedDisk formattedDisk = formattedDisks[i];
			Iterator iterator = formattedDisk.getDiskInformation().iterator();
			while (iterator.hasNext()) {
				DiskInformation diskinfo = (DiskInformation) iterator.next();
				System.out.println(diskinfo.getLabel() + ": " + diskinfo.getValue());
			}
		}
		System.out.println();
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:19,代码来源:ac.java

示例6: setFileLocked

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Set the lockState of the file named fileName on the disk named imageName.
 * Proposed by David Schmidt.
 */
static void setFileLocked(String imageName, Name name,
	boolean lockState) throws IOException {
	Disk disk = new Disk(imageName);
	if (!disk.isSDK() && !disk.isDC42()) {
		FormattedDisk[] formattedDisks = disk.getFormattedDisks();
		for (int i = 0; i < formattedDisks.length; i++) {
			FormattedDisk formattedDisk = formattedDisks[i];
			FileEntry entry = name.getEntry(formattedDisk);
			if (entry != null) {
				entry.setLocked(lockState);
				disk.save();
			} else {
				System.err.println(textBundle.format(
					"CommandLineNoMatchMessage", name.fullName)); //$NON-NLS-1$
			}
		}
	}
	else
		throw new IOException(textBundle.get("CommandLineSDKReadOnly"));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:25,代码来源:ac.java

示例7: getSize

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Compute the size of this file (in bytes).
 * @see com.webcodepro.applecommander.storage.FileEntry#getSize()
 */
public int getSize() {
	byte[] rawdata = null;
	if (!isDeleted()) {
		rawdata = disk.getFileData(this);
	}
	// default to nothing special, just compute from number of sectors
	int size = (getSectorsUsed()-1) * Disk.SECTOR_SIZE;
	if (size < 1) size = 0;	// we assume a T/S block is included (may not be)
	if (rawdata != null) {
		if ("B".equals(getFiletype())) { //$NON-NLS-1$
			// binary
			return AppleUtil.getWordValue(rawdata, 2);
		} else if ("A".equals(getFiletype()) || "I".equals(getFiletype())) { //$NON-NLS-1$ //$NON-NLS-2$
			// applesoft, integer basic
			return AppleUtil.getWordValue(rawdata, 0);
		}
	}
	return size;
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:24,代码来源:DosFileEntry.java

示例8: getOffset

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Compute the track and sector offset into the disk image.
 * This takes into account what type of format is being dealt
 * with.
 */
protected int getOffset(int track, int sector) throws IllegalArgumentException {
	if (!isSizeApprox(Disk.APPLE_140KB_DISK) 
		&& !isSizeApprox(Disk.APPLE_800KB_DISK)
		&& !isSizeApprox(Disk.APPLE_800KB_2IMG_DISK)
		&& track != 0 && sector != 0) {		// HACK: Allows boot sector writing
		throw new IllegalArgumentException(
				textBundle.get("DosOrder.UnrecognizedFormatError")); //$NON-NLS-1$
	}
	int offset = (track * getSectorsPerTrack() + sector) * Disk.SECTOR_SIZE;
	if (offset > getPhysicalSize()) {
		throw new IllegalArgumentException(
			textBundle.format("DosOrder.InvalidSizeError", //$NON-NLS-1$
					track, sector));
	}
	return offset;
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:22,代码来源:DosOrder.java

示例9: testChangeDosImageOrder

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
public void testChangeDosImageOrder() throws DiskFullException {
	// Straight DOS disk in standard DOS order
	DosFormatDisk dosDiskDosOrder = DosFormatDisk.create("dostemp.dsk",  //$NON-NLS-1$
		new DosOrder(new ByteArrayImageLayout(Disk.APPLE_140KB_DISK)))[0];
	FileEntry fileEntry = dosDiskDosOrder.createFile();
	fileEntry.setFilename("TESTFILE"); //$NON-NLS-1$
	fileEntry.setFiletype("T"); //$NON-NLS-1$
	fileEntry.setFileData("This is a test file.".getBytes()); //$NON-NLS-1$
	// A duplicate - then we change it to a NIB disk image...
	DosFormatDisk dosDiskNibbleOrder = DosFormatDisk.create("dostemp2.nib", //$NON-NLS-1$
		new NibbleOrder(new ByteArrayImageLayout(Disk.APPLE_140KB_DISK)))[0];
	AppleUtil.changeImageOrderByTrackAndSector(dosDiskDosOrder.getImageOrder(),
		dosDiskNibbleOrder.getImageOrder());
	// Confirm that these disks are identical:
	assertTrue(AppleUtil.disksEqualByTrackAndSector(dosDiskDosOrder, dosDiskNibbleOrder));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:17,代码来源:AppleUtilTest.java

示例10: testChangeProdosImageOrder

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
public void testChangeProdosImageOrder() throws DiskFullException {
	// Straight ProDOS disk in standard ProDOS block order
	ProdosFormatDisk prodosDiskDosOrder = ProdosFormatDisk.create("prodostemp.po",  //$NON-NLS-1$
		"prodostemp", //$NON-NLS-1$
		new ProdosOrder(new ByteArrayImageLayout(Disk.APPLE_140KB_DISK)))[0];
	FileEntry fileEntry = prodosDiskDosOrder.createFile();
	fileEntry.setFilename("TESTFILE"); //$NON-NLS-1$
	fileEntry.setFiletype("TXT"); //$NON-NLS-1$
	fileEntry.setFileData("This is a test file.".getBytes()); //$NON-NLS-1$
	// A duplicate - then we change it to a NIB disk image...
	ProdosFormatDisk prodosDiskNibbleOrder = ProdosFormatDisk.create("prodostemp2.nib", //$NON-NLS-1$
		"prodostemp2", //$NON-NLS-1$
		new NibbleOrder(new ByteArrayImageLayout(Disk.APPLE_140KB_DISK)))[0];
	AppleUtil.changeImageOrderByBlock(prodosDiskDosOrder.getImageOrder(),
		prodosDiskNibbleOrder.getImageOrder());
	// Confirm that these disks are identical:
	assertTrue(AppleUtil.disksEqualByBlock(prodosDiskDosOrder, prodosDiskNibbleOrder));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:19,代码来源:AppleUtilTest.java

示例11: getDirFromImg

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Extract all the files and subdirectories from one directory in an image file, and
 * write them to the local filesystem.
 * 
 * @throws IOException        if something goes wrong
 * @throws DiskFullException  this actually can't happen (because we're not creating dirs)
 */
static void getDirFromImg(String imgFile, String srcImgDir, String dstLocalDir) throws IOException, DiskFullException
{
  // Create the local dir if necessary.
  File localDirFile = new File(dstLocalDir);
  localDirFile.mkdirs();
  
  // Open the image file and get the disk inside it.
  FormattedDisk fd = new Disk(imgFile).getFormattedDisks()[0];

  // Locate the right subdirectory on the disk.
  DirectoryEntry imgDir = findSubDir(fd, srcImgDir, false);
  
  // Recursively extract the files from that subdirectory.
  getAllFiles((List<FileEntry>)imgDir.getFiles(), localDirFile);
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:23,代码来源:A2Copy.java

示例12: putDirToImg

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Put a whole directory of files/subdirs from the local filesystem into a 
 * subdirectory of an image file.
 * 
 * @param imgFilePath         path to the image file
 * @param dstImgDir           subdirectory in the image file, or "/" for the root
 * @param srcLocalDir         directory containing files and subdirs
 * @throws DiskFullException  if the image file fills up
 * @throws IOException        if something else goes wrong
 */
static void putDirToImg(String imgFilePath, String dstImgDir, String srcLocalDir)
  throws IOException, DiskFullException 
{
  // Make sure the local dir exists.
  File localDirFile = new File(srcLocalDir);
  if (!localDirFile.isDirectory()) {
    System.err.format("Error: Local directory '%s' not found.\n", srcLocalDir);
    System.exit(2);
  }
  
  // Open the image file.
  FormattedDisk fd = new Disk(imgFilePath).getFormattedDisks()[0];
  
  // Get to the right sub-directory.
  DirectoryEntry ent = findSubDir(fd, dstImgDir, true);
  
  // And fill it up.
  putAllFiles(fd, ent, localDirFile);
}
 
开发者ID:badvision,项目名称:lawless-legends,代码行数:30,代码来源:A2Copy.java

示例13: openFile

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Open a file.
 */
protected void openFile() {
	FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
	FilenameFilter[] fileFilters = Disk.getFilenameFilters();
	String[] names = new String[fileFilters.length];
	String[] extensions = new String[fileFilters.length];
	for (int i=0; i<fileFilters.length; i++) {
		names[i] = fileFilters[i].getNames();
		extensions[i] = fileFilters[i].getExtensions();
	}
	fileDialog.setFilterNames(names);
	fileDialog.setFilterExtensions(extensions);
	fileDialog.setFilterPath(userPreferences.getDiskImageDirectory());
	String fullpath = fileDialog.open();
	
	if (fullpath != null) {
		userPreferences.setDiskImageDirectory(fileDialog.getFilterPath());
		try {
			Disk disk = new Disk(fullpath);
			FormattedDisk[] formattedDisks = disk.getFormattedDisks();
			if (formattedDisks != null) {
				DiskWindow window = new DiskWindow(shell, formattedDisks, imageManager);
				window.open();
			} else {
				showUnrecognizedDiskFormatMessage(fullpath);
			}
		} catch (Exception ignored) {
			ignored.printStackTrace();
			showUnrecognizedDiskFormatMessage(fullpath);
		}
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:35,代码来源:SwtAppleCommander.java

示例14: putFile

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Put fileName from the local filesytem into the file named fileOnImageName on the disk named imageName;
 * Note: only volume level supported; input size unlimited.
 */
public static void putFile(String fileName, String imageName, String fileOnImageName, String fileType, String address) throws IOException, DiskFullException {
	Name name = new Name(fileOnImageName);
	File file = new File(fileName);
	if (!file.canRead())
	{
		throw new IOException("Unable to read input file named "+fileName+"."); // FIXME - NLS
	}
	ByteArrayOutputStream buf = new ByteArrayOutputStream();
	byte[] inb = new byte[1024];
	int byteCount = 0;
	InputStream is = new FileInputStream(file);
	while ((byteCount = is.read(inb)) > 0) {
		buf.write(inb, 0, byteCount);
	}
	Disk disk = new Disk(imageName);
	FormattedDisk[] formattedDisks = disk.getFormattedDisks();
	FormattedDisk formattedDisk = formattedDisks[0];
	FileEntry entry = name.createEntry(formattedDisk);
	if (entry != null) {
		entry.setFiletype(fileType);
		entry.setFilename(name.name);
		entry.setFileData(buf.toByteArray());
		if (entry.needsAddress()) {
			entry.setAddress(stringToInt(address));
		}
		formattedDisk.save();
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:33,代码来源:ac.java

示例15: setDiskName

import com.webcodepro.applecommander.storage.Disk; //导入依赖的package包/类
/**
 * Set the volume name for a given disk image. Only effective for ProDOS or
 * Pascal disks; others ignored. Proposed by David Schmidt.
 */
public static void setDiskName(String imageName, String volName)
	throws IOException {
	Disk disk = new Disk(imageName);
	if (!disk.isSDK() && !disk.isDC42()) {
		FormattedDisk[] formattedDisks = disk.getFormattedDisks();
		FormattedDisk formattedDisk = formattedDisks[0];
		formattedDisk.setDiskName(volName);
		formattedDisks[0].save();
	}
	else
		throw new IOException(textBundle.get("CommandLineSDKReadOnly"));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:17,代码来源:ac.java


注:本文中的com.webcodepro.applecommander.storage.Disk类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。