diff --git a/Interfaces/IReadOnlyFilesystem.cs b/Interfaces/IReadOnlyFilesystem.cs index b16c447..1189aba 100644 --- a/Interfaces/IReadOnlyFilesystem.cs +++ b/Interfaces/IReadOnlyFilesystem.cs @@ -39,10 +39,13 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; +using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; +using FileSystemInfo = Aaru.CommonTypes.Structs.FileSystemInfo; namespace Aaru.CommonTypes.Interfaces; @@ -136,6 +139,34 @@ public interface IReadOnlyFilesystem : IFilesystem /// The file node. /// Error number. ErrorNumber CloseFile(IFileNode node); + + /// Move the file node position pointer to the specified position with the specified origin + /// The file node. + /// Desired position. + /// From where in the file to move the position pointer to. + /// Error number. + ErrorNumber Seek(IFileNode node, long position, SeekOrigin origin) + { + if(node is null) + return ErrorNumber.InvalidArgument; + + long desiredPosition = origin switch + { + SeekOrigin.Begin => position, + SeekOrigin.End => node.Length + position, + _ => node.Offset + position + }; + + if(desiredPosition < 0) + return ErrorNumber.InvalidArgument; + + if(desiredPosition >= node.Length) + return ErrorNumber.InvalidArgument; + + node.Offset = desiredPosition; + + return ErrorNumber.NoError; + } } /// Represents an opened file from a filesystem @@ -146,5 +177,5 @@ public interface IFileNode /// File length long Length { get; } /// Current position in file - long Offset { get; } + long Offset { get; set; } } \ No newline at end of file