diff --git a/Aaru.Filters/Aaru.Filters.csproj b/Aaru.Filters/Aaru.Filters.csproj
index 7fb764694..c770f70d7 100644
--- a/Aaru.Filters/Aaru.Filters.csproj
+++ b/Aaru.Filters/Aaru.Filters.csproj
@@ -58,7 +58,7 @@
-
+
diff --git a/Aaru.Filters/Aaru.Filters.csproj.DotSettings b/Aaru.Filters/Aaru.Filters.csproj.DotSettings
index 68a94f578..10e52454d 100644
--- a/Aaru.Filters/Aaru.Filters.csproj.DotSettings
+++ b/Aaru.Filters/Aaru.Filters.csproj.DotSettings
@@ -2,4 +2,4 @@
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve">
True
\ No newline at end of file
+ x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=localization/@EntryIndexedValue">True
\ No newline at end of file
diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs
index f1f878938..86a9857d0 100644
--- a/Aaru.Filters/AppleDouble.cs
+++ b/Aaru.Filters/AppleDouble.cs
@@ -61,10 +61,14 @@ public sealed class AppleDouble : IFilter
string _headerPath;
Entry _rsrcFork;
+#region IFilter Members
+
///
public string Name => Localization.AppleDouble_Name;
+
///
public Guid Id => new("1B2165EE-C9DF-4B21-BBBB-9E5892B2DF4D");
+
///
public string Author => Authors.NataliaPortillo;
@@ -164,7 +168,7 @@ public sealed class AppleDouble : IFilter
if(prodosStream.Length > 26)
{
- byte[] prodosB = new byte[26];
+ var prodosB = new byte[26];
prodosStream.EnsureRead(prodosB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(prodosB);
prodosStream.Close();
@@ -181,7 +185,7 @@ public sealed class AppleDouble : IFilter
if(unixStream.Length > 26)
{
- byte[] unixB = new byte[26];
+ var unixB = new byte[26];
unixStream.EnsureRead(unixB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(unixB);
unixStream.Close();
@@ -198,7 +202,7 @@ public sealed class AppleDouble : IFilter
if(dosStream.Length > 26)
{
- byte[] dosB = new byte[26];
+ var dosB = new byte[26];
dosStream.EnsureRead(dosB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(dosB);
dosStream.Close();
@@ -215,7 +219,7 @@ public sealed class AppleDouble : IFilter
if(doslStream.Length > 26)
{
- byte[] doslB = new byte[26];
+ var doslB = new byte[26];
doslStream.EnsureRead(doslB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(doslB);
doslStream.Close();
@@ -232,7 +236,7 @@ public sealed class AppleDouble : IFilter
if(netatalkStream.Length > 26)
{
- byte[] netatalkB = new byte[26];
+ var netatalkB = new byte[26];
netatalkStream.EnsureRead(netatalkB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(netatalkB);
netatalkStream.Close();
@@ -249,7 +253,7 @@ public sealed class AppleDouble : IFilter
if(daveStream.Length > 26)
{
- byte[] daveB = new byte[26];
+ var daveB = new byte[26];
daveStream.EnsureRead(daveB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(daveB);
daveStream.Close();
@@ -266,7 +270,7 @@ public sealed class AppleDouble : IFilter
if(osxStream.Length > 26)
{
- byte[] osxB = new byte[26];
+ var osxB = new byte[26];
osxStream.EnsureRead(osxB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(osxB);
osxStream.Close();
@@ -285,7 +289,7 @@ public sealed class AppleDouble : IFilter
if(unarStream.Length <= 26)
return false;
- byte[] unarB = new byte[26];
+ var unarB = new byte[26];
unarStream.EnsureRead(unarB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(unarB);
unarStream.Close();
@@ -345,7 +349,7 @@ public sealed class AppleDouble : IFilter
if(prodosStream.Length > 26)
{
- byte[] prodosB = new byte[26];
+ var prodosB = new byte[26];
prodosStream.EnsureRead(prodosB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(prodosB);
prodosStream.Close();
@@ -362,7 +366,7 @@ public sealed class AppleDouble : IFilter
if(unixStream.Length > 26)
{
- byte[] unixB = new byte[26];
+ var unixB = new byte[26];
unixStream.EnsureRead(unixB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(unixB);
unixStream.Close();
@@ -379,7 +383,7 @@ public sealed class AppleDouble : IFilter
if(dosStream.Length > 26)
{
- byte[] dosB = new byte[26];
+ var dosB = new byte[26];
dosStream.EnsureRead(dosB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(dosB);
dosStream.Close();
@@ -396,7 +400,7 @@ public sealed class AppleDouble : IFilter
if(doslStream.Length > 26)
{
- byte[] doslB = new byte[26];
+ var doslB = new byte[26];
doslStream.EnsureRead(doslB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(doslB);
doslStream.Close();
@@ -413,7 +417,7 @@ public sealed class AppleDouble : IFilter
if(netatalkStream.Length > 26)
{
- byte[] netatalkB = new byte[26];
+ var netatalkB = new byte[26];
netatalkStream.EnsureRead(netatalkB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(netatalkB);
netatalkStream.Close();
@@ -430,7 +434,7 @@ public sealed class AppleDouble : IFilter
if(daveStream.Length > 26)
{
- byte[] daveB = new byte[26];
+ var daveB = new byte[26];
daveStream.EnsureRead(daveB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(daveB);
daveStream.Close();
@@ -447,7 +451,7 @@ public sealed class AppleDouble : IFilter
if(osxStream.Length > 26)
{
- byte[] osxB = new byte[26];
+ var osxB = new byte[26];
osxStream.EnsureRead(osxB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(osxB);
osxStream.Close();
@@ -464,7 +468,7 @@ public sealed class AppleDouble : IFilter
if(unarStream.Length > 26)
{
- byte[] unarB = new byte[26];
+ var unarB = new byte[26];
unarStream.EnsureRead(unarB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(unarB);
unarStream.Close();
@@ -481,15 +485,15 @@ public sealed class AppleDouble : IFilter
var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
fs.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- Entry[] entries = new Entry[_header.entries];
+ var entries = new Entry[_header.entries];
- for(int i = 0; i < _header.entries; i++)
+ for(var i = 0; i < _header.entries; i++)
{
- byte[] entry = new byte[12];
+ var entry = new byte[12];
fs.EnsureRead(entry, 0, 12);
entries[i] = Marshal.ByteArrayToStructureBigEndian(entry);
}
@@ -498,6 +502,7 @@ public sealed class AppleDouble : IFilter
LastWriteTime = CreationTime;
foreach(Entry entry in entries)
+ {
switch((EntryId)entry.id)
{
case EntryId.DataFork:
@@ -505,7 +510,7 @@ public sealed class AppleDouble : IFilter
break;
case EntryId.FileDates:
fs.Seek(entry.offset, SeekOrigin.Begin);
- byte[] datesB = new byte[16];
+ var datesB = new byte[16];
fs.EnsureRead(datesB, 0, 16);
FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB);
@@ -516,7 +521,7 @@ public sealed class AppleDouble : IFilter
break;
case EntryId.FileInfo:
fs.Seek(entry.offset, SeekOrigin.Begin);
- byte[] finfo = new byte[entry.length];
+ var finfo = new byte[entry.length];
fs.EnsureRead(finfo, 0, finfo.Length);
if(_macintoshHome.SequenceEqual(_header.homeFilesystem))
@@ -553,6 +558,7 @@ public sealed class AppleDouble : IFilter
break;
}
+ }
_dataFork = new Entry
{
@@ -572,16 +578,71 @@ public sealed class AppleDouble : IFilter
return ErrorNumber.NoError;
}
+#endregion
+
+#region Nested type: DOSFileInfo
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct DOSFileInfo
+ {
+ public readonly ushort modificationDate;
+ public readonly ushort modificationTime;
+ public readonly ushort attributes;
+ }
+
+#endregion
+
+#region Nested type: Entry
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ struct Entry
+ {
+ public uint id;
+ public readonly uint offset;
+ public uint length;
+ }
+
+#endregion
+
+#region Nested type: EntryId
+
enum EntryId : uint
{
- Invalid = 0, DataFork = 1, ResourceFork = 2,
- RealName = 3, Comment = 4, Icon = 5,
- ColorIcon = 6, FileInfo = 7, FileDates = 8,
- FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11,
- DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14,
- DirectoryID = 15
+ Invalid = 0,
+ DataFork = 1,
+ ResourceFork = 2,
+ RealName = 3,
+ Comment = 4,
+ Icon = 5,
+ ColorIcon = 6,
+ FileInfo = 7,
+ FileDates = 8,
+ FinderInfo = 9,
+ MacFileInfo = 10,
+ ProDOSFileInfo = 11,
+ DOSFileInfo = 12,
+ ShortName = 13,
+ AfpFileInfo = 14,
+ DirectoryID = 15
}
+#endregion
+
+#region Nested type: FileDates
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct FileDates
+ {
+ public readonly uint creationDate;
+ public readonly uint modificationDate;
+ public readonly uint backupDate;
+ public readonly uint accessDate;
+ }
+
+#endregion
+
+#region Nested type: Header
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Header
{
@@ -592,22 +653,9 @@ public sealed class AppleDouble : IFilter
public readonly ushort entries;
}
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- struct Entry
- {
- public uint id;
- public readonly uint offset;
- public uint length;
- }
+#endregion
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct FileDates
- {
- public readonly uint creationDate;
- public readonly uint modificationDate;
- public readonly uint backupDate;
- public readonly uint accessDate;
- }
+#region Nested type: MacFileInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct MacFileInfo
@@ -618,21 +666,9 @@ public sealed class AppleDouble : IFilter
public readonly uint accessDate;
}
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct UnixFileInfo
- {
- public readonly uint creationDate;
- public readonly uint accessDate;
- public readonly uint modificationDate;
- }
+#endregion
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct DOSFileInfo
- {
- public readonly ushort modificationDate;
- public readonly ushort modificationTime;
- public readonly ushort attributes;
- }
+#region Nested type: ProDOSFileInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct ProDOSFileInfo
@@ -644,4 +680,18 @@ public sealed class AppleDouble : IFilter
public readonly ushort fileType;
public readonly uint auxType;
}
+
+#endregion
+
+#region Nested type: UnixFileInfo
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct UnixFileInfo
+ {
+ public readonly uint creationDate;
+ public readonly uint accessDate;
+ public readonly uint modificationDate;
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs
index 0f0364ee2..e07dac53c 100644
--- a/Aaru.Filters/AppleSingle.cs
+++ b/Aaru.Filters/AppleSingle.cs
@@ -63,10 +63,14 @@ public sealed class AppleSingle : IFilter
Entry _rsrcFork;
Stream _stream;
+#region IFilter Members
+
///
public string Name => Localization.AppleSingle_Name;
+
///
public Guid Id => new("A69B20E8-F4D3-42BB-BD2B-4A7263394A05");
+
///
public string Author => Authors.NataliaPortillo;
@@ -102,8 +106,10 @@ public sealed class AppleSingle : IFilter
return new OffsetStream(_stream, _dataFork.offset, _dataFork.offset + _dataFork.length - 1);
if(_isPath)
+ {
return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _dataFork.offset,
_dataFork.offset + _dataFork.length - 1);
+ }
return null;
}
@@ -139,8 +145,10 @@ public sealed class AppleSingle : IFilter
return new OffsetStream(_stream, _rsrcFork.offset, _rsrcFork.offset + _rsrcFork.length - 1);
if(_isPath)
+ {
return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _rsrcFork.offset,
_rsrcFork.offset + _rsrcFork.length - 1);
+ }
return null;
}
@@ -155,7 +163,7 @@ public sealed class AppleSingle : IFilter
buffer.Length < 26)
return false;
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
Array.Copy(buffer, 0, hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -169,7 +177,7 @@ public sealed class AppleSingle : IFilter
stream.Length < 26)
return false;
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -188,7 +196,7 @@ public sealed class AppleSingle : IFilter
if(fstream.Length < 26)
return false;
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
fstream.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -203,15 +211,15 @@ public sealed class AppleSingle : IFilter
var ms = new MemoryStream(buffer);
ms.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
ms.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- Entry[] entries = new Entry[_header.entries];
+ var entries = new Entry[_header.entries];
- for(int i = 0; i < _header.entries; i++)
+ for(var i = 0; i < _header.entries; i++)
{
- byte[] entry = new byte[12];
+ var entry = new byte[12];
ms.EnsureRead(entry, 0, 12);
entries[i] = Marshal.ByteArrayToStructureBigEndian(entry);
}
@@ -220,6 +228,7 @@ public sealed class AppleSingle : IFilter
LastWriteTime = CreationTime;
foreach(Entry entry in entries)
+ {
switch((AppleSingleEntryID)entry.id)
{
case AppleSingleEntryID.DataFork:
@@ -228,7 +237,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileDates:
ms.Seek(entry.offset, SeekOrigin.Begin);
- byte[] datesB = new byte[16];
+ var datesB = new byte[16];
ms.EnsureRead(datesB, 0, 16);
FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB);
@@ -239,7 +248,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileInfo:
ms.Seek(entry.offset, SeekOrigin.Begin);
- byte[] finfo = new byte[entry.length];
+ var finfo = new byte[entry.length];
ms.EnsureRead(finfo, 0, finfo.Length);
if(_macintoshHome.SequenceEqual(_header.homeFilesystem))
@@ -276,6 +285,7 @@ public sealed class AppleSingle : IFilter
break;
}
+ }
ms.Close();
_isBytes = true;
@@ -289,15 +299,15 @@ public sealed class AppleSingle : IFilter
{
stream.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
stream.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- Entry[] entries = new Entry[_header.entries];
+ var entries = new Entry[_header.entries];
- for(int i = 0; i < _header.entries; i++)
+ for(var i = 0; i < _header.entries; i++)
{
- byte[] entry = new byte[12];
+ var entry = new byte[12];
stream.EnsureRead(entry, 0, 12);
entries[i] = Marshal.ByteArrayToStructureBigEndian(entry);
}
@@ -306,6 +316,7 @@ public sealed class AppleSingle : IFilter
LastWriteTime = CreationTime;
foreach(Entry entry in entries)
+ {
switch((AppleSingleEntryID)entry.id)
{
case AppleSingleEntryID.DataFork:
@@ -314,7 +325,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileDates:
stream.Seek(entry.offset, SeekOrigin.Begin);
- byte[] datesB = new byte[16];
+ var datesB = new byte[16];
stream.EnsureRead(datesB, 0, 16);
FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB);
@@ -325,7 +336,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileInfo:
stream.Seek(entry.offset, SeekOrigin.Begin);
- byte[] finfo = new byte[entry.length];
+ var finfo = new byte[entry.length];
stream.EnsureRead(finfo, 0, finfo.Length);
if(_macintoshHome.SequenceEqual(_header.homeFilesystem))
@@ -362,6 +373,7 @@ public sealed class AppleSingle : IFilter
break;
}
+ }
stream.Seek(0, SeekOrigin.Begin);
_isStream = true;
@@ -376,15 +388,15 @@ public sealed class AppleSingle : IFilter
var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[26];
+ var hdrB = new byte[26];
fs.EnsureRead(hdrB, 0, 26);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- Entry[] entries = new Entry[_header.entries];
+ var entries = new Entry[_header.entries];
- for(int i = 0; i < _header.entries; i++)
+ for(var i = 0; i < _header.entries; i++)
{
- byte[] entry = new byte[12];
+ var entry = new byte[12];
fs.EnsureRead(entry, 0, 12);
entries[i] = Marshal.ByteArrayToStructureBigEndian(entry);
}
@@ -393,6 +405,7 @@ public sealed class AppleSingle : IFilter
LastWriteTime = CreationTime;
foreach(Entry entry in entries)
+ {
switch((AppleSingleEntryID)entry.id)
{
case AppleSingleEntryID.DataFork:
@@ -401,7 +414,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileDates:
fs.Seek(entry.offset, SeekOrigin.Begin);
- byte[] datesB = new byte[16];
+ var datesB = new byte[16];
fs.EnsureRead(datesB, 0, 16);
FileDates dates = Marshal.ByteArrayToStructureBigEndian(datesB);
@@ -412,7 +425,7 @@ public sealed class AppleSingle : IFilter
break;
case AppleSingleEntryID.FileInfo:
fs.Seek(entry.offset, SeekOrigin.Begin);
- byte[] finfo = new byte[entry.length];
+ var finfo = new byte[entry.length];
fs.EnsureRead(finfo, 0, finfo.Length);
if(_macintoshHome.SequenceEqual(_header.homeFilesystem))
@@ -449,6 +462,7 @@ public sealed class AppleSingle : IFilter
break;
}
+ }
fs.Close();
_isPath = true;
@@ -457,16 +471,71 @@ public sealed class AppleSingle : IFilter
return ErrorNumber.NoError;
}
+#endregion
+
+#region Nested type: AppleSingleEntryID
+
enum AppleSingleEntryID : uint
{
- Invalid = 0, DataFork = 1, ResourceFork = 2,
- RealName = 3, Comment = 4, Icon = 5,
- ColorIcon = 6, FileInfo = 7, FileDates = 8,
- FinderInfo = 9, MacFileInfo = 10, ProDOSFileInfo = 11,
- DOSFileInfo = 12, ShortName = 13, AfpFileInfo = 14,
- DirectoryID = 15
+ Invalid = 0,
+ DataFork = 1,
+ ResourceFork = 2,
+ RealName = 3,
+ Comment = 4,
+ Icon = 5,
+ ColorIcon = 6,
+ FileInfo = 7,
+ FileDates = 8,
+ FinderInfo = 9,
+ MacFileInfo = 10,
+ ProDOSFileInfo = 11,
+ DOSFileInfo = 12,
+ ShortName = 13,
+ AfpFileInfo = 14,
+ DirectoryID = 15
}
+#endregion
+
+#region Nested type: DOSFileInfo
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct DOSFileInfo
+ {
+ public readonly ushort modificationDate;
+ public readonly ushort modificationTime;
+ public readonly ushort attributes;
+ }
+
+#endregion
+
+#region Nested type: Entry
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct Entry
+ {
+ public readonly uint id;
+ public readonly uint offset;
+ public readonly uint length;
+ }
+
+#endregion
+
+#region Nested type: FileDates
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct FileDates
+ {
+ public readonly uint creationDate;
+ public readonly uint modificationDate;
+ public readonly uint backupDate;
+ public readonly uint accessDate;
+ }
+
+#endregion
+
+#region Nested type: Header
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Header
{
@@ -477,22 +546,9 @@ public sealed class AppleSingle : IFilter
public readonly ushort entries;
}
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct Entry
- {
- public readonly uint id;
- public readonly uint offset;
- public readonly uint length;
- }
+#endregion
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct FileDates
- {
- public readonly uint creationDate;
- public readonly uint modificationDate;
- public readonly uint backupDate;
- public readonly uint accessDate;
- }
+#region Nested type: MacFileInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct MacFileInfo
@@ -503,21 +559,9 @@ public sealed class AppleSingle : IFilter
public readonly uint accessDate;
}
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct UnixFileInfo
- {
- public readonly uint creationDate;
- public readonly uint accessDate;
- public readonly uint modificationDate;
- }
+#endregion
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- readonly struct DOSFileInfo
- {
- public readonly ushort modificationDate;
- public readonly ushort modificationTime;
- public readonly ushort attributes;
- }
+#region Nested type: ProDOSFileInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct ProDOSFileInfo
@@ -529,4 +573,18 @@ public sealed class AppleSingle : IFilter
public readonly ushort fileType;
public readonly uint auxType;
}
+
+#endregion
+
+#region Nested type: UnixFileInfo
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ readonly struct UnixFileInfo
+ {
+ public readonly uint creationDate;
+ public readonly uint accessDate;
+ public readonly uint modificationDate;
+ }
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/BZip2.cs b/Aaru.Filters/BZip2.cs
index a796dc963..ac6e9076d 100644
--- a/Aaru.Filters/BZip2.cs
+++ b/Aaru.Filters/BZip2.cs
@@ -46,10 +46,14 @@ public class BZip2 : IFilter
Stream _dataStream;
Stream _innerStream;
+#region IFilter Members
+
///
public string Name => Localization.BZip2_Name;
+
///
public Guid Id => new("FCCFB0C3-32EF-40D8-9714-2333F6AC72A9");
+
///
public string Author => Authors.NataliaPortillo;
@@ -95,7 +99,7 @@ public class BZip2 : IFilter
///
public bool Identify(Stream stream)
{
- byte[] buffer = new byte[4];
+ var buffer = new byte[4];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 4);
@@ -125,8 +129,8 @@ public class BZip2 : IFilter
if(!File.Exists(path))
return false;
- var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
- byte[] buffer = new byte[4];
+ var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
+ var buffer = new byte[4];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 4);
@@ -214,11 +218,14 @@ public class BZip2 : IFilter
if(BasePath?.EndsWith(".bz2", StringComparison.InvariantCultureIgnoreCase) == true)
return BasePath[..^4];
- return BasePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^6]
+ return BasePath?.EndsWith(".bzip2", StringComparison.InvariantCultureIgnoreCase) == true
+ ? BasePath[..^6]
: BasePath;
}
}
///
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/ForcedSeekStream.cs b/Aaru.Filters/ForcedSeekStream.cs
index 964a91181..5e40f641f 100644
--- a/Aaru.Filters/ForcedSeekStream.cs
+++ b/Aaru.Filters/ForcedSeekStream.cs
@@ -106,7 +106,7 @@ public sealed class ForcedSeekStream : Stream where T : Stream
do
{
- byte[] buffer = new byte[BUFFER_LEN];
+ var buffer = new byte[BUFFER_LEN];
read = _baseStream.EnsureRead(buffer, 0, BUFFER_LEN);
_backStream.Write(buffer, 0, read);
} while(read == BUFFER_LEN);
@@ -132,13 +132,13 @@ public sealed class ForcedSeekStream : Stream where T : Stream
_backStream.Position = _backStream.Length;
long toPosition = position - _backStream.Position;
- int fullBufferReads = (int)(toPosition / BUFFER_LEN);
- int restToRead = (int)(toPosition % BUFFER_LEN);
+ var fullBufferReads = (int)(toPosition / BUFFER_LEN);
+ var restToRead = (int)(toPosition % BUFFER_LEN);
byte[] buffer;
int bufPos;
int left;
- for(int i = 0; i < fullBufferReads; i++)
+ for(var i = 0; i < fullBufferReads; i++)
{
buffer = new byte[BUFFER_LEN];
bufPos = 0;
diff --git a/Aaru.Filters/GZip.cs b/Aaru.Filters/GZip.cs
index f7dc4bc09..d7e231929 100644
--- a/Aaru.Filters/GZip.cs
+++ b/Aaru.Filters/GZip.cs
@@ -47,10 +47,14 @@ public sealed class GZip : IFilter
uint _decompressedSize;
Stream _zStream;
+#region IFilter Members
+
///
public string Name => Localization.GZip_Name;
+
///
public Guid Id => new("F4996661-4A29-42C9-A2C7-3904EF40F3B0");
+
///
public string Author => Authors.NataliaPortillo;
@@ -83,7 +87,7 @@ public sealed class GZip : IFilter
///
public bool Identify(Stream stream)
{
- byte[] buffer = new byte[3];
+ var buffer = new byte[3];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 3);
@@ -98,8 +102,8 @@ public sealed class GZip : IFilter
if(!File.Exists(path))
return false;
- var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
- byte[] buffer = new byte[3];
+ var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
+ var buffer = new byte[3];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 3);
@@ -111,8 +115,8 @@ public sealed class GZip : IFilter
///
public ErrorNumber Open(byte[] buffer)
{
- byte[] mtimeB = new byte[4];
- byte[] isizeB = new byte[4];
+ var mtimeB = new byte[4];
+ var isizeB = new byte[4];
_dataStream = new MemoryStream(buffer);
BasePath = null;
@@ -123,8 +127,8 @@ public sealed class GZip : IFilter
_dataStream.EnsureRead(isizeB, 0, 4);
_dataStream.Seek(0, SeekOrigin.Begin);
- uint mtime = BitConverter.ToUInt32(mtimeB, 0);
- uint isize = BitConverter.ToUInt32(isizeB, 0);
+ var mtime = BitConverter.ToUInt32(mtimeB, 0);
+ var isize = BitConverter.ToUInt32(isizeB, 0);
_decompressedSize = isize;
CreationTime = DateHandlers.UnixUnsignedToDateTime(mtime);
@@ -138,8 +142,8 @@ public sealed class GZip : IFilter
///
public ErrorNumber Open(Stream stream)
{
- byte[] mtimeB = new byte[4];
- byte[] isizeB = new byte[4];
+ var mtimeB = new byte[4];
+ var isizeB = new byte[4];
_dataStream = stream;
BasePath = null;
@@ -150,8 +154,8 @@ public sealed class GZip : IFilter
_dataStream.EnsureRead(isizeB, 0, 4);
_dataStream.Seek(0, SeekOrigin.Begin);
- uint mtime = BitConverter.ToUInt32(mtimeB, 0);
- uint isize = BitConverter.ToUInt32(isizeB, 0);
+ var mtime = BitConverter.ToUInt32(mtimeB, 0);
+ var isize = BitConverter.ToUInt32(isizeB, 0);
_decompressedSize = isize;
CreationTime = DateHandlers.UnixUnsignedToDateTime(mtime);
@@ -165,8 +169,8 @@ public sealed class GZip : IFilter
///
public ErrorNumber Open(string path)
{
- byte[] mtimeB = new byte[4];
- byte[] isizeB = new byte[4];
+ var mtimeB = new byte[4];
+ var isizeB = new byte[4];
_dataStream = new FileStream(path, FileMode.Open, FileAccess.Read);
BasePath = System.IO.Path.GetFullPath(path);
@@ -177,8 +181,8 @@ public sealed class GZip : IFilter
_dataStream.EnsureRead(isizeB, 0, 4);
_dataStream.Seek(0, SeekOrigin.Begin);
- uint mtime = BitConverter.ToUInt32(mtimeB, 0);
- uint isize = BitConverter.ToUInt32(isizeB, 0);
+ var mtime = BitConverter.ToUInt32(mtimeB, 0);
+ var isize = BitConverter.ToUInt32(isizeB, 0);
_decompressedSize = isize;
var fi = new FileInfo(path);
@@ -212,11 +216,14 @@ public sealed class GZip : IFilter
if(BasePath?.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase) == true)
return BasePath[..^3];
- return BasePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
+ return BasePath?.EndsWith(".gzip", StringComparison.InvariantCultureIgnoreCase) == true
+ ? BasePath[..^5]
: BasePath;
}
}
///
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/LZip.cs b/Aaru.Filters/LZip.cs
index d59411d8b..a5c8c6749 100644
--- a/Aaru.Filters/LZip.cs
+++ b/Aaru.Filters/LZip.cs
@@ -47,10 +47,14 @@ public sealed class LZip : IFilter
Stream _dataStream;
Stream _innerStream;
+#region IFilter Members
+
///
public string Name => Localization.LZip_Name;
+
///
public Guid Id => new("09D715E9-20C0-48B1-A8D9-D8897CEC57C9");
+
///
public string Author => Authors.NataliaPortillo;
@@ -84,7 +88,7 @@ public sealed class LZip : IFilter
///
public bool Identify(Stream stream)
{
- byte[] buffer = new byte[5];
+ var buffer = new byte[5];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 5);
@@ -99,8 +103,8 @@ public sealed class LZip : IFilter
if(!File.Exists(path))
return false;
- var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
- byte[] buffer = new byte[5];
+ var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
+ var buffer = new byte[5];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, 5);
@@ -130,7 +134,7 @@ public sealed class LZip : IFilter
BasePath = null;
CreationTime = DateTime.UtcNow;
LastWriteTime = CreationTime;
- byte[] tmp = new byte[8];
+ var tmp = new byte[8];
_dataStream.Seek(-16, SeekOrigin.End);
_dataStream.EnsureRead(tmp, 0, 8);
DataForkLength = BitConverter.ToInt64(tmp, 0);
@@ -149,7 +153,7 @@ public sealed class LZip : IFilter
var fi = new FileInfo(path);
CreationTime = fi.CreationTimeUtc;
LastWriteTime = fi.LastWriteTimeUtc;
- byte[] tmp = new byte[8];
+ var tmp = new byte[8];
_dataStream.Seek(-16, SeekOrigin.End);
_dataStream.EnsureRead(tmp, 0, 8);
DataForkLength = BitConverter.ToInt64(tmp, 0);
@@ -182,11 +186,14 @@ public sealed class LZip : IFilter
if(BasePath?.EndsWith(".lz", StringComparison.InvariantCultureIgnoreCase) == true)
return BasePath[..^3];
- return BasePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
+ return BasePath?.EndsWith(".lzip", StringComparison.InvariantCultureIgnoreCase) == true
+ ? BasePath[..^5]
: BasePath;
}
}
///
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/Localization/Localization.es.resx b/Aaru.Filters/Localization/Localization.es.resx
index b48129f82..badeea524 100644
--- a/Aaru.Filters/Localization/Localization.es.resx
+++ b/Aaru.Filters/Localization/Localization.es.resx
@@ -1,81 +1,85 @@
-
-
- text/microsoft-resx
-
-
- 1.3
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
AppleDouble
-
+
AppleSingle
-
+
E/S asíncrona no soportada.
-
+
BZip2
-
+
No se puede leer más allá del final de la secuencia.
-
+
No se puede posicionar después del final de la secuencia.
-
+
No se puede posicionar antes del comienzo de la secuencia.
-
+
No se puede establecer la posición más allá del final de la secuencia.
-
+
No se puede escribir después del final de la secuencia.
-
+
El final no puede ser un número negativo.
-
+
El final está después del final de la secuencia.
-
+
No se puede agrandar un OffsetStream.
-
+
GZip
-
+
LZip
-
+
MacBinary
-
+
Las secuencias no legíbles no están soportadas.
-
+
Las secuencias no posicionables no están soportadas.
-
+
PCExchange
-
+
El comienzo no puede ser un número negativo.
-
+
Esta secuencia es de sólo lectura.
-
+
XZ
-
+
Sin filtro
\ No newline at end of file
diff --git a/Aaru.Filters/Localization/Localization.resx b/Aaru.Filters/Localization/Localization.resx
index da287f65d..712480c09 100644
--- a/Aaru.Filters/Localization/Localization.resx
+++ b/Aaru.Filters/Localization/Localization.resx
@@ -1,90 +1,92 @@
-
-
-
-
- text/microsoft-resx
-
-
- 1.3
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
- PublicKeyToken=b77a5c561934e089
-
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
- PublicKeyToken=b77a5c561934e089
-
-
-
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
AppleDouble
-
+
AppleSingle
-
+
BZip2
-
+
Cannot seek before stream start.
-
+
Cannot seek after stream end.
-
+
GZip
-
+
LZip
-
+
MacBinary
-
+
Start can't be a negative number.
-
+
End can't be a negative number.
-
+
End is after stream end.
-
+
Cannot set position past stream end.
-
+
Cannot read past stream end.
-
+
Cannot write past stream end.
-
+
Growing OffsetStream is not supported.
-
+
PCExchange
-
+
Non-seekable streams are not supported
-
+
Non-readable streams are not supported
-
+
Asynchronous I/O is not supported.
-
+
This stream is read-only
-
+
XZ
-
+
No filter
\ No newline at end of file
diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs
index 3cad224e7..8bc5f1bda 100644
--- a/Aaru.Filters/MacBinary.cs
+++ b/Aaru.Filters/MacBinary.cs
@@ -54,10 +54,14 @@ public sealed class MacBinary : IFilter
long _rsrcForkOff;
Stream _stream;
+#region IFilter Members
+
///
public string Name => Localization.MacBinary_Name;
+
///
public Guid Id => new("D7C321D3-E51F-45DF-A150-F6BFDF0D7704");
+
///
public string Author => Authors.NataliaPortillo;
@@ -93,8 +97,10 @@ public sealed class MacBinary : IFilter
return new OffsetStream(_stream, _dataForkOff, _dataForkOff + _header.dataLength - 1);
if(_isPath)
+ {
return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _dataForkOff,
_dataForkOff + _header.dataLength - 1);
+ }
return null;
}
@@ -130,8 +136,10 @@ public sealed class MacBinary : IFilter
return new OffsetStream(_stream, _rsrcForkOff, _rsrcForkOff + _header.resourceLength - 1);
if(_isPath)
+ {
return new OffsetStream(BasePath, FileMode.Open, FileAccess.Read, _rsrcForkOff,
_rsrcForkOff + _header.resourceLength - 1);
+ }
return null;
}
@@ -146,13 +154,13 @@ public sealed class MacBinary : IFilter
buffer.Length < 128)
return false;
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
Array.Copy(buffer, 0, hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
- _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
- (_header.dataLength > 0 || _header.resourceLength > 0));
+ return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
+ _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
+ (_header.dataLength > 0 || _header.resourceLength > 0);
}
///
@@ -162,14 +170,14 @@ public sealed class MacBinary : IFilter
stream.Length < 128)
return false;
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
- return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
- _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
- (_header.dataLength > 0 || _header.resourceLength > 0));
+ return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
+ _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
+ (_header.dataLength > 0 || _header.resourceLength > 0);
}
///
@@ -183,15 +191,15 @@ public sealed class MacBinary : IFilter
if(fstream.Length < 128)
return false;
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
fstream.EnsureRead(hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
fstream.Close();
- return _header.magic == MAGIC || (_header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
- _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
- (_header.dataLength > 0 || _header.resourceLength > 0));
+ return _header.magic == MAGIC || _header.version == 0 && _header.filename[0] > 0 && _header.filename[0] < 64 &&
+ _header.zero1 == 0 && _header is { zero2: 0, reserved: 0 } &&
+ (_header.dataLength > 0 || _header.resourceLength > 0);
}
///
@@ -200,7 +208,7 @@ public sealed class MacBinary : IFilter
var ms = new MemoryStream(buffer);
ms.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
ms.EnsureRead(hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -234,7 +242,7 @@ public sealed class MacBinary : IFilter
{
stream.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
stream.EnsureRead(hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -269,7 +277,7 @@ public sealed class MacBinary : IFilter
var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Seek(0, SeekOrigin.Begin);
- byte[] hdrB = new byte[128];
+ var hdrB = new byte[128];
fs.EnsureRead(hdrB, 0, 128);
_header = Marshal.ByteArrayToStructureBigEndian(hdrB);
@@ -298,6 +306,10 @@ public sealed class MacBinary : IFilter
return ErrorNumber.NoError;
}
+#endregion
+
+#region Nested type: Header
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Header
{
@@ -337,21 +349,24 @@ public sealed class MacBinary : IFilter
/// 0x65, Low byte of Finder flags
public readonly byte finderFlags2;
- #region MacBinary III
+ #region MacBinary III
+
/// 0x66, magic identifier, "mBIN"
public readonly uint magic;
/// 0x6A, fdScript from fxInfo, identifies codepage of filename
public readonly byte fdScript;
/// 0x6B, fdXFlags from fxInfo, extended Mac OS 8 finder flags
public readonly byte fdXFlags;
- #endregion MacBinary III
+
+ #endregion MacBinary III
/// 0x6C, unused
public readonly ulong reserved;
/// 0x74, Total unpacked files
public readonly uint totalPackedFiles;
- #region MacBinary II
+ #region MacBinary II
+
/// 0x78, Length of secondary header
public readonly ushort secondaryHeaderLength;
/// 0x7A, version number of MacBinary that wrote this file, starts at 129
@@ -360,9 +375,12 @@ public sealed class MacBinary : IFilter
public readonly byte minVersion;
/// 0x7C, CRC of previous bytes
public readonly short crc;
- #endregion MacBinary II
+
+ #endregion MacBinary II
/// 0x7E, Reserved for computer type and OS ID
public readonly short computerID;
}
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/OffsetStream.cs b/Aaru.Filters/OffsetStream.cs
index a89bb715c..8854ff365 100644
--- a/Aaru.Filters/OffsetStream.cs
+++ b/Aaru.Filters/OffsetStream.cs
@@ -38,647 +38,646 @@ using Microsoft.Win32.SafeHandles;
#endif
-namespace Aaru.Filters
+namespace Aaru.Filters;
+
+/// Creates a stream that is a subset of another stream.
+///
+public sealed class OffsetStream : Stream
{
- /// Creates a stream that is a subset of another stream.
+ readonly Stream _baseStream;
+ readonly long _streamEnd;
+ readonly long _streamStart;
+
///
- public sealed class OffsetStream : Stream
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified stream, both inclusive.
+ ///
+ /// Base stream
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(Stream stream, long start, long end)
{
- readonly Stream _baseStream;
- readonly long _streamEnd;
- readonly long _streamStart;
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified stream, both inclusive.
- ///
- /// Base stream
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(Stream stream, long start, long end)
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = stream;
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file will be shared by
+ /// processes.
+ ///
+ ///
+ /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
+ /// 4096.
+ ///
+ /// A bitwise combination of the enumeration values that specifies additional file options.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ FileOptions options, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode, access, share, bufferSize, options);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A file handle for the file that the stream will encapsulate.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(SafeFileHandle handle, FileAccess access, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(handle, access);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A file handle for the file that the stream will encapsulate.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
+ /// 4096.
+ ///
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(handle, access, bufferSize);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A file handle for the file that the stream will encapsulate.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
+ /// 4096.
+ ///
+ /// Specifies whether to use asynchronous I/O or synchronous I/O.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync, long start,
+ long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(handle, access, bufferSize, isAsync);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file will be shared by
+ /// processes.
+ ///
+ ///
+ /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
+ /// 4096.
+ ///
+ /// Specifies whether to use asynchronous I/O or synchronous I/O.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ bool useAsync, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode, access, share, bufferSize, useAsync);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file will be shared by
+ /// processes.
+ ///
+ ///
+ /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
+ /// 4096.
+ ///
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, long start,
+ long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode, access, share, bufferSize);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file will be shared by
+ /// processes.
+ ///
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode, access, share);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ ///
+ /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
+ /// object.
+ ///
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, FileAccess access, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode, access);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified file, both inclusive.
+ ///
+ /// A relative or absolute path for the file that the stream will encapsulate.
+ /// One of the enumeration values that determines how to open or create the file.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(string path, FileMode mode, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new FileStream(path, mode);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified byte array, both inclusive.
+ ///
+ /// The array of unsigned bytes to add at the end of this stream.
+ /// The index into at which the stream begins.
+ /// The length in bytes to add to the end of the current stream.
+ /// The setting of the CanWrite property, currently ignored.
+ /// Currently ignored.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible, long start,
+ long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new MemoryStream(buffer, index, count, writable, publiclyVisible);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified byte array, both inclusive.
+ ///
+ /// The array of unsigned bytes to add at the end of this stream.
+ /// The index into at which the stream begins.
+ /// The length in bytes to add to the end of the current stream.
+ /// The setting of the CanWrite property, currently ignored.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(byte[] buffer, int index, int count, bool writable, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new MemoryStream(buffer, index, count, writable);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified byte array, both inclusive.
+ ///
+ /// The array of unsigned bytes to add at the end of this stream.
+ /// The index into at which the stream begins.
+ /// The length in bytes to add to the end of the current stream.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(byte[] buffer, int index, int count, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new MemoryStream(buffer, index, count);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified byte array, both inclusive.
+ ///
+ /// The array of unsigned bytes to add at the end of this stream.
+ /// The setting of the CanWrite property, currently ignored.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(byte[] buffer, bool writable, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new MemoryStream(buffer, writable);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ ///
+ /// Initializes a stream that only allows reading from to of the
+ /// specified byte array, both inclusive.
+ ///
+ /// The array of unsigned bytes to add at the end of this stream.
+ /// Start position
+ /// Last readable position
+ /// Invalid range
+ public OffsetStream(byte[] buffer, long start, long end)
+ {
+ if(start < 0)
+ throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+
+ if(end < 0)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
+
+ _streamStart = start;
+ _streamEnd = end;
+
+ _baseStream = new MemoryStream(buffer);
+
+ if(end > _baseStream.Length)
+ throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
+
+ _baseStream.Position = start;
+ }
+
+ ///
+ public override bool CanRead => _baseStream.CanRead;
+
+ ///
+ public override bool CanSeek => _baseStream.CanSeek;
+
+ ///
+ public override bool CanWrite => _baseStream.CanWrite;
+
+ ///
+ public override long Length => _streamEnd - _streamStart + 1;
+
+ ///
+ public override long Position
+ {
+ get => _baseStream.Position - _streamStart;
+
+ set
{
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
+ if(value + _streamStart > _streamEnd)
+ throw new IOException(Localization.Cannot_set_position_past_stream_end);
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = stream;
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A bitwise combination of the enumeration values that determines how the file will be shared by
- /// processes.
- ///
- ///
- /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
- /// 4096.
- ///
- /// A bitwise combination of the enumeration values that specifies additional file options.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
- FileOptions options, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode, access, share, bufferSize, options);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A file handle for the file that the stream will encapsulate.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(SafeFileHandle handle, FileAccess access, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(handle, access);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A file handle for the file that the stream will encapsulate.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
- /// 4096.
- ///
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(handle, access, bufferSize);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A file handle for the file that the stream will encapsulate.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
- /// 4096.
- ///
- /// Specifies whether to use asynchronous I/O or synchronous I/O.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync, long start,
- long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(handle, access, bufferSize, isAsync);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A bitwise combination of the enumeration values that determines how the file will be shared by
- /// processes.
- ///
- ///
- /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
- /// 4096.
- ///
- /// Specifies whether to use asynchronous I/O or synchronous I/O.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
- bool useAsync, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode, access, share, bufferSize, useAsync);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A bitwise combination of the enumeration values that determines how the file will be shared by
- /// processes.
- ///
- ///
- /// A positive Int32 value greater than 0 indicating the buffer size. The default buffer size is
- /// 4096.
- ///
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, long start,
- long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode, access, share, bufferSize);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- ///
- /// A bitwise combination of the enumeration values that determines how the file will be shared by
- /// processes.
- ///
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, FileAccess access, FileShare share, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode, access, share);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- ///
- /// A bitwise combination of the enumeration values that determines how the file can be accessed by a
- /// object.
- ///
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, FileAccess access, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode, access);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified file, both inclusive.
- ///
- /// A relative or absolute path for the file that the stream will encapsulate.
- /// One of the enumeration values that determines how to open or create the file.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(string path, FileMode mode, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new FileStream(path, mode);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified byte array, both inclusive.
- ///
- /// The array of unsigned bytes to add at the end of this stream.
- /// The index into at which the stream begins.
- /// The length in bytes to add to the end of the current stream.
- /// The setting of the CanWrite property, currently ignored.
- /// Currently ignored.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible, long start,
- long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new MemoryStream(buffer, index, count, writable, publiclyVisible);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified byte array, both inclusive.
- ///
- /// The array of unsigned bytes to add at the end of this stream.
- /// The index into at which the stream begins.
- /// The length in bytes to add to the end of the current stream.
- /// The setting of the CanWrite property, currently ignored.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(byte[] buffer, int index, int count, bool writable, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new MemoryStream(buffer, index, count, writable);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified byte array, both inclusive.
- ///
- /// The array of unsigned bytes to add at the end of this stream.
- /// The index into at which the stream begins.
- /// The length in bytes to add to the end of the current stream.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(byte[] buffer, int index, int count, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new MemoryStream(buffer, index, count);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified byte array, both inclusive.
- ///
- /// The array of unsigned bytes to add at the end of this stream.
- /// The setting of the CanWrite property, currently ignored.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(byte[] buffer, bool writable, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new MemoryStream(buffer, writable);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- ///
- /// Initializes a stream that only allows reading from to of the
- /// specified byte array, both inclusive.
- ///
- /// The array of unsigned bytes to add at the end of this stream.
- /// Start position
- /// Last readable position
- /// Invalid range
- public OffsetStream(byte[] buffer, long start, long end)
- {
- if(start < 0)
- throw new ArgumentOutOfRangeException(nameof(start), Localization.Start_cant_be_a_negative_number);
-
- if(end < 0)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_cant_be_a_negative_number);
-
- _streamStart = start;
- _streamEnd = end;
-
- _baseStream = new MemoryStream(buffer);
-
- if(end > _baseStream.Length)
- throw new ArgumentOutOfRangeException(nameof(end), Localization.End_is_after_stream_end);
-
- _baseStream.Position = start;
- }
-
- ///
- public override bool CanRead => _baseStream.CanRead;
-
- ///
- public override bool CanSeek => _baseStream.CanSeek;
-
- ///
- public override bool CanWrite => _baseStream.CanWrite;
-
- ///
- public override long Length => _streamEnd - _streamStart + 1;
-
- ///
- public override long Position
- {
- get => _baseStream.Position - _streamStart;
-
- set
- {
- if(value + _streamStart > _streamEnd)
- throw new IOException(Localization.Cannot_set_position_past_stream_end);
-
- _baseStream.Position = value + _streamStart;
- }
- }
-
- ~OffsetStream()
- {
- _baseStream.Close();
- _baseStream.Dispose();
- }
-
- ///
- public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback,
- object state)
- {
- if(_baseStream.Position + count > _streamEnd)
- throw new IOException(Localization.Cannot_read_past_stream_end);
-
- return _baseStream.BeginRead(buffer, offset, count, callback, state);
- }
-
- ///
- public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback,
- object state)
- {
- if(_baseStream.Position + count > _streamEnd)
- throw new IOException(Localization.Cannot_write_past_stream_end);
-
- return _baseStream.BeginWrite(buffer, offset, count, callback, state);
- }
-
- ///
- public override void Close() => _baseStream.Close();
-
- ///
- public override int EndRead(IAsyncResult asyncResult) => _baseStream.EndRead(asyncResult);
-
- ///
- public override void EndWrite(IAsyncResult asyncResult) => _baseStream.EndWrite(asyncResult);
-
- ///
- public override int ReadByte() => _baseStream.Position == _streamEnd + 1 ? -1 : _baseStream.ReadByte();
-
- ///
- public override void WriteByte(byte value)
- {
- if(_baseStream.Position + 1 > _streamEnd)
- throw new IOException(Localization.Cannot_write_past_stream_end);
-
- _baseStream.WriteByte(value);
- }
-
- ///
- public override void Flush() => _baseStream.Flush();
-
- ///
- public override int Read(byte[] buffer, int offset, int count)
- {
- if(_baseStream.Position + count > _streamEnd + 1)
- throw new IOException(Localization.Cannot_read_past_stream_end);
-
- return _baseStream.EnsureRead(buffer, offset, count);
- }
-
- ///
- public override long Seek(long offset, SeekOrigin origin)
- {
- switch(origin)
- {
- case SeekOrigin.Begin:
- if(offset + _streamStart > _streamEnd)
- throw new IOException(Localization.Cannot_seek_after_stream_end);
-
- return _baseStream.Seek(offset + _streamStart, SeekOrigin.Begin) - _streamStart;
- case SeekOrigin.End:
- if(offset - (_baseStream.Length - _streamEnd) < _streamStart)
- throw new IOException(Localization.Cannot_seek_before_stream_start);
-
- return _baseStream.Seek(offset - (_baseStream.Length - _streamEnd), SeekOrigin.End) - _streamStart;
- default:
- if(offset + _baseStream.Position > _streamEnd)
- throw new IOException(Localization.Cannot_seek_after_stream_end);
-
- return _baseStream.Seek(offset, SeekOrigin.Current) - _streamStart;
- }
- }
-
- ///
- public override void SetLength(long value) =>
- throw new NotSupportedException(Localization.Growing_OffsetStream_is_not_supported);
-
- ///
- public override void Write(byte[] buffer, int offset, int count)
- {
- if(_baseStream.Position + count > _streamEnd)
- throw new IOException(Localization.Cannot_write_past_stream_end);
-
- _baseStream.Write(buffer, offset, count);
+ _baseStream.Position = value + _streamStart;
}
}
+
+ ~OffsetStream()
+ {
+ _baseStream.Close();
+ _baseStream.Dispose();
+ }
+
+ ///
+ public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback,
+ object state)
+ {
+ if(_baseStream.Position + count > _streamEnd)
+ throw new IOException(Localization.Cannot_read_past_stream_end);
+
+ return _baseStream.BeginRead(buffer, offset, count, callback, state);
+ }
+
+ ///
+ public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback,
+ object state)
+ {
+ if(_baseStream.Position + count > _streamEnd)
+ throw new IOException(Localization.Cannot_write_past_stream_end);
+
+ return _baseStream.BeginWrite(buffer, offset, count, callback, state);
+ }
+
+ ///
+ public override void Close() => _baseStream.Close();
+
+ ///
+ public override int EndRead(IAsyncResult asyncResult) => _baseStream.EndRead(asyncResult);
+
+ ///
+ public override void EndWrite(IAsyncResult asyncResult) => _baseStream.EndWrite(asyncResult);
+
+ ///
+ public override int ReadByte() => _baseStream.Position == _streamEnd + 1 ? -1 : _baseStream.ReadByte();
+
+ ///
+ public override void WriteByte(byte value)
+ {
+ if(_baseStream.Position + 1 > _streamEnd)
+ throw new IOException(Localization.Cannot_write_past_stream_end);
+
+ _baseStream.WriteByte(value);
+ }
+
+ ///
+ public override void Flush() => _baseStream.Flush();
+
+ ///
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ if(_baseStream.Position + count > _streamEnd + 1)
+ throw new IOException(Localization.Cannot_read_past_stream_end);
+
+ return _baseStream.EnsureRead(buffer, offset, count);
+ }
+
+ ///
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ switch(origin)
+ {
+ case SeekOrigin.Begin:
+ if(offset + _streamStart > _streamEnd)
+ throw new IOException(Localization.Cannot_seek_after_stream_end);
+
+ return _baseStream.Seek(offset + _streamStart, SeekOrigin.Begin) - _streamStart;
+ case SeekOrigin.End:
+ if(offset - (_baseStream.Length - _streamEnd) < _streamStart)
+ throw new IOException(Localization.Cannot_seek_before_stream_start);
+
+ return _baseStream.Seek(offset - (_baseStream.Length - _streamEnd), SeekOrigin.End) - _streamStart;
+ default:
+ if(offset + _baseStream.Position > _streamEnd)
+ throw new IOException(Localization.Cannot_seek_after_stream_end);
+
+ return _baseStream.Seek(offset, SeekOrigin.Current) - _streamStart;
+ }
+ }
+
+ ///
+ public override void SetLength(long value) =>
+ throw new NotSupportedException(Localization.Growing_OffsetStream_is_not_supported);
+
+ ///
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ if(_baseStream.Position + count > _streamEnd)
+ throw new IOException(Localization.Cannot_write_past_stream_end);
+
+ _baseStream.Write(buffer, offset, count);
+ }
}
\ No newline at end of file
diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs
index 2c0d089ce..b81dcc5bd 100644
--- a/Aaru.Filters/PCExchange.cs
+++ b/Aaru.Filters/PCExchange.cs
@@ -55,10 +55,14 @@ public sealed class PcExchange : IFilter
string _dataPath;
string _rsrcPath;
+#region IFilter Members
+
///
public string Name => Localization.PcExchange_Name;
+
///
public Guid Id => new("9264EB9F-D634-4F9B-BE12-C24CD44988C6");
+
///
public string Author => Authors.NataliaPortillo;
@@ -122,26 +126,26 @@ public sealed class PcExchange : IFilter
string baseFilename = System.IO.Path.GetFileName(path);
- bool dataFound = false;
- bool rsrcFound = false;
+ var dataFound = false;
+ var rsrcFound = false;
var finderDatStream = new FileStream(System.IO.Path.Combine(parentFolder, FINDER_INFO), FileMode.Open,
FileAccess.Read);
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
{
- var datEntry = new Entry();
- byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)];
+ var datEntry = new Entry();
+ var datEntryB = new byte[Marshal.SizeOf(datEntry)];
finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry));
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB);
// TODO: Add support for encoding on filters
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
- byte[] tmpDosNameB = new byte[8];
- byte[] tmpDosExtB = new byte[3];
+ var tmpDosNameB = new byte[8];
+ var tmpDosExtB = new byte[3];
Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8);
- Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3);
+ Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3);
string dosName = Encoding.ASCII.GetString(tmpDosNameB).Trim() + "." +
Encoding.ASCII.GetString(tmpDosExtB).Trim();
@@ -188,17 +192,17 @@ public sealed class PcExchange : IFilter
while(finderDatStream.Position + 0x5C <= finderDatStream.Length)
{
- var datEntry = new Entry();
- byte[] datEntryB = new byte[Marshal.SizeOf(datEntry)];
+ var datEntry = new Entry();
+ var datEntryB = new byte[Marshal.SizeOf(datEntry)];
finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry));
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian(datEntryB);
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));
- byte[] tmpDosNameB = new byte[8];
- byte[] tmpDosExtB = new byte[3];
+ var tmpDosNameB = new byte[8];
+ var tmpDosExtB = new byte[3];
Array.Copy(datEntry.dosName, 0, tmpDosNameB, 0, 8);
- Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3);
+ Array.Copy(datEntry.dosName, 8, tmpDosExtB, 0, 3);
string dosName = Encoding.ASCII.GetString(tmpDosNameB).Trim() + "." +
Encoding.ASCII.GetString(tmpDosExtB).Trim();
@@ -242,6 +246,10 @@ public sealed class PcExchange : IFilter
return ErrorNumber.NoError;
}
+#endregion
+
+#region Nested type: Entry
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct Entry
{
@@ -278,4 +286,6 @@ public sealed class PcExchange : IFilter
/// Unknown, flags?
public readonly byte unknown3;
}
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru.Filters/SplitJoinStream.cs b/Aaru.Filters/SplitJoinStream.cs
index adc95df2a..866da5f2d 100644
--- a/Aaru.Filters/SplitJoinStream.cs
+++ b/Aaru.Filters/SplitJoinStream.cs
@@ -86,7 +86,7 @@ public class SplitJoinStream : Stream
/// 4096.
///
/// A bitwise combination of the enumeration values that specifies additional file options.
- public void Add(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ public void Add(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
FileOptions options) => Add(new FileStream(path, mode, access, share, bufferSize, options));
/// Adds the specified file to the end of the current stream
@@ -229,7 +229,7 @@ public class SplitJoinStream : Stream
/// Base file path, directory path only
/// Counter format, includes filename and a formatting string
/// Counter start, defaults to 0
- public void AddRange(string basePath, string counterFormat = "{0:D3}", int counterStart = 0,
+ public void AddRange(string basePath, string counterFormat = "{0:D3}", int counterStart = 0,
FileAccess access = FileAccess.Read)
{
while(true)
@@ -311,7 +311,7 @@ public class SplitJoinStream : Stream
///
public override int Read(byte[] buffer, int offset, int count)
{
- int read = 0;
+ var read = 0;
while(count > 0)
{
diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs
index 824f864e6..a3954acab 100644
--- a/Aaru.Filters/XZ.cs
+++ b/Aaru.Filters/XZ.cs
@@ -46,10 +46,14 @@ public sealed class XZ : IFilter
Stream _dataStream;
Stream _innerStream;
+#region IFilter Members
+
///
public string Name => Localization.XZ_Name;
+
///
public Guid Id => new("666A8617-0444-4C05-9F4F-DF0FD758D0D2");
+
///
public string Author => Authors.NataliaPortillo;
@@ -84,8 +88,8 @@ public sealed class XZ : IFilter
///
public bool Identify(Stream stream)
{
- byte[] buffer = new byte[6];
- byte[] footer = new byte[2];
+ var buffer = new byte[6];
+ var footer = new byte[2];
if(stream.Length < 8)
return false;
@@ -106,9 +110,9 @@ public sealed class XZ : IFilter
if(!File.Exists(path))
return false;
- var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
- byte[] buffer = new byte[6];
- byte[] footer = new byte[2];
+ var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
+ var buffer = new byte[6];
+ var footer = new byte[2];
if(stream.Length < 8)
return false;
@@ -187,7 +191,8 @@ public sealed class XZ : IFilter
if(BasePath?.EndsWith(".xz", StringComparison.InvariantCultureIgnoreCase) == true)
return BasePath[..^3];
- return BasePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true ? BasePath[..^5]
+ return BasePath?.EndsWith(".xzip", StringComparison.InvariantCultureIgnoreCase) == true
+ ? BasePath[..^5]
: BasePath;
}
}
@@ -195,13 +200,15 @@ public sealed class XZ : IFilter
///
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
+#endregion
+
void GuessSize()
{
DataForkLength = 0;
// Seek to footer backwards size field
_dataStream.Seek(-8, SeekOrigin.End);
- byte[] tmp = new byte[4];
+ var tmp = new byte[4];
_dataStream.EnsureRead(tmp, 0, 4);
uint backwardSize = (BitConverter.ToUInt32(tmp, 0) + 1) * 4;
@@ -228,7 +235,8 @@ public sealed class XZ : IFilter
{
switch(sizeMax)
{
- case 0: return 0;
+ case 0:
+ return 0;
case > 9:
sizeMax = 9;
@@ -236,7 +244,7 @@ public sealed class XZ : IFilter
}
num = (ulong)(buf[0] & 0x7F);
- int i = 0;
+ var i = 0;
while((buf[i++] & 0x80) == 0x80)
{
@@ -244,7 +252,7 @@ public sealed class XZ : IFilter
buf[i] == 0x00)
return 0;
- num |= (ulong)(buf[i] & 0x7F) << (i * 7);
+ num |= (ulong)(buf[i] & 0x7F) << i * 7;
}
return i;
diff --git a/Aaru.Filters/ZZZNoFilter.cs b/Aaru.Filters/ZZZNoFilter.cs
index 638cd294d..24dcca669 100644
--- a/Aaru.Filters/ZZZNoFilter.cs
+++ b/Aaru.Filters/ZZZNoFilter.cs
@@ -43,10 +43,14 @@ public sealed class ZZZNoFilter : IFilter
{
Stream _dataStream;
+#region IFilter Members
+
///
public string Name => Localization.ZZZNoFilter_Name;
+
///
public Guid Id => new("12345678-AAAA-BBBB-CCCC-123456789000");
+
///
public string Author => Authors.NataliaPortillo;
@@ -136,4 +140,6 @@ public sealed class ZZZNoFilter : IFilter
///
public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath);
+
+#endregion
}
\ No newline at end of file