mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add IAttributeFileSystem
This commit is contained in:
parent
8f977554f2
commit
404e05da53
3 changed files with 26 additions and 7 deletions
10
src/LibHac/IO/IAttributeFileSystem.cs
Normal file
10
src/LibHac/IO/IAttributeFileSystem.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace LibHac.IO
|
||||||
|
{
|
||||||
|
public interface IAttributeFileSystem : IFileSystem
|
||||||
|
{
|
||||||
|
FileAttributes GetFileAttributes(string path);
|
||||||
|
long GetFileSize(string path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,13 +25,11 @@ namespace LibHac.IO
|
||||||
|
|
||||||
public IEnumerable<DirectoryEntry> Read()
|
public IEnumerable<DirectoryEntry> Read()
|
||||||
{
|
{
|
||||||
var entries = new List<DirectoryEntry>();
|
|
||||||
|
|
||||||
if (Mode.HasFlag(OpenDirectoryMode.Directories))
|
if (Mode.HasFlag(OpenDirectoryMode.Directories))
|
||||||
{
|
{
|
||||||
foreach (DirectoryInfo dir in DirInfo.EnumerateDirectories())
|
foreach (DirectoryInfo dir in DirInfo.EnumerateDirectories())
|
||||||
{
|
{
|
||||||
entries.Add(new DirectoryEntry(dir.Name, FullPath + '/' + dir.Name, DirectoryEntryType.Directory, 0));
|
yield return new DirectoryEntry(dir.Name, FullPath + '/' + dir.Name, DirectoryEntryType.Directory, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +37,9 @@ namespace LibHac.IO
|
||||||
{
|
{
|
||||||
foreach (FileInfo file in DirInfo.EnumerateFiles())
|
foreach (FileInfo file in DirInfo.EnumerateFiles())
|
||||||
{
|
{
|
||||||
entries.Add(new DirectoryEntry(file.Name, FullPath + '/' + file.Name, DirectoryEntryType.File, file.Length));
|
yield return new DirectoryEntry(file.Name, FullPath + '/' + file.Name, DirectoryEntryType.File, file.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return entries.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetEntryCount()
|
public int GetEntryCount()
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace LibHac.IO
|
namespace LibHac.IO
|
||||||
{
|
{
|
||||||
public class LocalFileSystem : IFileSystem
|
public class LocalFileSystem : IAttributeFileSystem
|
||||||
{
|
{
|
||||||
private string BasePath { get; }
|
private string BasePath { get; }
|
||||||
|
|
||||||
|
@ -17,6 +17,19 @@ namespace LibHac.IO
|
||||||
return Path.Combine(BasePath, path.TrimStart('/'));
|
return Path.Combine(BasePath, path.TrimStart('/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileAttributes GetFileAttributes(string path)
|
||||||
|
{
|
||||||
|
path = PathTools.Normalize(path);
|
||||||
|
return File.GetAttributes(ResolveLocalPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public long GetFileSize(string path)
|
||||||
|
{
|
||||||
|
path = PathTools.Normalize(path);
|
||||||
|
var info = new FileInfo(ResolveLocalPath(path));
|
||||||
|
return info.Length;
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateDirectory(string path)
|
public void CreateDirectory(string path)
|
||||||
{
|
{
|
||||||
path = PathTools.Normalize(path);
|
path = PathTools.Normalize(path);
|
||||||
|
|
Loading…
Reference in a new issue