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

@@ -36,6 +36,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Helpers; using Aaru.Helpers;
using Marshal = Aaru.Helpers.Marshal; using Marshal = Aaru.Helpers.Marshal;
@@ -74,54 +75,50 @@ namespace Aaru.Filters
{ {
0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 0x56, 0x41, 0x58, 0x20, 0x56, 0x4D, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
}; };
string _basePath;
DateTime _creationTime;
Entry _dataFork; Entry _dataFork;
Header _header; Header _header;
string _headerPath; string _headerPath;
DateTime _lastWriteTime;
bool _opened;
Entry _rsrcFork; Entry _rsrcFork;
/// <inheritdoc /> /// <inheritdoc />
public string Name => "AppleDouble"; public string Name => "AppleDouble";
/// <inheritdoc /> /// <inheritdoc />
public Guid Id => new Guid("1B2165EE-C9DF-4B21-BBBB-9E5892B2DF4D"); public Guid Id => new("1B2165EE-C9DF-4B21-BBBB-9E5892B2DF4D");
/// <inheritdoc /> /// <inheritdoc />
public string Author => "Natalia Portillo"; public string Author => "Natalia Portillo";
/// <inheritdoc /> /// <inheritdoc />
public void Close() => _opened = false; public void Close() {}
/// <inheritdoc /> /// <inheritdoc />
public string GetBasePath() => _basePath; public string BasePath { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public DateTime GetCreationTime() => _creationTime; public DateTime CreationTime { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public long GetDataForkLength() => _dataFork.length; public long DataForkLength => _dataFork.length;
/// <inheritdoc /> /// <inheritdoc />
public Stream GetDataForkStream() => new FileStream(_basePath, FileMode.Open, FileAccess.Read); public Stream GetDataForkStream() => new FileStream(BasePath, FileMode.Open, FileAccess.Read);
/// <inheritdoc /> /// <inheritdoc />
public string GetFilename() => Path.GetFileName(_basePath); public string Filename => System.IO.Path.GetFileName(BasePath);
/// <inheritdoc /> /// <inheritdoc />
public DateTime GetLastWriteTime() => _lastWriteTime; public DateTime LastWriteTime { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public long GetLength() => _dataFork.length + _rsrcFork.length; public long Length => _dataFork.length + _rsrcFork.length;
/// <inheritdoc /> /// <inheritdoc />
public string GetParentFolder() => Path.GetDirectoryName(_basePath); public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc /> /// <inheritdoc />
public string GetPath() => _basePath; public string Path => BasePath;
/// <inheritdoc /> /// <inheritdoc />
public long GetResourceForkLength() => _rsrcFork.length; public long ResourceForkLength => _rsrcFork.length;
/// <inheritdoc /> /// <inheritdoc />
public Stream GetResourceForkStream() public Stream GetResourceForkStream()
@@ -134,7 +131,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public bool HasResourceFork() => _rsrcFork.length > 0; public bool HasResourceFork => _rsrcFork.length > 0;
/// <inheritdoc /> /// <inheritdoc />
public bool Identify(byte[] buffer) => false; public bool Identify(byte[] buffer) => false;
@@ -145,9 +142,9 @@ namespace Aaru.Filters
/// <inheritdoc /> /// <inheritdoc />
public bool Identify(string path) public bool Identify(string path)
{ {
string filename = Path.GetFileName(path); string filename = System.IO.Path.GetFileName(path);
string filenameNoExt = Path.GetFileNameWithoutExtension(path); string filenameNoExt = System.IO.Path.GetFileNameWithoutExtension(path);
string parentFolder = Path.GetDirectoryName(path); string parentFolder = System.IO.Path.GetDirectoryName(path);
parentFolder ??= ""; parentFolder ??= "";
@@ -156,28 +153,28 @@ namespace Aaru.Filters
return false; return false;
// Prepend data fork name with "R." // Prepend data fork name with "R."
string proDosAppleDouble = Path.Combine(parentFolder, "R." + filename); string proDosAppleDouble = System.IO.Path.Combine(parentFolder, "R." + filename);
// Prepend data fork name with '%' // Prepend data fork name with '%'
string unixAppleDouble = Path.Combine(parentFolder, "%" + filename); string unixAppleDouble = System.IO.Path.Combine(parentFolder, "%" + filename);
// Change file extension to ADF // Change file extension to ADF
string dosAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); string dosAppleDouble = System.IO.Path.Combine(parentFolder, filenameNoExt + ".ADF");
// Change file extension to adf // Change file extension to adf
string dosAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); string dosAppleDoubleLower = System.IO.Path.Combine(parentFolder, filenameNoExt + ".adf");
// Store AppleDouble header file in ".AppleDouble" folder with same name // Store AppleDouble header file in ".AppleDouble" folder with same name
string netatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); string netatalkAppleDouble = System.IO.Path.Combine(parentFolder, ".AppleDouble", filename);
// Store AppleDouble header file in "resource.frk" folder with same name // Store AppleDouble header file in "resource.frk" folder with same name
string daveAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); string daveAppleDouble = System.IO.Path.Combine(parentFolder, "resource.frk", filename);
// Prepend data fork name with "._" // Prepend data fork name with "._"
string osxAppleDouble = Path.Combine(parentFolder, "._" + filename); string osxAppleDouble = System.IO.Path.Combine(parentFolder, "._" + filename);
// Adds ".rsrc" extension // Adds ".rsrc" extension
string unArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); string unArAppleDouble = System.IO.Path.Combine(parentFolder, filename + ".rsrc");
// Check AppleDouble created by A/UX in ProDOS filesystem // Check AppleDouble created by A/UX in ProDOS filesystem
if(File.Exists(proDosAppleDouble)) if(File.Exists(proDosAppleDouble))
@@ -322,53 +319,50 @@ namespace Aaru.Filters
return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2); return _header.magic == MAGIC && (_header.version == VERSION || _header.version == VERSION2);
} }
/// <inheritdoc />
public bool IsOpened() => _opened;
// Now way to have two files in a single byte array // Now way to have two files in a single byte array
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) => throw new NotSupportedException(); public Errno Open(byte[] buffer) => Errno.NotSupported;
// Now way to have two files in a single stream // Now way to have two files in a single stream
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) => throw new NotSupportedException(); public Errno Open(Stream stream) => Errno.NotSupported;
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
string filename = Path.GetFileName(path); string filename = System.IO.Path.GetFileName(path);
string filenameNoExt = Path.GetFileNameWithoutExtension(path); string filenameNoExt = System.IO.Path.GetFileNameWithoutExtension(path);
string parentFolder = Path.GetDirectoryName(path); string parentFolder = System.IO.Path.GetDirectoryName(path);
parentFolder ??= ""; parentFolder ??= "";
if(filename is null || if(filename is null ||
filenameNoExt is null) filenameNoExt is null)
throw new ArgumentNullException(nameof(path)); return Errno.InvalidArgument;
// Prepend data fork name with "R." // Prepend data fork name with "R."
string proDosAppleDouble = Path.Combine(parentFolder, "R." + filename); string proDosAppleDouble = System.IO.Path.Combine(parentFolder, "R." + filename);
// Prepend data fork name with '%' // Prepend data fork name with '%'
string unixAppleDouble = Path.Combine(parentFolder, "%" + filename); string unixAppleDouble = System.IO.Path.Combine(parentFolder, "%" + filename);
// Change file extension to ADF // Change file extension to ADF
string dosAppleDouble = Path.Combine(parentFolder, filenameNoExt + ".ADF"); string dosAppleDouble = System.IO.Path.Combine(parentFolder, filenameNoExt + ".ADF");
// Change file extension to adf // Change file extension to adf
string dosAppleDoubleLower = Path.Combine(parentFolder, filenameNoExt + ".adf"); string dosAppleDoubleLower = System.IO.Path.Combine(parentFolder, filenameNoExt + ".adf");
// Store AppleDouble header file in ".AppleDouble" folder with same name // Store AppleDouble header file in ".AppleDouble" folder with same name
string netatalkAppleDouble = Path.Combine(parentFolder, ".AppleDouble", filename); string netatalkAppleDouble = System.IO.Path.Combine(parentFolder, ".AppleDouble", filename);
// Store AppleDouble header file in "resource.frk" folder with same name // Store AppleDouble header file in "resource.frk" folder with same name
string daveAppleDouble = Path.Combine(parentFolder, "resource.frk", filename); string daveAppleDouble = System.IO.Path.Combine(parentFolder, "resource.frk", filename);
// Prepend data fork name with "._" // Prepend data fork name with "._"
string osxAppleDouble = Path.Combine(parentFolder, "._" + filename); string osxAppleDouble = System.IO.Path.Combine(parentFolder, "._" + filename);
// Adds ".rsrc" extension // Adds ".rsrc" extension
string unArAppleDouble = Path.Combine(parentFolder, filename + ".rsrc"); string unArAppleDouble = System.IO.Path.Combine(parentFolder, filename + ".rsrc");
// Check AppleDouble created by A/UX in ProDOS filesystem // Check AppleDouble created by A/UX in ProDOS filesystem
if(File.Exists(proDosAppleDouble)) if(File.Exists(proDosAppleDouble))
@@ -514,6 +508,10 @@ namespace Aaru.Filters
} }
} }
// TODO: More appropriate error
if(_headerPath is null)
return Errno.NotSupported;
var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read); var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin); fs.Seek(0, SeekOrigin.Begin);
@@ -530,8 +528,8 @@ namespace Aaru.Filters
entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(entry); entries[i] = Marshal.ByteArrayToStructureBigEndian<Entry>(entry);
} }
_creationTime = DateTime.UtcNow; CreationTime = DateTime.UtcNow;
_lastWriteTime = _creationTime; LastWriteTime = CreationTime;
foreach(Entry entry in entries) foreach(Entry entry in entries)
switch((EntryId)entry.id) switch((EntryId)entry.id)
@@ -546,8 +544,8 @@ namespace Aaru.Filters
FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(datesB); FileDates dates = Marshal.ByteArrayToStructureBigEndian<FileDates>(datesB);
_creationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate); CreationTime = DateHandlers.UnixUnsignedToDateTime(dates.creationDate);
_lastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(dates.modificationDate);
break; break;
case EntryId.FileInfo: case EntryId.FileInfo:
@@ -559,28 +557,28 @@ namespace Aaru.Filters
{ {
MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(finfo); MacFileInfo macinfo = Marshal.ByteArrayToStructureBigEndian<MacFileInfo>(finfo);
_creationTime = DateHandlers.MacToDateTime(macinfo.creationDate); CreationTime = DateHandlers.MacToDateTime(macinfo.creationDate);
_lastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate); LastWriteTime = DateHandlers.MacToDateTime(macinfo.modificationDate);
} }
else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) else if(_proDosHome.SequenceEqual(_header.homeFilesystem))
{ {
ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo); ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian<ProDOSFileInfo>(finfo);
_creationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate);
_lastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate);
} }
else if(_unixHome.SequenceEqual(_header.homeFilesystem)) else if(_unixHome.SequenceEqual(_header.homeFilesystem))
{ {
UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo); UnixFileInfo unixinfo = Marshal.ByteArrayToStructureBigEndian<UnixFileInfo>(finfo);
_creationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate); CreationTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.creationDate);
_lastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(unixinfo.modificationDate);
} }
else if(_dosHome.SequenceEqual(_header.homeFilesystem)) else if(_dosHome.SequenceEqual(_header.homeFilesystem))
{ {
DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(finfo); DOSFileInfo dosinfo = Marshal.ByteArrayToStructureBigEndian<DOSFileInfo>(finfo);
_lastWriteTime = LastWriteTime =
DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime); DateHandlers.DosToDateTime(dosinfo.modificationDate, dosinfo.modificationTime);
} }
@@ -604,8 +602,9 @@ namespace Aaru.Filters
} }
fs.Close(); fs.Close();
_opened = true; BasePath = path;
_basePath = path;
return Errno.NoError;
} }
enum EntryId : uint enum EntryId : uint

View File

@@ -36,6 +36,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Helpers; using Aaru.Helpers;
using Marshal = Aaru.Helpers.Marshal; using Marshal = Aaru.Helpers.Marshal;
@@ -96,7 +97,6 @@ namespace Aaru.Filters
_isBytes = false; _isBytes = false;
_isStream = false; _isStream = false;
_isPath = false; _isPath = false;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -217,10 +217,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public bool Opened { get; private set; } public Errno Open(byte[] buffer)
/// <inheritdoc />
public void Open(byte[] buffer)
{ {
var ms = new MemoryStream(buffer); var ms = new MemoryStream(buffer);
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);
@@ -301,13 +298,14 @@ namespace Aaru.Filters
} }
ms.Close(); ms.Close();
Opened = true;
_isBytes = true; _isBytes = true;
_bytes = buffer; _bytes = buffer;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
@@ -387,13 +385,14 @@ namespace Aaru.Filters
} }
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
Opened = true;
_isStream = true; _isStream = true;
_stream = stream; _stream = stream;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
var fs = new FileStream(path, FileMode.Open, FileAccess.Read); var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin); fs.Seek(0, SeekOrigin.Begin);
@@ -474,9 +473,10 @@ namespace Aaru.Filters
} }
fs.Close(); fs.Close();
Opened = true;
_isPath = true; _isPath = true;
BasePath = path; BasePath = path;
return Errno.NoError;
} }
enum AppleSingleEntryID : uint enum AppleSingleEntryID : uint

View File

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

View File

@@ -34,6 +34,7 @@ using System;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Helpers; using Aaru.Helpers;
namespace Aaru.Filters namespace Aaru.Filters
@@ -59,7 +60,6 @@ namespace Aaru.Filters
_dataStream?.Close(); _dataStream?.Close();
_dataStream = null; _dataStream = null;
BasePath = null; BasePath = null;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -109,7 +109,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) public Errno Open(byte[] buffer)
{ {
byte[] mtimeB = new byte[4]; byte[] mtimeB = new byte[4];
byte[] isizeB = new byte[4]; byte[] isizeB = new byte[4];
@@ -132,11 +132,11 @@ namespace Aaru.Filters
_zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress); _zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress);
Opened = true; return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
byte[] mtimeB = new byte[4]; byte[] mtimeB = new byte[4];
byte[] isizeB = new byte[4]; byte[] isizeB = new byte[4];
@@ -159,11 +159,11 @@ namespace Aaru.Filters
_zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress); _zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress);
Opened = true; return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
byte[] mtimeB = new byte[4]; byte[] mtimeB = new byte[4];
byte[] isizeB = new byte[4]; byte[] isizeB = new byte[4];
@@ -185,7 +185,8 @@ namespace Aaru.Filters
CreationTime = fi.CreationTimeUtc; CreationTime = fi.CreationTimeUtc;
LastWriteTime = DateHandlers.UnixUnsignedToDateTime(mtime); LastWriteTime = DateHandlers.UnixUnsignedToDateTime(mtime);
_zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress); _zStream = new ForcedSeekStream<GZipStream>(_decompressedSize, _dataStream, CompressionMode.Decompress);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -218,8 +219,5 @@ namespace Aaru.Filters
/// <inheritdoc /> /// <inheritdoc />
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath); public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc />
public bool Opened { get; private set; }
} }
} }

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.IO; using System.IO;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using SharpCompress.Compressors; using SharpCompress.Compressors;
using SharpCompress.Compressors.LZMA; using SharpCompress.Compressors.LZMA;
@@ -58,7 +59,6 @@ namespace Aaru.Filters
_dataStream?.Close(); _dataStream?.Close();
_dataStream = null; _dataStream = null;
BasePath = null; BasePath = null;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -111,7 +111,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) public Errno Open(byte[] buffer)
{ {
_dataStream = new MemoryStream(buffer); _dataStream = new MemoryStream(buffer);
BasePath = null; BasePath = null;
@@ -121,11 +121,11 @@ namespace Aaru.Filters
_innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress); _innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress);
Opened = true; return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
_dataStream = stream; _dataStream = stream;
BasePath = null; BasePath = null;
@@ -137,11 +137,12 @@ namespace Aaru.Filters
DataForkLength = BitConverter.ToInt64(tmp, 0); DataForkLength = BitConverter.ToInt64(tmp, 0);
_dataStream.Seek(0, SeekOrigin.Begin); _dataStream.Seek(0, SeekOrigin.Begin);
_innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress); _innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
_dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
BasePath = System.IO.Path.GetFullPath(path); BasePath = System.IO.Path.GetFullPath(path);
@@ -155,7 +156,8 @@ namespace Aaru.Filters
DataForkLength = BitConverter.ToInt64(tmp, 0); DataForkLength = BitConverter.ToInt64(tmp, 0);
_dataStream.Seek(0, SeekOrigin.Begin); _dataStream.Seek(0, SeekOrigin.Begin);
_innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress); _innerStream = new ForcedSeekStream<LZipStream>(DataForkLength, _dataStream, CompressionMode.Decompress);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -188,8 +190,5 @@ namespace Aaru.Filters
/// <inheritdoc /> /// <inheritdoc />
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath); public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc />
public bool Opened { get; private set; }
} }
} }

View File

@@ -35,6 +35,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Helpers; using Aaru.Helpers;
using Marshal = Aaru.Helpers.Marshal; using Marshal = Aaru.Helpers.Marshal;
@@ -68,7 +69,6 @@ namespace Aaru.Filters
_isBytes = false; _isBytes = false;
_isStream = false; _isStream = false;
_isPath = false; _isPath = false;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -198,10 +198,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public bool Opened { get; private set; } public Errno Open(byte[] buffer)
/// <inheritdoc />
public void Open(byte[] buffer)
{ {
var ms = new MemoryStream(buffer); var ms = new MemoryStream(buffer);
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);
@@ -229,13 +226,14 @@ namespace Aaru.Filters
LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);
ms.Close(); ms.Close();
Opened = true;
_isBytes = true; _isBytes = true;
_bytes = buffer; _bytes = buffer;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
@@ -262,13 +260,14 @@ namespace Aaru.Filters
LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
Opened = true;
_isStream = true; _isStream = true;
_stream = stream; _stream = stream;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
var fs = new FileStream(path, FileMode.Open, FileAccess.Read); var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin); fs.Seek(0, SeekOrigin.Begin);
@@ -296,9 +295,10 @@ namespace Aaru.Filters
LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime); LastWriteTime = DateHandlers.MacToDateTime(_header.modificationTime);
fs.Close(); fs.Close();
Opened = true;
_isPath = true; _isPath = true;
BasePath = path; BasePath = path;
return Errno.NoError;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@@ -38,6 +38,7 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Helpers; using Aaru.Helpers;
using Marshal = System.Runtime.InteropServices.Marshal; using Marshal = System.Runtime.InteropServices.Marshal;
@@ -62,7 +63,7 @@ namespace Aaru.Filters
public string Author => "Natalia Portillo"; public string Author => "Natalia Portillo";
/// <inheritdoc /> /// <inheritdoc />
public void Close() => Opened = false; public void Close() {}
/// <inheritdoc /> /// <inheritdoc />
public string BasePath { get; private set; } public string BasePath { get; private set; }
@@ -170,16 +171,13 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public bool Opened { get; private set; } public Errno Open(byte[] buffer) => Errno.NotSupported;
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) => throw new NotSupportedException(); public Errno Open(Stream stream) => Errno.NotSupported;
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) => throw new NotSupportedException(); public Errno Open(string path)
/// <inheritdoc />
public void Open(string path)
{ {
string parentFolder = System.IO.Path.GetDirectoryName(path); string parentFolder = System.IO.Path.GetDirectoryName(path);
string baseFilename = System.IO.Path.GetFileName(path); string baseFilename = System.IO.Path.GetFileName(path);
@@ -239,9 +237,10 @@ namespace Aaru.Filters
ResourceForkLength = new FileInfo(_rsrcPath ?? throw new InvalidOperationException()).Length; ResourceForkLength = new FileInfo(_rsrcPath ?? throw new InvalidOperationException()).Length;
BasePath = path; BasePath = path;
Opened = true;
finderDatStream.Close(); finderDatStream.Close();
return Errno.NoError;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.IO; using System.IO;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using SharpCompress.Compressors.Xz; using SharpCompress.Compressors.Xz;
namespace Aaru.Filters namespace Aaru.Filters
@@ -57,7 +58,6 @@ namespace Aaru.Filters
_dataStream?.Close(); _dataStream?.Close();
_dataStream = null; _dataStream = null;
BasePath = null; BasePath = null;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -123,7 +123,7 @@ namespace Aaru.Filters
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) public Errno Open(byte[] buffer)
{ {
_dataStream = new MemoryStream(buffer); _dataStream = new MemoryStream(buffer);
BasePath = null; BasePath = null;
@@ -131,11 +131,12 @@ namespace Aaru.Filters
LastWriteTime = CreationTime; LastWriteTime = CreationTime;
GuessSize(); GuessSize();
_innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream); _innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
_dataStream = stream; _dataStream = stream;
BasePath = null; BasePath = null;
@@ -143,11 +144,12 @@ namespace Aaru.Filters
LastWriteTime = CreationTime; LastWriteTime = CreationTime;
GuessSize(); GuessSize();
_innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream); _innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
_dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
BasePath = System.IO.Path.GetFullPath(path); BasePath = System.IO.Path.GetFullPath(path);
@@ -157,7 +159,8 @@ namespace Aaru.Filters
LastWriteTime = fi.LastWriteTimeUtc; LastWriteTime = fi.LastWriteTimeUtc;
GuessSize(); GuessSize();
_innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream); _innerStream = new ForcedSeekStream<XZStream>(DataForkLength, _dataStream);
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -191,9 +194,6 @@ namespace Aaru.Filters
/// <inheritdoc /> /// <inheritdoc />
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath); public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc />
public bool Opened { get; private set; }
void GuessSize() void GuessSize()
{ {
DataForkLength = 0; DataForkLength = 0;

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.IO; using System.IO;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
namespace Aaru.Filters namespace Aaru.Filters
{ {
@@ -55,7 +56,6 @@ namespace Aaru.Filters
_dataStream?.Close(); _dataStream?.Close();
_dataStream = null; _dataStream = null;
BasePath = null; BasePath = null;
Opened = false;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -83,34 +83,37 @@ namespace Aaru.Filters
public bool Identify(string path) => File.Exists(path); public bool Identify(string path) => File.Exists(path);
/// <inheritdoc /> /// <inheritdoc />
public void Open(byte[] buffer) public Errno Open(byte[] buffer)
{ {
_dataStream = new MemoryStream(buffer); _dataStream = new MemoryStream(buffer);
BasePath = null; BasePath = null;
CreationTime = DateTime.UtcNow; CreationTime = DateTime.UtcNow;
LastWriteTime = CreationTime; LastWriteTime = CreationTime;
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(Stream stream) public Errno Open(Stream stream)
{ {
_dataStream = stream; _dataStream = stream;
BasePath = null; BasePath = null;
CreationTime = DateTime.UtcNow; CreationTime = DateTime.UtcNow;
LastWriteTime = CreationTime; LastWriteTime = CreationTime;
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
public void Open(string path) public Errno Open(string path)
{ {
_dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
BasePath = System.IO.Path.GetFullPath(path); BasePath = System.IO.Path.GetFullPath(path);
var fi = new FileInfo(path); var fi = new FileInfo(path);
CreationTime = fi.CreationTimeUtc; CreationTime = fi.CreationTimeUtc;
LastWriteTime = fi.LastWriteTimeUtc; LastWriteTime = fi.LastWriteTimeUtc;
Opened = true;
return Errno.NoError;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -133,8 +136,5 @@ namespace Aaru.Filters
/// <inheritdoc /> /// <inheritdoc />
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath); public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
/// <inheritdoc />
public bool Opened { get; private set; }
} }
} }

View File

@@ -37,6 +37,7 @@ using System.IO;
using System.Linq; using System.Linq;
using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Console; using Aaru.Console;
using Aaru.Filters; using Aaru.Filters;
using Aaru.Helpers; using Aaru.Helpers;
@@ -126,9 +127,8 @@ namespace Aaru.DiscImages
} }
var trackFilter = new ZZZNoFilter(); var trackFilter = new ZZZNoFilter();
trackFilter.Open(trackfile);
if(!trackFilter.Opened) if(trackFilter.Open(trackfile) != Errno.NoError)
throw new IOException("Could not open KryoFlux track file."); throw new IOException("Could not open KryoFlux track file.");
_imageInfo.CreationTime = DateTime.MaxValue; _imageInfo.CreationTime = DateTime.MaxValue;

View File

@@ -369,7 +369,7 @@ namespace Aaru.DiscImages
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(basename + sidecar.name); IFilter filter = filters.GetFilter(basename + sidecar.name);
if(filter.Opened != true) if(filter is null)
continue; continue;
AaruConsole.DebugWriteLine("ZZZRawImage Plugin", "Found media tag {0}", sidecar.tag); AaruConsole.DebugWriteLine("ZZZRawImage Plugin", "Found media tag {0}", sidecar.tag);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -103,8 +104,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -101,8 +102,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -103,8 +104,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -101,8 +102,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -101,8 +102,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -101,8 +102,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -101,8 +102,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new AppleDouble(); IFilter filter = new AppleDouble();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using NUnit.Framework; using NUnit.Framework;
namespace Aaru.Tests.Filters namespace Aaru.Tests.Filters
@@ -92,8 +93,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new Aaru.Filters.AppleSingle(); IFilter filter = new Aaru.Filters.AppleSingle();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using NUnit.Framework; using NUnit.Framework;
namespace Aaru.Tests.Filters namespace Aaru.Tests.Filters
@@ -81,8 +82,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new Aaru.Filters.BZip2(); IFilter filter = new Aaru.Filters.BZip2();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using NUnit.Framework; using NUnit.Framework;
namespace Aaru.Tests.Filters namespace Aaru.Tests.Filters
@@ -81,8 +82,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new Aaru.Filters.GZip(); IFilter filter = new Aaru.Filters.GZip();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using NUnit.Framework; using NUnit.Framework;
namespace Aaru.Tests.Filters namespace Aaru.Tests.Filters
@@ -81,8 +82,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new Aaru.Filters.LZip(); IFilter filter = new Aaru.Filters.LZip();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -93,8 +94,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -93,8 +94,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -93,8 +94,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new MacBinary(); IFilter filter = new MacBinary();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(286, filter.ResourceForkLength); Assert.AreEqual(286, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using NUnit.Framework; using NUnit.Framework;
namespace Aaru.Tests.Filters namespace Aaru.Tests.Filters
@@ -94,8 +95,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new Aaru.Filters.PcExchange(); IFilter filter = new Aaru.Filters.PcExchange();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(737280, filter.DataForkLength); Assert.AreEqual(737280, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(546, filter.ResourceForkLength); Assert.AreEqual(546, filter.ResourceForkLength);

View File

@@ -29,6 +29,7 @@
using System.IO; using System.IO;
using Aaru.Checksums; using Aaru.Checksums;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.Filters; using Aaru.Filters;
using NUnit.Framework; using NUnit.Framework;
@@ -82,8 +83,7 @@ namespace Aaru.Tests.Filters
public void Test() public void Test()
{ {
IFilter filter = new XZ(); IFilter filter = new XZ();
filter.Open(_location); Assert.AreEqual(Errno.NoError, filter.Open(_location));
Assert.AreEqual(true, filter.Opened);
Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreEqual(1048576, filter.DataForkLength);
Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreNotEqual(null, filter.GetDataForkStream());
Assert.AreEqual(0, filter.ResourceForkLength); Assert.AreEqual(0, filter.ResourceForkLength);