mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add GetFileTimeStampRaw
This commit is contained in:
parent
6aa15c0691
commit
bc22d6dd99
12 changed files with 85 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
9
src/LibHac/IO/FileTimeStamp.cs
Normal file
9
src/LibHac/IO/FileTimeStamp.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace LibHac.IO
|
||||
{
|
||||
public struct FileTimeStampRaw
|
||||
{
|
||||
public long Created;
|
||||
public long Accessed;
|
||||
public long Modified;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue