mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
f1b660b95f
I don't know about this. It seems really easy to screw something up. Allows using the same code for reading the raw nand and reading a normal file system
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System.IO;
|
|
|
|
namespace libhac
|
|
{
|
|
public class FileSystem : IFileSystem
|
|
{
|
|
public string Root { get; }
|
|
|
|
public FileSystem(string rootDir)
|
|
{
|
|
Root = Path.GetFullPath(rootDir);
|
|
}
|
|
|
|
public bool FileExists(string path)
|
|
{
|
|
return File.Exists(Path.Combine(Root, path));
|
|
}
|
|
|
|
public bool DirectoryExists(string path)
|
|
{
|
|
return Directory.Exists(Path.Combine(Root, path));
|
|
}
|
|
|
|
public Stream OpenFile(string path, FileMode mode)
|
|
{
|
|
return new FileStream(path, mode);
|
|
}
|
|
|
|
public Stream OpenFile(string path, FileMode mode, FileAccess access)
|
|
{
|
|
return new FileStream(path, mode, access);
|
|
}
|
|
|
|
public string[] GetFileSystemEntries(string path, string searchPattern)
|
|
{
|
|
return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern);
|
|
}
|
|
|
|
public string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
|
|
{
|
|
return Directory.GetFileSystemEntries(Path.Combine(Root, path), searchPattern, searchOption);
|
|
}
|
|
|
|
public string GetFullPath(string path)
|
|
{
|
|
return Path.Combine(Root, path);
|
|
}
|
|
}
|
|
}
|