mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-10-24 08:02:19 +00:00
Filetype does NOT apply to every file system. Removing it.
This commit is contained in:
1 parent
4caab0a06b
commit
7c8a9ccd26
9 files changed
+68
-34
No files matched your search
@@ -104,7 +104,8 @@ public enum ExportOption {
|
||||
try {
|
||||
List<Path> paths = new ArrayList<>();
|
||||
String name = fileEntry.getName();
|
||||
String ext = fileEntry.getFiletype().toLowerCase();
|
||||
// TODO FIXME
|
||||
String ext = ""; //fileEntry.getFiletype().toLowerCase();
|
||||
int idx = name.lastIndexOf('.');
|
||||
if (idx > -1) {
|
||||
ext = name.substring(idx + 1).toLowerCase();
|
||||
|
||||
@@ -159,11 +159,6 @@ public class ExportOptionTest {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFiletype() {
|
||||
return filetype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBuffer getDataFork() {
|
||||
return dataFork;
|
||||
|
||||
-4
@@ -250,10 +250,6 @@ public class DiskFileStoreAdapter implements FileStore {
|
||||
return fileEntry.getSize();
|
||||
}
|
||||
@Override
|
||||
public String getFiletype() {
|
||||
return fileEntry.getFiletype();
|
||||
}
|
||||
@Override
|
||||
public ContentType getContentType() {
|
||||
if (fileEntry instanceof ProdosFileEntry prodosFileEntry) {
|
||||
return FileMagic.getProdosContentType(prodosFileEntry.getFiletypeByte(),
|
||||
|
||||
@@ -69,8 +69,7 @@ public class ShrinkitFileEntry implements FileEntry {
|
||||
return headerBlock.getUncompressedSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFiletype() {
|
||||
public String getFiletypeText() {
|
||||
if (headerBlock.getFileSysId() == 1) {
|
||||
return FileMagic.getProdosFileTypeText((int) headerBlock.getFileType(), (int) headerBlock.getExtraType());
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public class ShrinkitFileEntry implements FileEntry {
|
||||
public int getStorageType() {
|
||||
return headerBlock.getStorageType();
|
||||
}
|
||||
public String getStorageTypeString() {
|
||||
public String getStorageTypeText() {
|
||||
return switch (getStorageType()) {
|
||||
case 0x1 -> "Seedling";
|
||||
case 0x2 -> "Sapling";
|
||||
@@ -100,7 +99,7 @@ public class ShrinkitFileEntry implements FileEntry {
|
||||
public Date getArchiveWhen() {
|
||||
return headerBlock.getArchiveWhen();
|
||||
}
|
||||
public String getThreadFormat() {
|
||||
public String getThreadFormatText() {
|
||||
return headerBlock.getDataForkThreadRecord()
|
||||
.or(headerBlock::getResourceForkThreadRecord)
|
||||
.map(ThreadRecord::getThreadFormat)
|
||||
@@ -132,7 +131,7 @@ public class ShrinkitFileEntry implements FileEntry {
|
||||
public long getAccess() {
|
||||
return headerBlock.getAccess();
|
||||
}
|
||||
public String getAccessString() {
|
||||
public String getAccessText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String flags = "RWI--BRD"; // string index is bit value
|
||||
for (int i=0; i<flags.length(); i++) {
|
||||
|
||||
@@ -82,14 +82,14 @@ public class ShrinkitFileStore implements FileStore {
|
||||
.addStringField("Name", ShrinkitFileEntry::getName)
|
||||
.addStringField("Sys. Id", ShrinkitFileEntry::getFileSysIdText, Mode.DETAIL)
|
||||
.addIntField("File Sys. Info", ShrinkitFileEntry::getFileSysInfo, "$%04X", Mode.DETAIL)
|
||||
.addStringField("Access", Alignment.CENTER, ShrinkitFileEntry::getAccessString, Mode.DETAIL)
|
||||
.addStringField("Kind", ShrinkitFileEntry::getStorageTypeString)
|
||||
.addStringField("Type", Alignment.CENTER, ShrinkitFileEntry::getFiletype)
|
||||
.addStringField("Access", Alignment.CENTER, ShrinkitFileEntry::getAccessText, Mode.DETAIL)
|
||||
.addStringField("Kind", ShrinkitFileEntry::getStorageTypeText)
|
||||
.addStringField("Type", Alignment.CENTER, ShrinkitFileEntry::getFiletypeText)
|
||||
.addLongField("Aux. Type", ShrinkitFileEntry::getExtraType, "$%04X")
|
||||
.addDateField("Archived", ShrinkitFileEntry::getArchiveWhen)
|
||||
.addDateField("Created", ShrinkitFileEntry::getCreateWhen, Mode.DETAIL)
|
||||
.addDateField("Modified", ShrinkitFileEntry::getModWhen, Mode.DETAIL)
|
||||
.addStringField("Format", ShrinkitFileEntry::getThreadFormat)
|
||||
.addStringField("Format", ShrinkitFileEntry::getThreadFormatText)
|
||||
.addPercentField("Size", ShrinkitFileEntry::getCompressedSize, ShrinkitFileEntry::getSize, "%2.0f%%")
|
||||
.addLongField("Un-Length", ShrinkitFileEntry::getSize)
|
||||
.addIntField("Data CRC", ShrinkitFileEntry::getDataForkCrc, "$%04X", Mode.DETAIL)
|
||||
|
||||
@@ -73,15 +73,6 @@ public class ZipFileEntry implements FileEntry {
|
||||
return entry.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFiletype() {
|
||||
int pos = entry.getName().lastIndexOf('.');
|
||||
if (pos > 0) {
|
||||
return entry.getName().substring(pos + 1);
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
public FileTime getLastModifiedTime() {
|
||||
return entry.getLastModifiedTime();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.applecommander.util.DataBuffer;
|
||||
import java.util.Optional;
|
||||
|
||||
/// A `FileEntry` represents a single file in a file store.
|
||||
/// The generic interface is intentionally spare to keep useless methods to a minimum.
|
||||
public interface FileEntry extends Container {
|
||||
|
||||
/// The parent `Directory`, if applicable. Can return `null` if this is the root directory.
|
||||
@@ -45,10 +46,6 @@ public interface FileEntry extends Container {
|
||||
/// It may be approximate (based off a sector count, for instance).
|
||||
long getSize();
|
||||
|
||||
/// Return the textual representation of the file type, such as "BAS" or "A" for Applesoft.
|
||||
// TODO file type is not always a concept, maybe take this out of the general interface? (CP/M, Zip files for instance)
|
||||
String getFiletype();
|
||||
|
||||
/// Return the file's data.
|
||||
/// This does not include any metadata that may be embedded with the file.
|
||||
DataBuffer getDataFork();
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.applecommander.filestore;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public record ProdosAttributes(String name, int access, int fileType, int auxType, long size, Date creation, Date modified) {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private int access;
|
||||
private int fileType;
|
||||
private int auxType;
|
||||
private long size;
|
||||
private Date creation;
|
||||
private Date modified;
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
public Builder locked() {
|
||||
return access(0x21);
|
||||
}
|
||||
public Builder unlocked() {
|
||||
return access(0xe3);
|
||||
}
|
||||
public Builder access(int access) {
|
||||
this.access = access;
|
||||
return this;
|
||||
}
|
||||
public Builder fileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
return this;
|
||||
}
|
||||
public Builder auxType(int auxType) {
|
||||
this.auxType = auxType;
|
||||
return this;
|
||||
}
|
||||
public Builder size(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
public Builder creation(Date creation) {
|
||||
this.creation = creation;
|
||||
return this;
|
||||
}
|
||||
public Builder modification(Date modified) {
|
||||
this.modified = modified;
|
||||
return this;
|
||||
}
|
||||
public ProdosAttributes build() {
|
||||
return new ProdosAttributes(name, access, fileType, auxType, size, creation, modified);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,11 +70,9 @@ public class GamedosFileEntry implements FileEntry, GamedosConstants {
|
||||
return (long) getSectorCount() * TrackSectorDevice.SECTOR_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFiletype() {
|
||||
return readEntry().getFixedLengthString(ENTRY_TYPE_OFFSET,1);
|
||||
}
|
||||
|
||||
public int getFirstTrack() {
|
||||
return readEntry().getUnsignedByte(ENTRY_TRACK_OFFSET);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user