mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Simplify ISO9660 namespaces.
This commit is contained in:
@@ -43,11 +43,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
Normal,
|
||||
Vms,
|
||||
Joliet,
|
||||
JolietNormal,
|
||||
Rrip,
|
||||
RripNormal,
|
||||
RripJoliet,
|
||||
RripJolietNormal
|
||||
Rrip
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,42 +86,20 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
switch(@namespace)
|
||||
{
|
||||
case Namespace.Normal:
|
||||
contents.Add(entry.IsoFilename.EndsWith(";1", StringComparison.Ordinal)
|
||||
? entry.IsoFilename.Substring(0, entry.IsoFilename.Length - 2)
|
||||
: entry.IsoFilename);
|
||||
contents.Add(entry.Filename.EndsWith(";1", StringComparison.Ordinal)
|
||||
? entry.Filename.Substring(0, entry.Filename.Length - 2)
|
||||
: entry.Filename);
|
||||
|
||||
break;
|
||||
case Namespace.Vms:
|
||||
contents.Add(entry.IsoFilename);
|
||||
contents.Add(entry.Filename);
|
||||
break;
|
||||
case Namespace.Joliet:
|
||||
// TODO: Implement Joliet
|
||||
break;
|
||||
case Namespace.JolietNormal:
|
||||
// TODO: Implement Joliet
|
||||
contents.Add(entry.IsoFilename.EndsWith(";1", StringComparison.Ordinal)
|
||||
? entry.IsoFilename.Substring(0, entry.IsoFilename.Length - 2)
|
||||
: entry.IsoFilename);
|
||||
break;
|
||||
case Namespace.Rrip:
|
||||
// TODO: Implement RRIP
|
||||
break;
|
||||
case Namespace.RripNormal:
|
||||
// TODO: Implement RRIP
|
||||
contents.Add(entry.IsoFilename.EndsWith(";1", StringComparison.Ordinal)
|
||||
? entry.IsoFilename.Substring(0, entry.IsoFilename.Length - 2)
|
||||
: entry.IsoFilename);
|
||||
break;
|
||||
case Namespace.RripJoliet:
|
||||
// TODO: Implement RRIP
|
||||
// TODO: Implement Joliet
|
||||
break;
|
||||
case Namespace.RripJolietNormal:
|
||||
// TODO: Implement RRIP
|
||||
// TODO: Implement Joliet
|
||||
contents.Add(entry.IsoFilename.EndsWith(";1", StringComparison.Ordinal)
|
||||
? entry.IsoFilename.Substring(0, entry.IsoFilename.Length - 2)
|
||||
: entry.IsoFilename);
|
||||
break;
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -161,12 +139,12 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
Flags = record.flags,
|
||||
Interleave = record.interleave,
|
||||
VolumeSequenceNumber = record.volume_sequence_number,
|
||||
IsoFilename =
|
||||
Filename =
|
||||
Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize, record.name_len),
|
||||
Timestamp = DecodeHighSierraDateTime(record.date)
|
||||
};
|
||||
|
||||
if(!entries.ContainsKey(entry.IsoFilename)) entries.Add(entry.IsoFilename, entry);
|
||||
if(!entries.ContainsKey(entry.Filename)) entries.Add(entry.Filename, entry);
|
||||
|
||||
entryOff += record.length;
|
||||
}
|
||||
@@ -175,7 +153,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
}
|
||||
|
||||
// TODO: Implement system area
|
||||
Dictionary<string, DecodedDirectoryEntry> DecodeIsoDirectory(byte[] data, bool joliet = false)
|
||||
Dictionary<string, DecodedDirectoryEntry> DecodeIsoDirectory(byte[] data)
|
||||
{
|
||||
Dictionary<string, DecodedDirectoryEntry> entries = new Dictionary<string, DecodedDirectoryEntry>();
|
||||
int entryOff = 0;
|
||||
@@ -201,28 +179,25 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
Extent = record.size == 0 ? 0 : record.extent,
|
||||
Size = record.size,
|
||||
Flags = record.flags,
|
||||
Filename =
|
||||
joliet
|
||||
? Encoding.BigEndianUnicode.GetString(data, entryOff + DirectoryRecordSize,
|
||||
record.name_len)
|
||||
: Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize, record.name_len),
|
||||
FileUnitSize = record.file_unit_size,
|
||||
Interleave = record.interleave,
|
||||
VolumeSequenceNumber = record.volume_sequence_number,
|
||||
Timestamp = DecodeIsoDateTime(record.date)
|
||||
};
|
||||
|
||||
if(joliet)
|
||||
entry.JolietFilename =
|
||||
Encoding.BigEndianUnicode.GetString(data, entryOff + DirectoryRecordSize, record.name_len);
|
||||
else
|
||||
entry.IsoFilename = Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize, record.name_len);
|
||||
|
||||
// TODO: Multi-extent files
|
||||
if(entry.Flags.HasFlag(FileFlags.Associated))
|
||||
{
|
||||
// TODO: Detect if Apple extensions, as associated files contain the resource fork there
|
||||
|
||||
if(entries.ContainsKey(joliet ? entry.JolietFilename : entry.IsoFilename))
|
||||
entries[joliet ? entry.JolietFilename : entry.IsoFilename].AssociatedFile = entry;
|
||||
if(entries.ContainsKey(entry.Filename)) entries[entry.Filename].AssociatedFile = entry;
|
||||
else
|
||||
{
|
||||
entries[joliet ? entry.JolietFilename : entry.IsoFilename] = new DecodedDirectoryEntry
|
||||
entries[entry.Filename] = new DecodedDirectoryEntry
|
||||
{
|
||||
Extent = 0,
|
||||
Size = 0,
|
||||
@@ -230,27 +205,21 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
FileUnitSize = 0,
|
||||
Interleave = 0,
|
||||
VolumeSequenceNumber = record.volume_sequence_number,
|
||||
IsoFilename =
|
||||
Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize, record.name_len),
|
||||
Filename = joliet
|
||||
? Encoding.BigEndianUnicode.GetString(data,
|
||||
entryOff + DirectoryRecordSize,
|
||||
record.name_len)
|
||||
: Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize,
|
||||
record.name_len),
|
||||
Timestamp = DecodeIsoDateTime(record.date),
|
||||
AssociatedFile = entry
|
||||
};
|
||||
|
||||
if(joliet)
|
||||
entries[entry.JolietFilename].JolietFilename =
|
||||
Encoding.BigEndianUnicode.GetString(data, entryOff + DirectoryRecordSize,
|
||||
record.name_len);
|
||||
else
|
||||
entries[entry.IsoFilename].IsoFilename =
|
||||
Encoding.ASCII.GetString(data, entryOff + DirectoryRecordSize, record.name_len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(entries.ContainsKey(joliet ? entry.JolietFilename : entry.IsoFilename))
|
||||
entry.AssociatedFile =
|
||||
entries[joliet ? entry.JolietFilename : entry.IsoFilename].AssociatedFile;
|
||||
entries[joliet ? entry.JolietFilename : entry.IsoFilename] = entry;
|
||||
if(entries.ContainsKey(entry.Filename))
|
||||
entry.AssociatedFile = entries[entry.Filename].AssociatedFile;
|
||||
entries[entry.Filename] = entry;
|
||||
}
|
||||
|
||||
entryOff += record.length;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
bool debug;
|
||||
bool highSierra;
|
||||
IMediaImage image;
|
||||
Dictionary<string, DecodedDirectoryEntry> jolietRootDirectoryCache;
|
||||
bool joliet;
|
||||
bool mounted;
|
||||
Namespace @namespace;
|
||||
Dictionary<string, DecodedDirectoryEntry> rootDirectoryCache;
|
||||
@@ -67,11 +67,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
{"normal", "Primary Volume Descriptor, ignoring ;1 suffixes"},
|
||||
{"vms", "Primary Volume Descriptor, showing version suffixes"},
|
||||
{"joliet", "Joliet Volume Descriptor"},
|
||||
{"joliet+normal", "Joliet with fallback to normal"},
|
||||
{"rrip", "Rock Ridge"},
|
||||
{"rrip+normal", "Rock Ridge with fallback to normal"},
|
||||
{"rrip+joliet", "Rock Ridge with fallback to Joliet"},
|
||||
{"rrip+joliet+normal", "Rock Ridge with fallback to Joliet and then to normal (default)"}
|
||||
{"rrip", "Rock Ridge"}
|
||||
};
|
||||
|
||||
public Errno ReadLink(string path, out string dest)
|
||||
|
||||
@@ -59,16 +59,15 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
{
|
||||
public DecodedDirectoryEntry AssociatedFile;
|
||||
public uint Extent;
|
||||
public string Filename;
|
||||
public byte FileUnitSize;
|
||||
public FileFlags Flags;
|
||||
public byte Interleave;
|
||||
public string IsoFilename;
|
||||
public uint Size;
|
||||
public DateTime? Timestamp;
|
||||
public ushort VolumeSequenceNumber;
|
||||
public string JolietFilename;
|
||||
|
||||
public override string ToString() => JolietFilename ?? IsoFilename;
|
||||
public override string ToString() => Filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,21 +37,9 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
case "joliet":
|
||||
this.@namespace = Namespace.Joliet;
|
||||
break;
|
||||
case "joliet+normal":
|
||||
this.@namespace = Namespace.JolietNormal;
|
||||
break;
|
||||
case "rrip":
|
||||
this.@namespace = Namespace.Rrip;
|
||||
break;
|
||||
case "rrip+normal":
|
||||
this.@namespace = Namespace.RripNormal;
|
||||
break;
|
||||
case "rrip+joliet":
|
||||
this.@namespace = Namespace.RripJoliet;
|
||||
break;
|
||||
case "rrip+joliet+normal":
|
||||
this.@namespace = Namespace.RripJolietNormal;
|
||||
break;
|
||||
default: return Errno.InvalidArgument;
|
||||
}
|
||||
|
||||
@@ -183,20 +171,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
if((highSierra || cdi) && this.@namespace != Namespace.Normal && this.@namespace != Namespace.Vms)
|
||||
this.@namespace = Namespace.Normal;
|
||||
|
||||
if(jolietvd is null)
|
||||
switch(this.@namespace)
|
||||
{
|
||||
case Namespace.Joliet:
|
||||
case Namespace.JolietNormal:
|
||||
this.@namespace = Namespace.Normal;
|
||||
break;
|
||||
case Namespace.RripJoliet:
|
||||
this.@namespace = Namespace.Rrip;
|
||||
break;
|
||||
case Namespace.RripJolietNormal:
|
||||
this.@namespace = Namespace.RripNormal;
|
||||
break;
|
||||
}
|
||||
if(jolietvd is null && this.@namespace == Namespace.Joliet) this.@namespace = Namespace.Normal;
|
||||
|
||||
uint rootLocation = 0;
|
||||
uint rootSize = 0;
|
||||
@@ -241,9 +216,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
XmlFsType.Type = fsFormat;
|
||||
|
||||
if(jolietvd != null && this.@namespace != Namespace.Normal &&
|
||||
this.@namespace != Namespace.Vms &&
|
||||
this.@namespace != Namespace.Rrip && this.@namespace != Namespace.RripNormal)
|
||||
if(jolietvd != null && this.@namespace == Namespace.Joliet)
|
||||
{
|
||||
rootLocation = jolietvd.Value.root_directory_record.extent;
|
||||
|
||||
@@ -253,9 +226,11 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
if(rootLocation + rootSize >= imagePlugin.Info.Sectors) return Errno.InvalidArgument;
|
||||
|
||||
joliet = true;
|
||||
|
||||
rootDir = imagePlugin.ReadSectors(rootLocation, rootSize);
|
||||
|
||||
jolietRootDirectoryCache = DecodeIsoDirectory(rootDir, true);
|
||||
rootDirectoryCache = DecodeIsoDirectory(rootDir);
|
||||
|
||||
XmlFsType.VolumeName = decodedJolietVd.VolumeIdentifier;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user