Skip to content

Commit

Permalink
Fixed some FAT exceptions
Browse files Browse the repository at this point in the history
* Fixed NullReferenceException when parameter object was not supplied to file system class.
* Fixed dictionary exception for FAT with volume name entry, when volume name matched a file name in root directory.
  • Loading branch information
LTRData committed Oct 16, 2024
1 parent 27fc757 commit 36607b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Library/DiscUtils.Fat/Directory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,13 @@ internal void UpdateEntry(long id, DirectoryEntry entry)
private void AddEntryRaw(long pos, DirectoryEntry entry)
{
_entries.Add(pos, entry);

// Update the short and full name lookup tables
_shortFileNameToEntry.Add(entry.Name.ShortName, pos);
_fullFileNameToEntry.Add(entry.Name.FullName, pos);
if (!entry.Attributes.HasFlag(FatAttributes.VolumeId))
{
_shortFileNameToEntry.Add(entry.Name.ShortName, pos);
_fullFileNameToEntry.Add(entry.Name.FullName, pos);
}
}

private void LoadEntries()
Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Fat/FatFileSystemOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal FatFileSystemOptions()

internal FatFileSystemOptions(FileSystemParameters parameters)
{
if (parameters.FileNameEncoding is not null)
if (parameters?.FileNameEncoding is not null)
{
FileNameEncoding = parameters.FileNameEncoding;
}
Expand Down

0 comments on commit 36607b7

Please sign in to comment.