Use error returning Open() in IFilter.

This commit is contained in:
2021-09-15 13:03:42 +01:00
parent 8982cfc8c9
commit 525fb0da2a
28 changed files with 172 additions and 177 deletions

View File

@@ -33,6 +33,7 @@
using System;
using System.IO;
using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using SharpCompress.Compressors;
using SharpCompress.Compressors.BZip2;
@@ -58,7 +59,6 @@ namespace Aaru.Filters
_dataStream?.Close();
_dataStream = null;
BasePath = null;
Opened = false;
}
/// <inheritdoc />
@@ -151,7 +151,7 @@ namespace Aaru.Filters
}
/// <inheritdoc />
public void Open(byte[] buffer)
public Errno Open(byte[] buffer)
{
_dataStream = new MemoryStream(buffer);
BasePath = null;
@@ -159,11 +159,12 @@ namespace Aaru.Filters
LastWriteTime = CreationTime;
_innerStream = new ForcedSeekStream<BZip2Stream>(_dataStream, CompressionMode.Decompress, false);
DataForkLength = _innerStream.Length;
Opened = true;
return Errno.NoError;
}
/// <inheritdoc />
public void Open(Stream stream)
public Errno Open(Stream stream)
{
_dataStream = stream;
BasePath = null;
@@ -171,11 +172,12 @@ namespace Aaru.Filters
LastWriteTime = CreationTime;
_innerStream = new ForcedSeekStream<BZip2Stream>(_dataStream, CompressionMode.Decompress, false);
DataForkLength = _innerStream.Length;
Opened = true;
return Errno.NoError;
}
/// <inheritdoc />
public void Open(string path)
public Errno Open(string path)
{
_dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
BasePath = System.IO.Path.GetFullPath(path);
@@ -185,7 +187,8 @@ namespace Aaru.Filters
LastWriteTime = fi.LastWriteTimeUtc;
_innerStream = new ForcedSeekStream<BZip2Stream>(_dataStream, CompressionMode.Decompress, false);
DataForkLength = _innerStream.Length;
Opened = true;
return Errno.NoError;
}
/// <inheritdoc />
@@ -218,8 +221,5 @@ namespace Aaru.Filters
/// <inheritdoc />
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc />
public bool Opened { get; private set; }
}
}