Skip to content

Commit

Permalink
Recognize "Probable" embedded images
Browse files Browse the repository at this point in the history
We use a pretty narrow definition, because we don't want to have
false-positives.  This change adds $F1 to the set of possible
ProDOS file types (which was previously just BIN and NON), and
accepts files with an unrecognized filename extension if their
length is exactly 140kiB.

(issue #35)
  • Loading branch information
fadden committed Oct 26, 2024
1 parent 8ea42cd commit 49a9f8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion AppCommon/FileIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static bool HasDiskImageAttribs(IFileEntry entry, string gzipName, out st
if (!looksGood && !hasProType && entry.HasProDOSTypes) {
proType = entry.FileType;
proAux = entry.AuxType;
hasProType = true;
}
if (!looksGood) {
if (proType == FileAttribs.FILE_TYPE_LBR &&
Expand All @@ -145,9 +146,16 @@ public static bool HasDiskImageAttribs(IFileEntry entry, string gzipName, out st
// If it's BIN or NON, or totally typeless (ZIP), test the filename extension.
if ((!hasProType /*&& !entry.HasHFSTypes*/) ||
(hasProType && (proType == FileAttribs.FILE_TYPE_NON ||
proType == FileAttribs.FILE_TYPE_BIN))) {
proType == FileAttribs.FILE_TYPE_BIN ||
proType == FileAttribs.FILE_TYPE_F1))) {
if (ExtInSet(ext, sDiskExts)) {
looksGood = true;
} else if (entry.DataLength == 140 * 1024) {
// File is exactly the size of a 140KB floppy disk image. It didn't have
// a recognized disk image filename extension, so let's assume it's in
// DOS sector order.
ext = ".do";
looksGood = true;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DiskArc/DAExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ public static bool IsMacZipHeader(this IFileEntry entry) {
return false;
}

#endregion
#endregion IFileEntry

#region IMetadata

Expand All @@ -768,6 +768,6 @@ public static bool IsMacZipHeader(this IFileEntry entry) {
return null;
}

#endregion
#endregion IMetadata
}
}
1 change: 1 addition & 0 deletions DiskArc/FileAttribs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public sealed class FileAttribs {
public const int FILE_TYPE_SND = 0xd8;
public const int FILE_TYPE_LBR = 0xe0;
public const int FILE_TYPE_CMD = 0xf0;
public const int FILE_TYPE_F1 = 0xf1;
public const int FILE_TYPE_F2 = 0xf2;
public const int FILE_TYPE_F3 = 0xf3;
public const int FILE_TYPE_F4 = 0xf4;
Expand Down

0 comments on commit 49a9f8f

Please sign in to comment.