Merge pull request #8 from CaitSith2/master

Stop converting all names to uppercase.
Fix CombinationStream seeking.
This commit is contained in:
Alex Barney 2018-08-31 20:09:28 -06:00 committed by GitHub
commit 12fbc1484c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 6 deletions

View file

@ -115,7 +115,7 @@ namespace DiscUtils.Fat
if (_position > _length)
{
throw new IOException("Attempt to read beyond end of file");
return 0;
}
if (count < 0)

View file

@ -414,7 +414,7 @@ namespace DiscUtils.Fat
validChecksum = false;
break;
}
sb.Append(slot.Name.ToUpperInvariant());
sb.Append(slot.Name);
}
if (validChecksum)

View file

@ -1,4 +1,6 @@
using System.IO;
using System;
using System.Collections.Generic;
using System.IO;
namespace LibHac
{
@ -23,12 +25,12 @@ namespace LibHac
public Stream OpenFile(string path, FileMode mode)
{
return new FileStream(path, mode);
return new FileStream(Path.Combine(Root, path), mode);
}
public Stream OpenFile(string path, FileMode mode, FileAccess access)
{
return new FileStream(path, mode, access);
return new FileStream(Path.Combine(Root, path), mode, access);
}
public string[] GetFileSystemEntries(string path, string searchPattern)
@ -38,7 +40,29 @@ namespace LibHac
public string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
{
return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern, searchOption);
//return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern, searchOption);
var result = new List<string>();
try
{
result.AddRange(GetFileSystemEntries(Path.Combine(Root, path), searchPattern));
}
catch (UnauthorizedAccessException) { /* Skip this directory */ }
if (searchOption == SearchOption.TopDirectoryOnly)
return result.ToArray();
var searchDirectories = Directory.GetDirectories(Path.Combine(Root, path));
foreach (var search in searchDirectories)
{
try
{
result.AddRange(GetFileSystemEntries(search, searchPattern, searchOption));
}
catch (UnauthorizedAccessException) { /* Skip this result */ }
}
return result.ToArray();
}
public string GetFullPath(string path)

View file

@ -126,6 +126,7 @@ namespace LibHac.Streams
break;
_currentStream = _streams[_currentStreamIndex++];
_currentStream.Position = 0;
}
}