mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use error returning Open() in IFilter.
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user