Directory.java

package libsidutils.directory;

import java.util.ArrayList;
import java.util.Collection;

import static libsidutils.directory.DirEntry.FILETYPE_NONE;
import static libsidutils.directory.DirEntry.toQuotedFilenameAndType;

/**
 *
 * Real directory of a floppy disk.
 * <p>
 * This class represents a floppy disk or tape directory.
 *
 * @author Ken Händel
 *
 */
public abstract class Directory {

    /**
     * Should be true (C-1541) else false (C-1571).
     */
    protected boolean singleSided = true;
    /**
     * Disk/Tape title.
     */
    protected byte[] title;
    /**
     * Disk ID or null (tape).
     */
    protected byte[] id;
    /**
     * Directory entries.
     */
    protected Collection<DirEntry> dirEntries = new ArrayList<>();

    /**
     * Status line to displayed free blocks.
     */
    protected String statusLine;

    public String getTitle() {
        StringBuilder header = new StringBuilder();
        header.append("0 ");
        header.append(toQuotedFilenameAndType(title, FILETYPE_NONE));
        if (id != null) {
            header.append(" ");
            for (byte element : id) {
                header.append((char) (element & 0xff));
            }
        }
        return header.toString();
    }

    public Collection<DirEntry> getDirEntries() {
        return dirEntries;
    }

    public String getStatusLine() {
        return statusLine;
    }

}