Check if ISO has Joliet extension by DiscUtils

343 views Asked by At

I'm developing a function to verify if the ISO has Joliet extension. I use DiscUtils to create the ISO file as follow

CDBuilder builder = new CDBuilder();
builder.UseJoliet = true;
builder.VolumeIdentifier = "A_SAMPLE_DISK";
builder.AddFile("x/x.png", @"C:\Users\Circle\Pictures\Image 1.png");
builder.Build(@"C:\temp\sample.iso");

However, when I read the ISO file. It doesn't be recognized as Joliet

using (FileStream isoStream = File.Open(@"C:\temp\sample.iso", FileMode.Open))
{
    CDReader cd = new CDReader(isoStream, true);
    if (cd.ActiveVariant == Iso9660Variant.Joliet)
    {
        // Never enter here
    }
}

Not sure which part I did wrong. Any suggestions?

1

There are 1 answers

0
Anya Shenanigans On

You don't appear to be doing it wrong; however the code won't ever set that ActiveVariant.

If you look at the underlying code, it seems to switch the ActiveVariant to Iso9660Variant.Iso9660 for joliet extensions for the purposes of that field. I don't know the reason for that - it might be a bug, it might have some other esoteric reason for doing it based on some other code in the project.

I've added a couple of comments to the code, and reproduced it here.

case Iso9660Variant.Joliet:
    if (svdPos != 0) // <-- Joliet is always a supplementary table.
    {
        data.Position = svdPos;
        data.Read(buffer, 0, IsoUtilities.SectorSize);
        SupplementaryVolumeDescriptor volDesc = new SupplementaryVolumeDescriptor(buffer, 0);

        Context = new IsoContext { VolumeDescriptor = volDesc, DataStream = _data };
        RootDirectory = new ReaderDirectory(Context,
            new ReaderDirEntry(Context, volDesc.RootDirectory));
        ActiveVariant = Iso9660Variant.Iso9660; // <-- set active variant to base Iso9660
    }

    break;