/* * AppleCommander - An Apple ][ image utility. * Copyright (C) 2002 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.pascal; import java.util.ArrayList; import java.util.BitSet; import java.util.Date; import java.util.Iterator; import java.util.List; import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.AppleUtil; /** * Manages a disk that is in the Pascal format. *

* Date created: Oct 4, 2002 11:56:50 PM * @author Rob Greene */ public class PascalFormatDisk extends FormattedDisk { /** * The size of the Pascal file entry. */ public static final int ENTRY_SIZE = 26; /** * The number of Pascal blocks on a 140K disk. */ public static final int PASCAL_BLOCKS_ON_140K_DISK = 280; // filetypes used elsewhere in the code: private static final String TEXTFILE = "textfile"; private static final String CODEFILE = "codefile"; private static final String DATAFILE = "datafile"; /** * The know filetypes for a Pascal disk. */ private static final String[] filetypes = { "xdskfile", CODEFILE, TEXTFILE, "infofile", DATAFILE, "graffile", "fotofile", "securedir" }; /** * Use this inner interface for managing the disk usage data. * This offloads format-specific implementation to the implementing class. * A BitSet is used to track all blocks, as Pascal disks do not have a * bitmap stored on the disk. This is safe since we know the number of blocks * that exist. (BitSet length is of last set bit - unset bits at the end are * "lost".) */ private class PascalDiskUsage implements DiskUsage { private int location = -1; private BitSet bitmap = null; public boolean hasNext() { return location == -1 || location < getBlocksOnDisk() - 1; } public void next() { if (bitmap == null) { bitmap = new BitSet(getBlocksOnDisk()); // assume all blocks are unused for (int block=6; block 0) { String what = filename.substring(pos+1); if ("txt".equalsIgnoreCase(what)) { filetype = TEXTFILE; } else if ("pas".equalsIgnoreCase(what)) { filetype = CODEFILE; } } return filetype; } /** * Returns a list of possible file types. Since the filetype is * specific to each operating system, a simple String is used. */ public String[] getFiletypes() { return filetypes; } /** * Indicates if this filetype requires an address component. * No Pascal filetypes require or support an address. */ public boolean needsAddress(String filetype) { return false; } /** * Indicates if this FormattedDisk supports a disk map. */ public boolean supportsDiskMap() { return true; } /** * Change to a different ImageOrder. Remains in Pascal format but * the underlying order can chage. * @see ImageOrder */ public void changeImageOrder(ImageOrder imageOrder) { AppleUtil.changeImageOrderByBlock(getImageOrder(), imageOrder); setImageOrder(imageOrder); } }