Add GetFileTimeStampRaw

This commit is contained in:
Alex Barney 2019-05-07 18:30:04 -05:00
parent 6aa15c0691
commit bc22d6dd99
12 changed files with 85 additions and 0 deletions

View file

@ -92,6 +92,20 @@ namespace LibHac.Nand
return Fs.GetFileInfo(path).Length;
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
path = PathTools.Normalize(path);
string localPath = ToDiscUtilsPath(path);
FileTimeStampRaw timeStamp = default;
timeStamp.Created = new DateTimeOffset(Fs.GetCreationTime(localPath)).ToUnixTimeSeconds();
timeStamp.Accessed = new DateTimeOffset(Fs.GetLastAccessTime(localPath)).ToUnixTimeSeconds();
timeStamp.Modified = new DateTimeOffset(Fs.GetLastWriteTime(localPath)).ToUnixTimeSeconds();
return timeStamp;
}
public void Commit() { }
public void CreateDirectory(string path) => throw new NotSupportedException();

View file

@ -179,6 +179,11 @@ namespace LibHac.IO
return BaseFileSystem.GetEntryType(path);
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
return BaseFileSystem.GetFileTimeStampRaw(path);
}
public void Commit()
{
BaseFileSystem.Commit();

View file

@ -198,6 +198,11 @@ namespace LibHac.IO
return BaseFileSystem.GetEntryType(path);
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
return BaseFileSystem.GetFileTimeStampRaw(path);
}
public void Commit()
{
BaseFileSystem.Commit();

View file

@ -0,0 +1,9 @@
namespace LibHac.IO
{
public struct FileTimeStampRaw
{
public long Created;
public long Accessed;
public long Modified;
}
}

View file

@ -33,6 +33,10 @@ namespace LibHac.IO
/// <exception cref="IOException">An I/O error occurred while deleting the directory.</exception>
void DeleteDirectory(string path);
//void DeleteDirectoryRecursively(string path);
//void CleanDirectoryRecursively(string path);
/// <summary>
/// Deletes the specified file.
/// </summary>
@ -101,6 +105,12 @@ namespace LibHac.IO
/// <exception cref="FileNotFoundException">The specified path does not exist.</exception>
DirectoryEntryType GetEntryType(string path);
//long GetFreeSpaceSize(string path);
//long GetTotalSpaceSize(string path);
FileTimeStampRaw GetFileTimeStampRaw(string path);
/// <summary>
/// Commits any changes to a transactional file system.
/// Does nothing if called on a non-transactional file system.

View file

@ -97,6 +97,21 @@ namespace LibHac.IO
throw new FileNotFoundException(path);
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
path = PathTools.Normalize(path);
foreach (IFileSystem fs in Sources)
{
if (fs.FileExists(path) || fs.DirectoryExists(path))
{
return fs.GetFileTimeStampRaw(path);
}
}
throw new FileNotFoundException(path);
}
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId)
{
path = PathTools.Normalize(path);

View file

@ -160,6 +160,20 @@ namespace LibHac.IO
throw new FileNotFoundException(path);
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
path = PathTools.Normalize(path);
string localPath = ResolveLocalPath(path);
FileTimeStampRaw timeStamp = default;
timeStamp.Created = new DateTimeOffset(File.GetCreationTime(localPath)).ToUnixTimeSeconds();
timeStamp.Accessed = new DateTimeOffset(File.GetLastAccessTime(localPath)).ToUnixTimeSeconds();
timeStamp.Modified = new DateTimeOffset(File.GetLastWriteTime(localPath)).ToUnixTimeSeconds();
return timeStamp;
}
public void Commit() { }
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();

View file

@ -81,6 +81,7 @@ namespace LibHac.IO
public void DeleteFile(string path) => throw new NotSupportedException();
public void RenameDirectory(string srcPath, string dstPath) => throw new NotSupportedException();
public void RenameFile(string srcPath, string dstPath) => throw new NotSupportedException();
public FileTimeStampRaw GetFileTimeStampRaw(string path) => throw new NotSupportedException();
public void Commit() { }
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();
}

View file

@ -89,6 +89,7 @@ namespace LibHac.IO.RomFs
public void DeleteFile(string path) => throw new NotSupportedException();
public void RenameDirectory(string srcPath, string dstPath) => throw new NotSupportedException();
public void RenameFile(string srcPath, string dstPath) => throw new NotSupportedException();
public FileTimeStampRaw GetFileTimeStampRaw(string path) => throw new NotSupportedException();
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();
}

View file

@ -195,6 +195,7 @@ namespace LibHac.IO.Save
Commit(Keyset);
}
public FileTimeStampRaw GetFileTimeStampRaw(string path) => throw new NotSupportedException();
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();
public bool Commit(Keyset keyset)

View file

@ -131,6 +131,7 @@ namespace LibHac.IO.Save
}
public FileTimeStampRaw GetFileTimeStampRaw(string path) => throw new NotSupportedException();
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId) => throw new NotSupportedException();
public IStorage GetBaseStorage() => BaseStorage.AsReadOnly();

View file

@ -105,8 +105,17 @@ namespace LibHac.IO
ParentFileSystem.Commit();
}
public FileTimeStampRaw GetFileTimeStampRaw(string path)
{
path = PathTools.Normalize(path);
return ParentFileSystem.GetFileTimeStampRaw(ResolveFullPath(path));
}
public void QueryEntry(Span<byte> outBuffer, Span<byte> inBuffer, string path, QueryId queryId)
{
path = PathTools.Normalize(path);
ParentFileSystem.QueryEntry(outBuffer, inBuffer, ResolveFullPath(path), queryId);
}
}