/* * AppleCommander - An Apple ][ image utility. * Copyright (C) 2002-3 by Robert Greene * robgreene at users.sourceforge.net * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.webcodepro.applecommander.storage.os.rdos; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileFilter; import com.webcodepro.applecommander.storage.FormattedDisk; import com.webcodepro.applecommander.storage.StorageBundle; import com.webcodepro.applecommander.storage.filters.ApplesoftFileFilter; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.TextBundle; /** * Handle RDOS file entry format. *
* Since I was unable to locate the file entries on the internet, it is documented here:
*
* Offset Description
* ====== ====================================================
* $00-$17 File name; space-filled. If the first byte is $00, that is the end of the
* directory. If the first byte is $80, the file is deleted.
* $18 File type. Appears to be actual letter ('A'=Applesoft, etc)
* $19 File length in blocks (block = sector = 256 bytes)
* $1A-$1B Address of application. For Applesoft and binary; others may vary.
* $1C-$1D Length in bytes of file.
* $1E-$1F Starting block of application.
*
*
* Date created: Oct 7, 2002 1:36:56 PM
* @author Rob Greene
*/
public class RdosFileEntry implements FileEntry {
private TextBundle textBundle = StorageBundle.getInstance();
private byte[] fileEntry;
private RdosFormatDisk disk;
/**
* Constructor for RdosFileEntry.
*/
public RdosFileEntry(byte[] fileEntry, RdosFormatDisk disk) {
super();
this.fileEntry = fileEntry;
this.disk = disk;
}
/**
* Return the number of blocks this file uses.
*/
public int getSizeInBlocks() {
return AppleUtil.getUnsignedByte(fileEntry[0x19]);
}
/**
* Return the starting block of this application.
*/
public int getStartingBlock() {
return AppleUtil.getWordValue(fileEntry, 0x1e);
}
/**
* Return the address of application.
*/
public int getAddress() {
return AppleUtil.getWordValue(fileEntry, 0x1a);
}
/**
* Return the name of this file.
*/
public String getFilename() {
return isDeleted() ? textBundle.get("RdosFileEntry.NotInUse") : AppleUtil.getString(fileEntry, 0, 24).trim(); //$NON-NLS-1$
}
/**
* Set the name of this file.
*/
public void setFilename(String filename) {
// FIXME: Need to implement!
}
/**
* Return the maximum filename length.
*/
public int getMaximumFilenameLength() {
return 24;
}
/**
* Return the filetype of this file.
*/
public String getFiletype() {
return isDeleted() ? " " : AppleUtil.getString(fileEntry, 0x18, 1); //$NON-NLS-1$
}
/**
* Set the filetype.
*/
public void setFiletype(String filetype) {
// FIXME: Implement!
}
/**
* Locked doesn't appear to be a concept under RDOS.
*/
public boolean isLocked() {
return false;
}
/**
* Set the lock indicator.
*/
public void setLocked(boolean lock) {
// FIXME: Implement!
}
/**
* Compute the size of this file (in bytes).
*/
public int getSize() {
return AppleUtil.getWordValue(fileEntry, 0x1c);
}
/**
* RDOS does not support directories.
*/
public boolean isDirectory() {
return false;
}
/**
* Retrieve the list of files in this directory.
* Since RDOS does not support directories, this will always return null.
*/
public List