From 12a72a45e46b0310437e1b48d889a20a7637cb5b Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 16 Sep 2021 04:42:14 +0100 Subject: [PATCH] Consolidate error number enumerations. --- Aaru.Core/Sidecar/BlockMedia.cs | 4 +- Aaru.Core/Sidecar/Files.cs | 19 +-- Aaru.Filesystems/AppleDOS/Dir.cs | 19 +-- Aaru.Filesystems/AppleDOS/File.cs | 62 +++++---- Aaru.Filesystems/AppleDOS/Super.cs | 27 ++-- Aaru.Filesystems/AppleDOS/Xattr.cs | 35 ++--- Aaru.Filesystems/AppleMFS/Dir.cs | 10 +- Aaru.Filesystems/AppleMFS/File.cs | 84 ++++++------ Aaru.Filesystems/AppleMFS/Super.cs | 18 +-- Aaru.Filesystems/AppleMFS/Xattr.cs | 40 +++--- Aaru.Filesystems/CPM/Dir.cs | 9 +- Aaru.Filesystems/CPM/File.cs | 49 +++---- Aaru.Filesystems/CPM/Super.cs | 36 ++--- Aaru.Filesystems/CPM/Xattr.cs | 28 ++-- Aaru.Filesystems/FAT/Dir.cs | 28 ++-- Aaru.Filesystems/FAT/File.cs | 76 ++++++----- Aaru.Filesystems/FAT/Super.cs | 24 ++-- Aaru.Filesystems/FAT/Xattr.cs | 40 +++--- Aaru.Filesystems/FATX/Dir.cs | 22 +-- Aaru.Filesystems/FATX/FATX.cs | 11 +- Aaru.Filesystems/FATX/File.cs | 69 +++++----- Aaru.Filesystems/FATX/Super.cs | 29 ++-- Aaru.Filesystems/ISO9660/Dir.cs | 38 +++--- Aaru.Filesystems/ISO9660/File.cs | 84 ++++++------ Aaru.Filesystems/ISO9660/Super.cs | 35 ++--- Aaru.Filesystems/ISO9660/Xattr.cs | 74 +++++----- Aaru.Filesystems/LisaFS/Dir.cs | 44 +++--- Aaru.Filesystems/LisaFS/Extent.cs | 35 +++-- Aaru.Filesystems/LisaFS/File.cs | 128 +++++++++--------- Aaru.Filesystems/LisaFS/Super.cs | 44 +++--- Aaru.Filesystems/LisaFS/Xattr.cs | 58 ++++---- Aaru.Filesystems/Opera/Dir.cs | 25 ++-- Aaru.Filesystems/Opera/File.cs | 65 ++++----- Aaru.Filesystems/Opera/Opera.cs | 11 +- Aaru.Filesystems/Opera/Super.cs | 23 ++-- Aaru.Filesystems/UCSDPascal/Dir.cs | 10 +- Aaru.Filesystems/UCSDPascal/File.cs | 47 +++---- Aaru.Filesystems/UCSDPascal/Super.cs | 19 +-- Aaru.Filesystems/UCSDPascal/UCSDPascal.cs | 12 +- Aaru.Filters/AppleDouble.cs | 14 +- Aaru.Filters/AppleSingle.cs | 14 +- Aaru.Filters/BZip2.cs | 13 +- Aaru.Filters/GZip.cs | 14 +- Aaru.Filters/LZip.cs | 14 +- Aaru.Filters/MacBinary.cs | 13 +- Aaru.Filters/PCExchange.cs | 10 +- Aaru.Filters/XZ.cs | 14 +- Aaru.Filters/ZZZNoFilter.cs | 14 +- .../Panels/SubdirectoryViewModel.cs | 14 +- .../ViewModels/Windows/MainWindowViewModel.cs | 11 +- Aaru.Images/KryoFlux/Read.cs | 3 +- .../Filesystems/ReadOnlyFilesystemTest.cs | 37 ++--- Aaru.Tests/Filters/AppleDoubleDave.cs | 3 +- Aaru.Tests/Filters/AppleDoubleDos.cs | 3 +- Aaru.Tests/Filters/AppleDoubleNetatalk.cs | 3 +- Aaru.Tests/Filters/AppleDoubleOsX.cs | 3 +- Aaru.Tests/Filters/AppleDoubleProDos.cs | 3 +- Aaru.Tests/Filters/AppleDoubleUnAr.cs | 3 +- Aaru.Tests/Filters/AppleDoubleUnix.cs | 3 +- Aaru.Tests/Filters/AppleSingle.cs | 3 +- Aaru.Tests/Filters/BZip2.cs | 3 +- Aaru.Tests/Filters/GZip.cs | 3 +- Aaru.Tests/Filters/LZip.cs | 3 +- Aaru.Tests/Filters/MacBinary1.cs | 3 +- Aaru.Tests/Filters/MacBinary2.cs | 3 +- Aaru.Tests/Filters/MacBinary3.cs | 3 +- Aaru.Tests/Filters/PCExchange.cs | 3 +- Aaru.Tests/Filters/XZ.cs | 3 +- Aaru.Tests/Images/BlockMediaImageTest.cs | 12 +- Aaru.Tests/Images/OpticalMediaImageTest.cs | 6 +- Aaru.Tests/Issues/FsExtractHashIssueTest.cs | 19 +-- Aaru.Tests/Issues/FsExtractIssueTest.cs | 22 +-- Aaru/Commands/Device/DeviceReport.cs | 2 +- Aaru/Commands/Filesystem/ExtractFiles.cs | 20 +-- Aaru/Commands/Filesystem/Ls.cs | 14 +- Aaru/Commands/Image/Convert.cs | 26 ++-- Aaru/Commands/Image/CreateSidecar.cs | 4 +- Aaru/Commands/Media/Dump.cs | 2 +- 78 files changed, 945 insertions(+), 906 deletions(-) diff --git a/Aaru.Core/Sidecar/BlockMedia.cs b/Aaru.Core/Sidecar/BlockMedia.cs index 316463933..cdbf3b2cc 100644 --- a/Aaru.Core/Sidecar/BlockMedia.cs +++ b/Aaru.Core/Sidecar/BlockMedia.cs @@ -589,7 +589,7 @@ namespace Aaru.Core continue; if(plugin is IReadOnlyFilesystem fsPlugin && - fsPlugin.Mount(image, partitions[i], encoding, null, null) == Errno.NoError) + fsPlugin.Mount(image, partitions[i], encoding, null, null) == ErrorNumber.NoError) { UpdateStatus($"Mounting {fsPlugin.XmlFsType.Type}"); @@ -644,7 +644,7 @@ namespace Aaru.Core continue; if(plugin is IReadOnlyFilesystem fsPlugin && - fsPlugin.Mount(image, wholePart, encoding, null, null) == Errno.NoError) + fsPlugin.Mount(image, wholePart, encoding, null, null) == ErrorNumber.NoError) { UpdateStatus($"Mounting {fsPlugin.XmlFsType.Type}"); diff --git a/Aaru.Core/Sidecar/Files.cs b/Aaru.Core/Sidecar/Files.cs index c175b4731..306d4cef6 100644 --- a/Aaru.Core/Sidecar/Files.cs +++ b/Aaru.Core/Sidecar/Files.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -47,9 +48,9 @@ namespace Aaru.Core { var contents = new FilesystemContentsType(); - Errno ret = filesystem.ReadDir("/", out List dirents); + ErrorNumber ret = filesystem.ReadDir("/", out List dirents); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) return null; List directories = new(); @@ -59,7 +60,7 @@ namespace Aaru.Core { ret = filesystem.Stat(dirent, out FileEntryInfo stat); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("Create-Sidecar command", "Cannot stat {0}", dirent); @@ -150,9 +151,9 @@ namespace Aaru.Core directory.statusChangeTimeSpecified = true; } - Errno ret = filesystem.ReadDir(path + "/" + filename, out List dirents); + ErrorNumber ret = filesystem.ReadDir(path + "/" + filename, out List dirents); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) return null; List directories = new(); @@ -162,7 +163,7 @@ namespace Aaru.Core { ret = filesystem.Stat(path + "/" + filename + "/" + dirent, out FileEntryInfo entryStat); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("Create-Sidecar command", "Cannot stat {0}", dirent); @@ -292,9 +293,9 @@ namespace Aaru.Core else file.Checksums = _emptyChecksums; - Errno ret = filesystem.ListXAttr(path + "/" + filename, out List xattrs); + ErrorNumber ret = filesystem.ListXAttr(path + "/" + filename, out List xattrs); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) return file; List xattrTypes = new(); @@ -303,7 +304,7 @@ namespace Aaru.Core { ret = filesystem.GetXattr(path + "/" + filename, xattr, ref data); - if(ret != Errno.NoError) + if(ret != ErrorNumber.NoError) continue; var xattrChkWorker = new Checksum(); diff --git a/Aaru.Filesystems/AppleDOS/Dir.cs b/Aaru.Filesystems/AppleDOS/Dir.cs index 32cd462bb..3c81c9eac 100644 --- a/Aaru.Filesystems/AppleDOS/Dir.cs +++ b/Aaru.Filesystems/AppleDOS/Dir.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -42,24 +43,24 @@ namespace Aaru.Filesystems public sealed partial class AppleDOS { /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return !_mounted ? Errno.AccessDenied : Errno.NotSupported; + return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotSupported; } /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return Errno.NotSupported; + return ErrorNumber.NotSupported; contents = _catalogCache.Keys.ToList(); @@ -72,10 +73,10 @@ namespace Aaru.Filesystems contents.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } - Errno ReadCatalog() + ErrorNumber ReadCatalog() { var catalogMs = new MemoryStream(); ulong lba = (ulong)((_vtoc.catalogTrack * _sectorsPerTrack) + _vtoc.catalogSector); @@ -87,7 +88,7 @@ namespace Aaru.Filesystems if(lba == 0 || lba > _device.Info.Sectors) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; while(lba != 0) { @@ -138,7 +139,7 @@ namespace Aaru.Filesystems if(_debug) _catalogBlocks = catalogMs.ToArray(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleDOS/File.cs b/Aaru.Filesystems/AppleDOS/File.cs index 3918c79f1..eb6e4a83b 100644 --- a/Aaru.Filesystems/AppleDOS/File.cs +++ b/Aaru.Filesystems/AppleDOS/File.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; @@ -43,12 +44,12 @@ namespace Aaru.Filesystems public sealed partial class AppleDOS { /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -56,12 +57,12 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); if(!_fileCache.ContainsKey(filename)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; attributes = FileAttributes.Extents; attributes |= FileAttributes.File; @@ -74,14 +75,14 @@ namespace Aaru.Filesystems string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) attributes |= FileAttributes.System; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -89,13 +90,13 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; byte[] file; string filename = pathElements[0].ToUpperInvariant(); if(filename.Length > 30) - return Errno.NameTooLong; + return ErrorNumber.NameTooLong; if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || @@ -110,18 +111,18 @@ namespace Aaru.Filesystems { if(!_fileCache.TryGetValue(filename, out file)) { - Errno error = CacheFile(filename); + ErrorNumber error = CacheFile(filename); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(!_fileCache.TryGetValue(filename, out file)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } } if(offset >= file.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= file.Length) size = file.Length - offset; @@ -130,16 +131,16 @@ namespace Aaru.Filesystems Array.Copy(file, offset, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -147,15 +148,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); if(filename.Length > 30) - return Errno.NameTooLong; + return ErrorNumber.NameTooLong; if(!_fileCache.ContainsKey(filename)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; stat = new FileEntryInfo(); @@ -185,19 +186,19 @@ namespace Aaru.Filesystems stat.BlockSize = _vtoc.bytesPerSector; stat.Links = 1; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; // TODO: Not really important. - return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotImplemented; } - Errno CacheFile(string path) + ErrorNumber CacheFile(string path) { string[] pathElements = path.Split(new[] { @@ -205,15 +206,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); if(filename.Length > 30) - return Errno.NameTooLong; + return ErrorNumber.NameTooLong; if(!_catalogCache.TryGetValue(filename, out ushort ts)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; ulong lba = (ulong)((((ts & 0xFF00) >> 8) * _sectorsPerTrack) + (ts & 0xFF)); var fileMs = new MemoryStream(); @@ -266,15 +267,16 @@ namespace Aaru.Filesystems _fileCache.Add(filename, fileMs.ToArray()); _extentCache.Add(filename, tsListMs.ToArray()); - return Errno.NoError; + return ErrorNumber.NoError; } - Errno CacheAllFiles() + ErrorNumber CacheAllFiles() { _fileCache = new Dictionary(); _extentCache = new Dictionary(); - foreach(Errno error in _catalogCache.Keys.Select(CacheFile).Where(error => error != Errno.NoError)) + foreach(ErrorNumber error in _catalogCache.Keys.Select(CacheFile). + Where(error => error != ErrorNumber.NoError)) return error; uint tracksOnBoot = 1; @@ -288,7 +290,7 @@ namespace Aaru.Filesystems _bootBlocks = _device.ReadSectors(0, (uint)(tracksOnBoot * _sectorsPerTrack)); _usedSectors += (uint)(_bootBlocks.Length / _vtoc.bytesPerSector); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleDOS/Super.cs b/Aaru.Filesystems/AppleDOS/Super.cs index 3a8fe5cde..d7a56cb17 100644 --- a/Aaru.Filesystems/AppleDOS/Super.cs +++ b/Aaru.Filesystems/AppleDOS/Super.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -45,8 +46,8 @@ namespace Aaru.Filesystems public sealed partial class AppleDOS { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { _device = imagePlugin; _start = partition.Start; @@ -57,21 +58,21 @@ namespace Aaru.Filesystems { AaruConsole.DebugWriteLine("Apple DOS plugin", "Incorrect device size."); - return Errno.InOutError; + return ErrorNumber.InOutError; } if(_start > 0) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Partitions are not supported."); - return Errno.InOutError; + return ErrorNumber.InOutError; } if(_device.Info.SectorSize != 256) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Incorrect sector size."); - return Errno.InOutError; + return ErrorNumber.InOutError; } _sectorsPerTrack = _device.Info.Sectors == 455 ? 13 : 16; @@ -84,9 +85,9 @@ namespace Aaru.Filesystems _track2UsedByFiles = false; _usedSectors = 1; - Errno error = ReadCatalog(); + ErrorNumber error = ReadCatalog(); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Unable to read catalog."); @@ -95,7 +96,7 @@ namespace Aaru.Filesystems error = CacheAllFiles(); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("Apple DOS plugin", "Unable cache all files."); @@ -123,11 +124,11 @@ namespace Aaru.Filesystems _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { _mounted = false; _extentCache = null; @@ -135,11 +136,11 @@ namespace Aaru.Filesystems _catalogCache = null; _fileSizeCache = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = new FileSystemInfo { @@ -153,7 +154,7 @@ namespace Aaru.Filesystems stat.FreeFiles = _totalFileEntries - stat.Files; stat.FreeBlocks = stat.Blocks - _usedSectors; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleDOS/Xattr.cs b/Aaru.Filesystems/AppleDOS/Xattr.cs index be6f26f6b..06d255093 100644 --- a/Aaru.Filesystems/AppleDOS/Xattr.cs +++ b/Aaru.Filesystems/AppleDOS/Xattr.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; namespace Aaru.Filesystems @@ -39,12 +40,12 @@ namespace Aaru.Filesystems public sealed partial class AppleDOS { /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -52,12 +53,12 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); if(filename.Length > 30) - return Errno.NameTooLong; + return ErrorNumber.NameTooLong; xattrs = new List(); @@ -67,7 +68,7 @@ namespace Aaru.Filesystems else { if(!_catalogCache.ContainsKey(filename)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; xattrs.Add("com.apple.dos.type"); @@ -75,14 +76,14 @@ namespace Aaru.Filesystems xattrs.Add("com.apple.dos.tracksectorlist"); } - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -90,43 +91,43 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; string filename = pathElements[0].ToUpperInvariant(); if(filename.Length > 30) - return Errno.NameTooLong; + return ErrorNumber.NameTooLong; if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(!_catalogCache.ContainsKey(filename)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(string.Compare(xattr, "com.apple.dos.type", StringComparison.InvariantCulture) == 0) { if(!_fileTypeCache.TryGetValue(filename, out byte type)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; buf = new byte[1]; buf[0] = type; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(xattr, "com.apple.dos.tracksectorlist", StringComparison.InvariantCulture) != 0 || !_debug) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(!_extentCache.TryGetValue(filename, out byte[] ts)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; buf = new byte[ts.Length]; Array.Copy(ts, 0, buf, 0, buf.Length); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleMFS/Dir.cs b/Aaru.Filesystems/AppleMFS/Dir.cs index 15b1aa509..532111227 100644 --- a/Aaru.Filesystems/AppleMFS/Dir.cs +++ b/Aaru.Filesystems/AppleMFS/Dir.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; @@ -43,16 +43,16 @@ namespace Aaru.Filesystems public sealed partial class AppleMFS { /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return Errno.NotSupported; + return ErrorNumber.NotSupported; contents = _idToFilename.Select(kvp => kvp.Value).ToList(); @@ -68,7 +68,7 @@ namespace Aaru.Filesystems contents.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } bool FillDirectory() diff --git a/Aaru.Filesystems/AppleMFS/File.cs b/Aaru.Filesystems/AppleMFS/File.cs index 5928cc471..96d641b08 100644 --- a/Aaru.Filesystems/AppleMFS/File.cs +++ b/Aaru.Filesystems/AppleMFS/File.cs @@ -44,12 +44,12 @@ namespace Aaru.Filesystems public sealed partial class AppleMFS { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = new long(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -57,18 +57,18 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(fileBlock > entry.flPyLen / _volMdb.drAlBlkSiz) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; uint nextBlock = entry.flStBlk; long relBlock = 0; @@ -79,7 +79,7 @@ namespace Aaru.Filesystems { deviceBlock = ((nextBlock - 2) * _sectorsPerBlock) + _volMdb.drAlBlSt + (long)_partitionStart; - return Errno.NoError; + return ErrorNumber.NoError; } if(_blockMap[nextBlock] == BMAP_FREE || @@ -90,16 +90,16 @@ namespace Aaru.Filesystems relBlock++; } - return Errno.InOutError; + return ErrorNumber.InOutError; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -107,15 +107,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(entry.flUsrWds.fdFlags.HasFlag(AppleCommon.FinderFlags.kIsAlias)) attributes |= FileAttributes.Alias; @@ -154,17 +154,17 @@ namespace Aaru.Filesystems attributes |= FileAttributes.BlockUnits; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - byte[] file; - Errno error = Errno.NoError; + byte[] file; + ErrorNumber error = ErrorNumber.NoError; if(_debug && string.Compare(path, "$", StringComparison.InvariantCulture) == 0) file = _directoryBlocks; @@ -179,18 +179,18 @@ namespace Aaru.Filesystems else error = ReadFile(path, out file, false, false); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset >= file.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= file.Length) size = file.Length - offset; @@ -199,16 +199,16 @@ namespace Aaru.Filesystems Array.Copy(file, offset, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -216,7 +216,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; @@ -260,20 +260,20 @@ namespace Aaru.Filesystems stat.Length = _mdbBlocks.Length; } else - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; - return Errno.NoError; + return ErrorNumber.NoError; } if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; - Errno error = GetAttributes(path, out FileAttributes attr); + ErrorNumber error = GetAttributes(path, out FileAttributes attr); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; stat = new FileEntryInfo @@ -288,23 +288,23 @@ namespace Aaru.Filesystems Links = 1 }; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } - Errno ReadFile(string path, out byte[] buf, bool resourceFork, bool tags) + ErrorNumber ReadFile(string path, out byte[] buf, bool resourceFork, bool tags) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -312,15 +312,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; uint nextBlock; @@ -330,7 +330,7 @@ namespace Aaru.Filesystems { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } nextBlock = entry.flRStBlk; @@ -341,7 +341,7 @@ namespace Aaru.Filesystems { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } nextBlock = entry.flStBlk; @@ -400,7 +400,7 @@ namespace Aaru.Filesystems } } - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleMFS/Super.cs b/Aaru.Filesystems/AppleMFS/Super.cs index 3fb80e878..1adf471d1 100644 --- a/Aaru.Filesystems/AppleMFS/Super.cs +++ b/Aaru.Filesystems/AppleMFS/Super.cs @@ -48,8 +48,8 @@ namespace Aaru.Filesystems const int BYTES_BEFORE_BLOCK_MAP = 64; /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { _device = imagePlugin; _partitionStart = partition.Start; @@ -68,7 +68,7 @@ namespace Aaru.Filesystems _volMdb.drSigWord = BigEndianBitConverter.ToUInt16(_mdbBlocks, 0x000); if(_volMdb.drSigWord != MFS_MAGIC) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; _volMdb.drCrDate = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x002); _volMdb.drLsBkUp = BigEndianBitConverter.ToUInt32(_mdbBlocks, 0x006); @@ -158,7 +158,7 @@ namespace Aaru.Filesystems _sectorsPerBlock = (int)(_volMdb.drAlBlkSiz / _device.Info.SectorSize); if(!FillDirectory()) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; _mounted = true; @@ -192,11 +192,11 @@ namespace Aaru.Filesystems XmlFsType.Type = "MFS"; XmlFsType.VolumeName = _volMdb.drVN; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { _mounted = false; _idToFilename = null; @@ -204,11 +204,11 @@ namespace Aaru.Filesystems _filenameToId = null; _bootBlocks = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = new FileSystemInfo { @@ -222,7 +222,7 @@ namespace Aaru.Filesystems stat.FreeFiles = uint.MaxValue - stat.Files; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/AppleMFS/Xattr.cs b/Aaru.Filesystems/AppleMFS/Xattr.cs index 35e7524e8..a080cdc6b 100644 --- a/Aaru.Filesystems/AppleMFS/Xattr.cs +++ b/Aaru.Filesystems/AppleMFS/Xattr.cs @@ -43,12 +43,12 @@ namespace Aaru.Filesystems public sealed partial class AppleMFS { /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -56,7 +56,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; @@ -71,14 +71,14 @@ namespace Aaru.Filesystems if(_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag)) xattrs.Add("com.apple.macintosh.tags"); - return Errno.NoError; + return ErrorNumber.NoError; } if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(entry.flRLgLen > 0) { @@ -97,14 +97,14 @@ namespace Aaru.Filesystems xattrs.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -112,7 +112,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; path = pathElements[0]; @@ -129,7 +129,7 @@ namespace Aaru.Filesystems buf = new byte[_directoryTags.Length]; Array.Copy(_directoryTags, 0, buf, 0, buf.Length); - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(path, "$Bitmap", StringComparison.InvariantCulture) == 0) @@ -137,7 +137,7 @@ namespace Aaru.Filesystems buf = new byte[_bitmapTags.Length]; Array.Copy(_bitmapTags, 0, buf, 0, buf.Length); - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0) @@ -145,7 +145,7 @@ namespace Aaru.Filesystems buf = new byte[_bootTags.Length]; Array.Copy(_bootTags, 0, buf, 0, buf.Length); - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(path, "$MDB", StringComparison.InvariantCulture) == 0) @@ -153,19 +153,19 @@ namespace Aaru.Filesystems buf = new byte[_mdbTags.Length]; Array.Copy(_mdbTags, 0, buf, 0, buf.Length); - return Errno.NoError; + return ErrorNumber.NoError; } } else - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; - Errno error; + ErrorNumber error; if(!_filenameToId.TryGetValue(path.ToLowerInvariant(), out uint fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!_idToEntry.TryGetValue(fileId, out FileEntry entry)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(entry.flRLgLen > 0 && string.Compare(xattr, "com.apple.ResourceFork", StringComparison.InvariantCulture) == 0) @@ -187,13 +187,13 @@ namespace Aaru.Filesystems { buf = Marshal.StructureToByteArrayBigEndian(entry.flUsrWds); - return Errno.NoError; + return ErrorNumber.NoError; } if(!_debug || !_device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag) || string.Compare(xattr, "com.apple.macintosh.tags", StringComparison.InvariantCulture) != 0) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; error = ReadFile(path, out buf, false, true); diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index 2cca2bcf1..f6b1aec39 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -41,20 +42,20 @@ namespace Aaru.Filesystems public sealed partial class CPM { /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return Errno.NotSupported; + return ErrorNumber.NotSupported; contents = new List(_dirList); - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Filesystems/CPM/File.cs b/Aaru.Filesystems/CPM/File.cs index 156fde0a3..b487670d2 100644 --- a/Aaru.Filesystems/CPM/File.cs +++ b/Aaru.Filesystems/CPM/File.cs @@ -31,6 +31,7 @@ // ****************************************************************************/ using System; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -39,12 +40,12 @@ namespace Aaru.Filesystems public sealed partial class CPM { /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -52,7 +53,7 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(string.IsNullOrEmpty(pathElements[0]) || string.Compare(pathElements[0], "/", StringComparison.OrdinalIgnoreCase) == 0) @@ -60,41 +61,41 @@ namespace Aaru.Filesystems attributes = new FileAttributes(); attributes = FileAttributes.Directory; - return Errno.NoError; + return ErrorNumber.NoError; } if(!_statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out FileEntryInfo fInfo)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; attributes = fInfo.Attributes; - return Errno.NoError; + return ErrorNumber.NoError; } // TODO: Implementing this would require storing the interleaving /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; - return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotImplemented; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset < 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; string[] pathElements = path.Split(new[] { @@ -102,13 +103,13 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(!_fileCache.TryGetValue(pathElements[0].ToUpperInvariant(), out byte[] file)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(offset >= file.Length) - return Errno.EINVAL; + return ErrorNumber.EINVAL; if(size + offset >= file.Length) size = file.Length - offset; @@ -116,24 +117,24 @@ namespace Aaru.Filesystems buf = new byte[size]; Array.Copy(file, offset, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return !_mounted ? Errno.AccessDenied : Errno.NotSupported; + return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotSupported; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -141,12 +142,12 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return _statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? Errno.NoError - : Errno.NoSuchFile; + return _statCache.TryGetValue(pathElements[0].ToUpperInvariant(), out stat) ? ErrorNumber.NoError + : ErrorNumber.NoSuchFile; stat = new FileEntryInfo { @@ -160,7 +161,7 @@ namespace Aaru.Filesystems if(_labelUpdateDate != null) stat.StatusChangeTime = DateHandlers.CpmToDateTime(_labelUpdateDate); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index 21de2cabf..836b781a0 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -38,6 +38,7 @@ using System.IO; using System.Linq; using System.Text; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -51,8 +52,8 @@ namespace Aaru.Filesystems public sealed partial class CPM { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { _device = imagePlugin; Encoding = encoding ?? Encoding.GetEncoding("IBM437"); @@ -62,7 +63,7 @@ namespace Aaru.Filesystems !_cpmFound || _workingDefinition == null || _dpb == null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; // Build the software interleaving sector mask if(_workingDefinition.sides == 1) @@ -106,7 +107,7 @@ namespace Aaru.Filesystems // TODO: Implement CYLINDERS ordering AaruConsole.DebugWriteLine("CP/M Plugin", "CYLINDERS ordering not yet implemented."); - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } // TODO: Implement COLUMBIA ordering @@ -116,7 +117,7 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle COLUMBIA ordering, not proceeding with this definition."); - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } // TODO: Implement EAGLE ordering @@ -126,7 +127,7 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("CP/M Plugin", "Don't know how to handle EAGLE ordering, not proceeding with this definition."); - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } else { @@ -134,12 +135,12 @@ namespace Aaru.Filesystems "Unknown order type \"{0}\", not proceeding with this definition.", _workingDefinition.order); - return Errno.NotSupported; + return ErrorNumber.NotSupported; } } // Deinterleave whole volume - Dictionary deinterleavedSectors = new Dictionary(); + Dictionary deinterleavedSectors = new(); if(_workingDefinition.sides == 1 || string.Compare(_workingDefinition.order, "SIDES", StringComparison.InvariantCultureIgnoreCase) == 0) @@ -165,7 +166,7 @@ namespace Aaru.Filesystems var blockMs = new MemoryStream(); ulong blockNo = 0; int sectorsPerBlock = 0; - Dictionary allocationBlocks = new Dictionary(); + Dictionary allocationBlocks = new(); AaruConsole.DebugWriteLine("CP/M Plugin", "Creating allocation blocks."); @@ -224,15 +225,14 @@ namespace Aaru.Filesystems byte[] directory = dirMs.ToArray(); if(directory == null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; int dirCnt = 0; string file1 = null; string file2 = null; string file3 = null; - Dictionary>> fileExtents = - new Dictionary>>(); + Dictionary>> fileExtents = new(); _statCache = new Dictionary(); _cpmStat = new FileSystemInfo(); @@ -798,24 +798,24 @@ namespace Aaru.Filesystems _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = _cpmStat; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { _mounted = false; _definitions = null; @@ -829,7 +829,7 @@ namespace Aaru.Filesystems _labelCreationDate = null; _labelUpdateDate = null; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/CPM/Xattr.cs b/Aaru.Filesystems/CPM/Xattr.cs index feddb0e28..042487fb5 100644 --- a/Aaru.Filesystems/CPM/Xattr.cs +++ b/Aaru.Filesystems/CPM/Xattr.cs @@ -32,17 +32,17 @@ using System; using System.Collections.Generic; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; namespace Aaru.Filesystems { public sealed partial class CPM { /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -50,29 +50,29 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) - return Errno.NoError; + return ErrorNumber.NoError; if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; - return !_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? Errno.NoError - : Errno.NoSuchExtendedAttribute; + return !_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf) ? ErrorNumber.NoError + : ErrorNumber.NoSuchExtendedAttribute; } /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -80,10 +80,10 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; xattrs = new List(); @@ -93,7 +93,7 @@ namespace Aaru.Filesystems if(_decodedPasswordCache.ContainsKey(pathElements[0].ToUpperInvariant())) xattrs.Add("com.caldera.cpm.password.text"); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FAT/Dir.cs b/Aaru.Filesystems/FAT/Dir.cs index 028861173..f7d30423d 100644 --- a/Aaru.Filesystems/FAT/Dir.cs +++ b/Aaru.Filesystems/FAT/Dir.cs @@ -35,7 +35,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Console; using Aaru.Helpers; @@ -47,30 +47,30 @@ namespace Aaru.Filesystems /// Solves a symbolic link. /// Link path. /// Link destination. - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// /// Lists contents from a directory. /// Directory path. /// Directory contents. - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { contents = _rootDirectoryCache.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string cutPath = path.StartsWith("/", StringComparison.Ordinal) ? path.Substring(1).ToLower(_cultureInfo) @@ -80,7 +80,7 @@ namespace Aaru.Filesystems { contents = currentDirectory.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string[] pieces = cutPath.Split(new[] @@ -92,10 +92,10 @@ namespace Aaru.Filesystems _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -106,10 +106,10 @@ namespace Aaru.Filesystems entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.Dirent.attributes.HasFlag(FatAttributes.Subdirectory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.Dirent.start_cluster; @@ -126,13 +126,13 @@ namespace Aaru.Filesystems _directoryCache[currentPath] = new Dictionary(); contents = new List(); - return Errno.NoError; + return ErrorNumber.NoError; } uint[] clusters = GetClusters(currentCluster); if(clusters is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; @@ -389,7 +389,7 @@ namespace Aaru.Filesystems contents = currentDirectory?.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index 9b766fde2..9866c58be 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; @@ -43,74 +44,74 @@ namespace Aaru.Filesystems public sealed partial class FAT { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); if(fileBlock >= clusters.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; deviceBlock = (long)(_firstClusterSector + (clusters[fileBlock] * _sectorsPerCluster)); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; if(size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset >= stat.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= stat.Length) size = stat.Length - offset; @@ -118,7 +119,7 @@ namespace Aaru.Filesystems uint[] clusters = GetClusters((uint)stat.Inode); if(clusters is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; long firstCluster = offset / _bytesPerCluster; long offsetInCluster = offset % _bytesPerCluster; @@ -132,7 +133,7 @@ namespace Aaru.Filesystems for(int i = 0; i < sizeInClusters; i++) { if(i + firstCluster >= clusters.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] buffer = _image.ReadSectors(_firstClusterSector + (clusters[i + firstCluster] * _sectorsPerCluster), @@ -145,20 +146,20 @@ namespace Aaru.Filesystems buf = new byte[size]; ms.Read(buf, 0, (int)size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry); + ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry completeEntry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; DirectoryEntry entry = completeEntry.Dirent; @@ -196,8 +197,9 @@ namespace Aaru.Filesystems if((_fat32 && entry.ea_handle << 16 > 0) || entry.start_cluster > 0) - stat.Blocks = _fat32 ? (GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0) - : (GetClusters(entry.start_cluster)?.Length??0); + stat.Blocks = + _fat32 ? GetClusters((uint)((entry.ea_handle << 16) + entry.start_cluster))?.Length ?? 0 + : GetClusters(entry.start_cluster)?.Length ?? 0; stat.Length = stat.Blocks * stat.BlockSize; } @@ -217,7 +219,7 @@ namespace Aaru.Filesystems if(entry.attributes.HasFlag(FatAttributes.Device)) stat.Attributes |= FileAttributes.Device; - return Errno.NoError; + return ErrorNumber.NoError; } uint[] GetClusters(uint startCluster) @@ -228,7 +230,7 @@ namespace Aaru.Filesystems if(startCluster >= XmlFsType.Clusters) return null; - List clusters = new List(); + List clusters = new(); uint nextCluster = startCluster; @@ -283,7 +285,7 @@ namespace Aaru.Filesystems return clusters.ToArray(); } - Errno GetFileEntry(string path, out CompleteDirectoryEntry entry) + ErrorNumber GetFileEntry(string path, out CompleteDirectoryEntry entry) { entry = null; @@ -296,15 +298,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pieces.Length == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { - Errno err = ReadDir(parentPath, out _); + ErrorNumber err = ReadDir(parentPath, out _); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; } @@ -313,17 +315,17 @@ namespace Aaru.Filesystems if(pieces.Length == 1) parent = _rootDirectoryCache; else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); if(string.IsNullOrEmpty(dirent.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; entry = dirent.Value; - return Errno.NoError; + return ErrorNumber.NoError; } byte LfnChecksum(byte[] name, byte[] extension) diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 4d9d14b15..9b46053f9 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -55,8 +55,8 @@ namespace Aaru.Filesystems IMediaImage _image; /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { XmlFsType = new FileSystemType(); @@ -94,7 +94,7 @@ namespace Aaru.Filesystems _namespace = Namespace.Human; break; - default: return Errno.InvalidArgument; + default: return ErrorNumber.InvalidArgument; } AaruConsole.DebugWriteLine("FAT plugin", "Reading BPB"); @@ -553,7 +553,7 @@ namespace Aaru.Filesystems else { if(rootDirectoryCluster == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; var rootMs = new MemoryStream(); uint[] rootDirectoryClusters = GetClusters(rootDirectoryCluster); @@ -574,7 +574,7 @@ namespace Aaru.Filesystems } if(rootDirectory is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] lastLfnName = null; byte lastLfnChecksum = 0; @@ -1050,32 +1050,32 @@ namespace Aaru.Filesystems if(string.IsNullOrWhiteSpace(XmlFsType.VolumeName)) XmlFsType.VolumeName = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; _mounted = false; _fatEntries = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FAT/Xattr.cs b/Aaru.Filesystems/FAT/Xattr.cs index 81fa8bb0b..769b8d8d7 100644 --- a/Aaru.Filesystems/FAT/Xattr.cs +++ b/Aaru.Filesystems/FAT/Xattr.cs @@ -35,7 +35,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems @@ -45,17 +45,17 @@ namespace Aaru.Filesystems Dictionary> _eaCache; /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; // No other xattr recognized yet if(_cachedEaData is null && !_fat32) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(path[0] == '/') path = path.Substring(1); @@ -64,12 +64,12 @@ namespace Aaru.Filesystems { xattrs = eas.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } - Errno err = GetFileEntry(path, out CompleteDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out CompleteDirectoryEntry entry); - if(err != Errno.NoError || + if(err != ErrorNumber.NoError || entry is null) return err; @@ -78,54 +78,54 @@ namespace Aaru.Filesystems if(!_fat32) { if(entry.Dirent.ea_handle == 0) - return Errno.NoError; + return ErrorNumber.NoError; eas = GetEas(entry.Dirent.ea_handle); } else { if(entry.Fat32Ea.start_cluster == 0) - return Errno.NoError; + return ErrorNumber.NoError; eas = GetEas(entry.Fat32Ea); } if(eas is null) - return Errno.NoError; + return ErrorNumber.NoError; _eaCache.Add(path.ToLower(_cultureInfo), eas); xattrs = eas.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = ListXAttr(path, out List xattrs); + ErrorNumber err = ListXAttr(path, out List xattrs); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(path[0] == '/') path = path.Substring(1); if(!xattrs.Contains(xattr.ToLower(_cultureInfo))) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(!_eaCache.TryGetValue(path.ToLower(_cultureInfo), out Dictionary eas)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(!eas.TryGetValue(xattr.ToLower(_cultureInfo), out byte[] data)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; buf = new byte[data.Length]; data.CopyTo(buf, 0); - return Errno.NoError; + return ErrorNumber.NoError; } Dictionary GetEas(DirectoryEntry entryFat32Ea) @@ -189,7 +189,7 @@ namespace Aaru.Filesystems eaData.Length < 4) return null; - Dictionary eas = new Dictionary(); + Dictionary eas = new(); if(_debug) eas.Add("com.microsoft.os2.fea", eaData); diff --git a/Aaru.Filesystems/FATX/Dir.cs b/Aaru.Filesystems/FATX/Dir.cs index e7201534a..74f6560b6 100644 --- a/Aaru.Filesystems/FATX/Dir.cs +++ b/Aaru.Filesystems/FATX/Dir.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems @@ -41,19 +41,19 @@ namespace Aaru.Filesystems public sealed partial class XboxFatPlugin { /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { contents = _rootDirectory.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string cutPath = path.StartsWith('/') ? path.Substring(1).ToLower(_cultureInfo) @@ -63,7 +63,7 @@ namespace Aaru.Filesystems { contents = currentDirectory.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string[] pieces = cutPath.Split(new[] @@ -75,10 +75,10 @@ namespace Aaru.Filesystems _rootDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.attributes.HasFlag(Attributes.Directory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -89,10 +89,10 @@ namespace Aaru.Filesystems entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.attributes.HasFlag(Attributes.Directory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; uint currentCluster = entry.Value.firstCluster; @@ -103,7 +103,7 @@ namespace Aaru.Filesystems uint[] clusters = GetClusters(currentCluster); if(clusters is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] directoryBuffer = new byte[_bytesPerCluster * clusters.Length]; @@ -150,7 +150,7 @@ namespace Aaru.Filesystems contents = currentDirectory?.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FATX/FATX.cs b/Aaru.Filesystems/FATX/FATX.cs index cde5812d0..28afb764e 100644 --- a/Aaru.Filesystems/FATX/FATX.cs +++ b/Aaru.Filesystems/FATX/FATX.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; @@ -72,22 +73,22 @@ namespace Aaru.Filesystems public string Author => "Natalia Portillo"; /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) => Errno.NotSupported; + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) => ErrorNumber.NotSupported; /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index 430f5c58a..945b14434 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; @@ -43,67 +44,67 @@ namespace Aaru.Filesystems public sealed partial class XboxFatPlugin { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; uint[] clusters = GetClusters((uint)stat.Inode); if(fileBlock >= clusters.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; deviceBlock = (long)(_firstClusterSector + ((clusters[fileBlock] - 1) * _sectorsPerCluster)); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(stat.Attributes.HasFlag(FileAttributes.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; if(offset >= stat.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= stat.Length) size = stat.Length - offset; @@ -122,7 +123,7 @@ namespace Aaru.Filesystems for(int i = 0; i < sizeInClusters; i++) { if(i + firstCluster >= clusters.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] buffer = _imagePlugin. @@ -136,16 +137,16 @@ namespace Aaru.Filesystems buf = new byte[size]; ms.Read(buf, 0, (int)size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(_debug && (string.IsNullOrEmpty(path) || path == "$" || path == "/")) { @@ -159,12 +160,12 @@ namespace Aaru.Filesystems Links = 1 }; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno err = GetFileEntry(path, out DirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; stat = new FileEntryInfo @@ -209,7 +210,7 @@ namespace Aaru.Filesystems if(entry.attributes.HasFlag(Attributes.Archive)) stat.Attributes |= FileAttributes.Archive; - return Errno.NoError; + return ErrorNumber.NoError; } uint[] GetClusters(uint startCluster) @@ -225,7 +226,7 @@ namespace Aaru.Filesystems else if(startCluster >= _fat16.Length) return null; - List clusters = new List(); + List clusters = new(); uint nextCluster = startCluster; @@ -247,7 +248,7 @@ namespace Aaru.Filesystems return clusters.ToArray(); } - Errno GetFileEntry(string path, out DirectoryEntry entry) + ErrorNumber GetFileEntry(string path, out DirectoryEntry entry) { entry = new DirectoryEntry(); @@ -260,13 +261,13 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pieces.Length == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); - Errno err = ReadDir(parentPath, out _); + ErrorNumber err = ReadDir(parentPath, out _); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; Dictionary parent; @@ -274,17 +275,17 @@ namespace Aaru.Filesystems if(pieces.Length == 1) parent = _rootDirectory; else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(_cultureInfo) == pieces[^1]); if(string.IsNullOrEmpty(dirent.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; entry = dirent.Value; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index 0d5302702..7e8082669 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -36,6 +36,7 @@ using System.Globalization; using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -48,8 +49,8 @@ namespace Aaru.Filesystems public sealed partial class XboxFatPlugin { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { Encoding = Encoding.GetEncoding("iso-8859-15"); _littleEndian = true; @@ -60,7 +61,7 @@ namespace Aaru.Filesystems bool.TryParse(debugString, out _debug); if(imagePlugin.Info.SectorSize < 512) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; AaruConsole.DebugWriteLine("Xbox FAT plugin", "Reading superblock"); @@ -75,7 +76,7 @@ namespace Aaru.Filesystems } if(_superblock.magic != FATX_MAGIC) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; AaruConsole.DebugWriteLine("Xbox FAT plugin", _littleEndian ? "Filesystem is little endian" : "Filesystem is big endian"); @@ -161,7 +162,7 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); if(_fat32[0] != FATX32_ID) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } else { @@ -193,7 +194,7 @@ namespace Aaru.Filesystems AaruConsole.DebugWriteLine("Xbox FAT plugin", "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); if(_fat16[0] != FATX16_ID) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } _sectorsPerCluster = (uint)(_superblock.sectorsPerCluster * logicalSectorsPerPhysicalSectors); @@ -208,7 +209,7 @@ namespace Aaru.Filesystems uint[] rootDirectoryClusters = GetClusters(_superblock.rootDirectoryCluster); if(rootDirectoryClusters is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] rootDirectoryBuffer = new byte[_bytesPerCluster * rootDirectoryClusters.Length]; @@ -256,34 +257,34 @@ namespace Aaru.Filesystems _directoryCache = new Dictionary>(); _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; _fat16 = null; _fat32 = null; _imagePlugin = null; _mounted = false; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Dir.cs b/Aaru.Filesystems/ISO9660/Dir.cs index 61a1aeb00..60f809ce4 100644 --- a/Aaru.Filesystems/ISO9660/Dir.cs +++ b/Aaru.Filesystems/ISO9660/Dir.cs @@ -37,7 +37,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Text; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems @@ -47,19 +47,19 @@ namespace Aaru.Filesystems Dictionary> _directoryCache; /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { contents = GetFilenames(_rootDirectoryCache); - return Errno.NoError; + return ErrorNumber.NoError; } string cutPath = path.StartsWith("/", StringComparison.Ordinal) @@ -70,7 +70,7 @@ namespace Aaru.Filesystems { contents = currentDirectory.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string[] pieces = cutPath.Split(new[] @@ -82,10 +82,10 @@ namespace Aaru.Filesystems _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -96,10 +96,10 @@ namespace Aaru.Filesystems entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if(!entry.Value.Flags.HasFlag(FileFlags.Directory)) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; @@ -107,7 +107,7 @@ namespace Aaru.Filesystems continue; if(entry.Value.Extents.Count == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; currentDirectory = _cdi ? DecodeCdiDirectory(entry.Value.Extents[0].extent + entry.Value.XattrLength, @@ -131,12 +131,12 @@ namespace Aaru.Filesystems contents = GetFilenames(currentDirectory); - return Errno.NoError; + return ErrorNumber.NoError; } List GetFilenames(Dictionary dirents) { - List contents = new List(); + List contents = new(); foreach(DecodedDirectoryEntry entry in dirents.Values) switch(_namespace) @@ -161,7 +161,7 @@ namespace Aaru.Filesystems Dictionary DecodeCdiDirectory(ulong start, uint size) { - Dictionary entries = new Dictionary(); + Dictionary entries = new(); int entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -238,7 +238,7 @@ namespace Aaru.Filesystems Dictionary DecodeHighSierraDirectory(ulong start, uint size) { - Dictionary entries = new Dictionary(); + Dictionary entries = new(); int entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -309,7 +309,7 @@ namespace Aaru.Filesystems Dictionary DecodeIsoDirectory(ulong start, uint size) { - Dictionary entries = new Dictionary(); + Dictionary entries = new(); int entryOff = 0; byte[] data = ReadSingleExtent(size, (uint)start); @@ -1010,7 +1010,7 @@ namespace Aaru.Filesystems PathTableEntryInternal[] GetPathTableEntries(string path) { IEnumerable tableEntries; - List pathTableList = new List(_pathTable); + List pathTableList = new(_pathTable); if(path == "" || path == "/") @@ -1050,7 +1050,7 @@ namespace Aaru.Filesystems DecodedDirectoryEntry[] GetSubdirsFromCdiPathTable(string path) { PathTableEntryInternal[] tableEntries = GetPathTableEntries(path); - List entries = new List(); + List entries = new(); foreach(PathTableEntryInternal tEntry in tableEntries) { @@ -1100,7 +1100,7 @@ namespace Aaru.Filesystems DecodedDirectoryEntry[] GetSubdirsFromIsoPathTable(string path) { PathTableEntryInternal[] tableEntries = GetPathTableEntries(path); - List entries = new List(); + List entries = new(); foreach(PathTableEntryInternal tEntry in tableEntries) { @@ -1150,7 +1150,7 @@ namespace Aaru.Filesystems DecodedDirectoryEntry[] GetSubdirsFromHighSierraPathTable(string path) { PathTableEntryInternal[] tableEntries = GetPathTableEntries(path); - List entries = new List(); + List entries = new(); foreach(PathTableEntryInternal tEntry in tableEntries) { diff --git a/Aaru.Filesystems/ISO9660/File.cs b/Aaru.Filesystems/ISO9660/File.cs index 6185d123c..8db8eb542 100644 --- a/Aaru.Filesystems/ISO9660/File.cs +++ b/Aaru.Filesystems/ISO9660/File.cs @@ -48,79 +48,79 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(entry.Flags.HasFlag(FileFlags.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; // TODO: Multi-extents if(entry.Extents.Count > 1) - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; deviceBlock = entry.Extents[0].extent + fileBlock; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; - return Errno.NoError; + return ErrorNumber.NoError; } // TODO: Resolve symbolic link /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(entry.Flags.HasFlag(FileFlags.Directory) && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; if(entry.Extents is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(entry.Size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset >= (long)entry.Size) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= (long)entry.Size) size = (long)entry.Size - offset; @@ -145,14 +145,14 @@ namespace Aaru.Filesystems buf = new byte[size]; Array.Copy(buffer, offsetInSector, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } catch(Exception e) { AaruConsole.DebugWriteLine("ISO9660 plugin", "Exception reading CD-i audio file"); AaruConsole.DebugWriteLine("ISO9660 plugin", "{0}", e); - return Errno.InOutError; + return ErrorNumber.InOutError; } } @@ -161,20 +161,20 @@ namespace Aaru.Filesystems entry.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, entry.XA?.filenumber ?? 0); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; stat = new FileEntryInfo @@ -357,7 +357,7 @@ namespace Aaru.Filesystems if(entry.XattrLength == 0 || _cdi || _highSierra) - return Errno.NoError; + return ErrorNumber.NoError; if(entry.CdiSystemArea != null) { @@ -413,28 +413,28 @@ namespace Aaru.Filesystems stat.CreationTimeUtc = DateHandlers.Iso9660ToDateTime(ear.creation_date); stat.LastWriteTimeUtc = DateHandlers.Iso9660ToDateTime(ear.modification_date); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if(entry.SymbolicLink is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; dest = entry.SymbolicLink; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno GetFileEntry(string path, out DecodedDirectoryEntry entry) + ErrorNumber GetFileEntry(string path, out DecodedDirectoryEntry entry) { entry = null; @@ -448,15 +448,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pieces.Length == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { - Errno err = ReadDir(parentPath, out _); + ErrorNumber err = ReadDir(parentPath, out _); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; } @@ -465,7 +465,7 @@ namespace Aaru.Filesystems if(pieces.Length == 1) parent = _rootDirectoryCache; else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[^1]); @@ -479,15 +479,15 @@ namespace Aaru.Filesystems pieces[^1] + ";1"); if(string.IsNullOrEmpty(dirent.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; } else - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; } entry = dirent.Value; - return Errno.NoError; + return ErrorNumber.NoError; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 429b72bbe..4bab4f382 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -35,6 +35,7 @@ using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -47,8 +48,8 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { Encoding = encoding ?? Encoding.GetEncoding(1252); byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" @@ -93,7 +94,7 @@ namespace Aaru.Filesystems _namespace = Namespace.Romeo; break; - default: return Errno.InvalidArgument; + default: return ErrorNumber.InvalidArgument; } PrimaryVolumeDescriptor? pvd = null; @@ -104,11 +105,11 @@ namespace Aaru.Filesystems // ISO9660 is designed for 2048 bytes/sector devices if(imagePlugin.Info.SectorSize < 2048) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. if(partition.End < 16) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; ulong counter = 0; @@ -144,7 +145,7 @@ namespace Aaru.Filesystems if(vdType == 255) // Supposedly we are in the PVD. { if(counter == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; break; } @@ -158,7 +159,7 @@ namespace Aaru.Filesystems CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { if(counter == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; break; } @@ -253,7 +254,7 @@ namespace Aaru.Filesystems { AaruConsole.ErrorWriteLine("ERROR: Could not find primary volume descriptor"); - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } if(_highSierra) @@ -406,7 +407,7 @@ namespace Aaru.Filesystems { AaruConsole.ErrorWriteLine("Cannot find root directory..."); - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } _usePathTable = true; @@ -462,7 +463,7 @@ namespace Aaru.Filesystems } catch { - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } byte[] ipbinSector = ReadSector(partition.Start); @@ -751,33 +752,33 @@ namespace Aaru.Filesystems _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; _rootDirectoryCache = null; _directoryCache = null; _mounted = false; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/ISO9660/Xattr.cs b/Aaru.Filesystems/ISO9660/Xattr.cs index 56a42e9cb..12c1b91e0 100644 --- a/Aaru.Filesystems/ISO9660/Xattr.cs +++ b/Aaru.Filesystems/ISO9660/Xattr.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems @@ -41,16 +41,16 @@ namespace Aaru.Filesystems public sealed partial class ISO9660 { /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; xattrs = new List(); @@ -82,7 +82,7 @@ namespace Aaru.Filesystems if(entry.Flags.HasFlag(FileFlags.Directory) || entry.Extents == null || entry.Extents.Count == 0) - return Errno.NoError; + return ErrorNumber.NoError; // TODO: No more exceptions try @@ -90,56 +90,56 @@ namespace Aaru.Filesystems byte[] sector = _image.ReadSectorLong(entry.Extents[0].extent * _blockSize / 2048); if(sector[15] != 2) - return Errno.NoError; + return ErrorNumber.NoError; } catch { - return Errno.NoError; + return ErrorNumber.NoError; } xattrs.Add("org.iso.mode2.subheader"); xattrs.Add("org.iso.mode2.subheader.copy"); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DecodedDirectoryEntry entry); + ErrorNumber err = GetFileEntry(path, out DecodedDirectoryEntry entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; switch(xattr) { case "org.iso.9660.ea": if(entry.XattrLength == 0) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(entry.Extents is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; buf = ReadSingleExtent(entry.XattrLength * _blockSize, entry.Extents[0].extent); - return Errno.NoError; + return ErrorNumber.NoError; case "org.iso.9660.AssociatedFile": if(entry.AssociatedFile is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(entry.AssociatedFile.Extents is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(entry.AssociatedFile.Size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } buf = ReadWithExtents(0, (long)entry.AssociatedFile.Size, entry.AssociatedFile.Extents, @@ -147,34 +147,34 @@ namespace Aaru.Filesystems entry.AssociatedFile.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, entry.AssociatedFile.XA?.filenumber ?? 0); - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.dos.type": if(entry.AppleDosType is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[1]; buf[0] = entry.AppleDosType.Value; - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.prodos.type": if(entry.AppleProDosType is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; buf = BitConverter.GetBytes(entry.AppleProDosType.Value); - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.ResourceFork": if(entry.ResourceFork is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; if(entry.ResourceFork.Extents is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(entry.ResourceFork.Size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } buf = ReadWithExtents(0, (long)entry.ResourceFork.Size, entry.ResourceFork.Extents, @@ -182,39 +182,39 @@ namespace Aaru.Filesystems entry.ResourceFork.XA?.attributes.HasFlag(XaAttributes.Interleaved) == true, entry.ResourceFork.XA?.filenumber ?? 0); - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.FinderInfo": if(entry.FinderInfo is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; buf = Marshal.StructureToByteArrayBigEndian(entry.FinderInfo.Value); - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.Macintosh.Icon": if(entry.AppleIcon is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[entry.AppleIcon.Length]; Array.Copy(entry.AppleIcon, 0, buf, 0, entry.AppleIcon.Length); - return Errno.NoError; + return ErrorNumber.NoError; case "com.amiga.comments": if(entry.AmigaComment is null) - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; buf = new byte[entry.AmigaComment.Length]; Array.Copy(entry.AmigaComment, 0, buf, 0, entry.AmigaComment.Length); - return Errno.NoError; + return ErrorNumber.NoError; case "org.iso.mode2.subheader": buf = ReadSubheaderWithExtents(entry.Extents, false); - return Errno.NoError; + return ErrorNumber.NoError; case "org.iso.mode2.subheader.copy": buf = ReadSubheaderWithExtents(entry.Extents, true); - return Errno.NoError; - default: return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoError; + default: return ErrorNumber.NoSuchExtendedAttribute; } } } diff --git a/Aaru.Filesystems/LisaFS/Dir.cs b/Aaru.Filesystems/LisaFS/Dir.cs index 07318aafc..6c0a3544e 100644 --- a/Aaru.Filesystems/LisaFS/Dir.cs +++ b/Aaru.Filesystems/LisaFS/Dir.cs @@ -43,29 +43,29 @@ namespace Aaru.Filesystems.LisaFS public sealed partial class LisaFS { /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; // LisaFS does not support symbolic links (afaik) - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; - Errno error = LookupFileId(path, out short fileId, out bool isDir); + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(!isDir) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; /*List catalog; error = ReadCatalog(fileId, out catalog); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error;*/ ReadDir(fileId, out contents); @@ -84,7 +84,7 @@ namespace Aaru.Filesystems.LisaFS contents.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } void ReadDir(short dirId, out List contents) => @@ -95,10 +95,10 @@ namespace Aaru.Filesystems.LisaFS select StringHandlers.CToString(entry.filename, Encoding).Replace('/', '-')).ToList(); /// Reads, interprets and caches the Catalog File - Errno ReadCatalog() + ErrorNumber ReadCatalog() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; _catalogCache = new List(); @@ -106,9 +106,9 @@ namespace Aaru.Filesystems.LisaFS if(_mddf.fsversion == LISA_V2 || _mddf.fsversion == LISA_V1) { - Errno error = ReadFile((short)FILEID_CATALOG, out byte[] buf); + ErrorNumber error = ReadFile((short)FILEID_CATALOG, out byte[] buf); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; int offset = 0; @@ -146,7 +146,7 @@ namespace Aaru.Filesystems.LisaFS { error = ReadExtentsFile(entV2.fileID, out ExtentFile ext); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) continue; var entV3 = new CatalogEntry @@ -164,7 +164,7 @@ namespace Aaru.Filesystems.LisaFS _catalogCache.Add(entV3); } - return Errno.NoError; + return ErrorNumber.NoError; } byte[] firstCatalogBlock = null; @@ -187,7 +187,7 @@ namespace Aaru.Filesystems.LisaFS // Catalog not found if(firstCatalogBlock == null) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; ulong prevCatalogPointer = BigEndianBitConverter.ToUInt32(firstCatalogBlock, 0x7F6); @@ -198,7 +198,7 @@ namespace Aaru.Filesystems.LisaFS out LisaTag.PriamTag prevTag); if(prevTag.FileId != FILEID_CATALOG) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; firstCatalogBlock = _device.ReadSectors(prevCatalogPointer + _mddf.mddf_block + _volumePrefix, 4); prevCatalogPointer = BigEndianBitConverter.ToUInt32(firstCatalogBlock, 0x7F6); @@ -218,7 +218,7 @@ namespace Aaru.Filesystems.LisaFS out LisaTag.PriamTag nextTag); if(nextTag.FileId != FILEID_CATALOG) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; byte[] nextCatalogBlock = _device.ReadSectors(nextCatalogPointer + _mddf.mddf_block + _volumePrefix, 4); nextCatalogPointer = BigEndianBitConverter.ToUInt32(nextCatalogBlock, 0x7FA); @@ -268,7 +268,7 @@ namespace Aaru.Filesystems.LisaFS Array.Copy(buf, offset + 0x03, entry.filename, 0, E_NAME); Array.Copy(buf, offset + 0x38, entry.tail, 0, 8); - if(ReadExtentsFile(entry.fileID, out _) == Errno.NoError) + if(ReadExtentsFile(entry.fileID, out _) == ErrorNumber.NoError) if(!_fileSizeCache.ContainsKey(entry.fileID)) { _catalogCache.Add(entry); @@ -311,15 +311,15 @@ namespace Aaru.Filesystems.LisaFS break; } - return Errno.NoError; + return ErrorNumber.NoError; } - Errno StatDir(short dirId, out FileEntryInfo stat) + ErrorNumber StatDir(short dirId, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = new FileEntryInfo { @@ -338,7 +338,7 @@ namespace Aaru.Filesystems.LisaFS _directoryDtcCache.TryGetValue(dirId, out DateTime tmp); stat.CreationTime = tmp; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/Extent.cs b/Aaru.Filesystems/LisaFS/Extent.cs index 6a090c637..3ffc3089d 100644 --- a/Aaru.Filesystems/LisaFS/Extent.cs +++ b/Aaru.Filesystems/LisaFS/Extent.cs @@ -32,7 +32,6 @@ using System; using Aaru.CommonTypes.Enums; -using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Decoders; using Aaru.Helpers; @@ -42,42 +41,42 @@ namespace Aaru.Filesystems.LisaFS public sealed partial class LisaFS { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; // TODO: Not really important. - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } /// Searches the disk for an extents file (or gets it from cache) /// Error. /// File identifier. /// Extents file. - Errno ReadExtentsFile(short fileId, out ExtentFile file) + ErrorNumber ReadExtentsFile(short fileId, out ExtentFile file) { file = new ExtentFile(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(fileId < 4 || (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(_extentCache.TryGetValue(fileId, out file)) - return Errno.NoError; + return ErrorNumber.NoError; // A file ID that cannot be stored in the S-Records File if(fileId >= _srecords.Length) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; ulong ptr = _srecords[fileId].extent_ptr; // An invalid pointer denotes file does not exist if(ptr == 0xFFFFFFFF || ptr == 0x00000000) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; // Pointers are relative to MDDF ptr += _mddf.mddf_block + _volumePrefix; @@ -105,20 +104,20 @@ namespace Aaru.Filesystems.LisaFS } if(!found) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } // Checks that the sector tag indicates its the Extents File we are searching for DecodeTag(_device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag); if(extTag.FileId != (short)(-1 * fileId)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; byte[] sector = _mddf.fsversion == LISA_V1 ? _device.ReadSectors(ptr, 2) : _device.ReadSector(ptr); if(sector[0] >= 32 || sector[0] == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; file.filenameLen = sector[0]; file.filename = new byte[file.filenameLen]; @@ -197,10 +196,10 @@ namespace Aaru.Filesystems.LisaFS _extentCache.Add(fileId, file); if(!_debug) - return Errno.NoError; + return ErrorNumber.NoError; if(_printedExtents.Contains(fileId)) - return Errno.NoError; + return ErrorNumber.NoError; AaruConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId, file.filenameLen); @@ -277,14 +276,14 @@ namespace Aaru.Filesystems.LisaFS _printedExtents.Add(fileId); - return Errno.NoError; + return ErrorNumber.NoError; } /// Reads all the S-Records and caches it - Errno ReadSRecords() + ErrorNumber ReadSRecords() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; // Searches the S-Records place using MDDF pointers byte[] sectors = _device.ReadSectors(_mddf.srec_ptr + _mddf.mddf_block + _volumePrefix, _mddf.srec_len); @@ -301,7 +300,7 @@ namespace Aaru.Filesystems.LisaFS flags = BigEndianBitConverter.ToUInt16(sectors, 0x0C + (14 * s)) }; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index a072e867d..bcdc5c20c 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -42,13 +42,13 @@ namespace Aaru.Filesystems.LisaFS public sealed partial class LisaFS { /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); - Errno error = LookupFileId(path, out short fileId, out bool isDir); + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(!isDir) @@ -56,25 +56,25 @@ namespace Aaru.Filesystems.LisaFS attributes = FileAttributes.Directory; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(size == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset < 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; - Errno error = LookupFileId(path, out short fileId, out _); + ErrorNumber error = LookupFileId(path, out short fileId, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; byte[] tmp; @@ -99,11 +99,11 @@ namespace Aaru.Filesystems.LisaFS else error = ReadFile(fileId, out tmp); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(offset >= tmp.Length) - return Errno.EINVAL; + return ErrorNumber.EINVAL; if(size + offset >= tmp.Length) size = tmp.Length - offset; @@ -111,32 +111,32 @@ namespace Aaru.Filesystems.LisaFS buf = new byte[size]; Array.Copy(tmp, offset, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; - Errno error = LookupFileId(path, out short fileId, out bool isDir); + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; return isDir ? StatDir(fileId, out stat) : Stat(fileId, out stat); } - Errno GetAttributes(short fileId, out FileAttributes attributes) + ErrorNumber GetAttributes(short fileId, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(fileId < 4) { if(!_debug) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; attributes = new FileAttributes(); attributes = FileAttributes.System; @@ -144,12 +144,12 @@ namespace Aaru.Filesystems.LisaFS attributes |= FileAttributes.File; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno error = ReadExtentsFile(fileId, out ExtentFile extFile); + ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile extFile); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; switch(extFile.ftype) @@ -184,28 +184,28 @@ namespace Aaru.Filesystems.LisaFS if(extFile.password_valid > 0) attributes |= FileAttributes.Password; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno ReadSystemFile(short fileId, out byte[] buf) => ReadSystemFile(fileId, out buf, false); + ErrorNumber ReadSystemFile(short fileId, out byte[] buf) => ReadSystemFile(fileId, out buf, false); - Errno ReadSystemFile(short fileId, out byte[] buf, bool tags) + ErrorNumber ReadSystemFile(short fileId, out byte[] buf, bool tags) { buf = null; if(!_mounted || !_debug) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(fileId > 4 || fileId <= 0) if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) - return Errno.NoError; + return ErrorNumber.NoError; int count = 0; @@ -215,14 +215,14 @@ namespace Aaru.Filesystems.LisaFS buf = _device.ReadSectors(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len); _systemFileCache.Add(fileId, buf); - return Errno.NoError; + return ErrorNumber.NoError; } else { buf = _device.ReadSectorsTag(_mddf.mddf_block + _volumePrefix + _mddf.srec_ptr, _mddf.srec_len, SectorTagType.AppleSectorTag); - return Errno.NoError; + return ErrorNumber.NoError; } LisaTag.PriamTag sysTag; @@ -237,7 +237,7 @@ namespace Aaru.Filesystems.LisaFS } if(count == 0) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; buf = !tags ? new byte[count * _device.Info.SectorSize] : new byte[count * _devTagSize]; @@ -261,23 +261,23 @@ namespace Aaru.Filesystems.LisaFS if(!tags) _systemFileCache.Add(fileId, buf); - return Errno.NoError; + return ErrorNumber.NoError; } - Errno Stat(short fileId, out FileEntryInfo stat) + ErrorNumber Stat(short fileId, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno error; - ExtentFile file; + ErrorNumber error; + ExtentFile file; if(fileId <= 4) if(!_debug || fileId == 0) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; else { stat = new FileEntryInfo(); @@ -286,7 +286,7 @@ namespace Aaru.Filesystems.LisaFS stat.Attributes = attrs; - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; if(fileId < 0 && @@ -295,7 +295,7 @@ namespace Aaru.Filesystems.LisaFS { error = ReadExtentsFile((short)(fileId * -1), out file); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; stat.CreationTime = DateHandlers.LisaToDateTime(file.dtc); @@ -313,7 +313,7 @@ namespace Aaru.Filesystems.LisaFS { error = ReadSystemFile(fileId, out byte[] buf); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; stat.CreationTime = fileId != 4 ? _mddf.dtvc : _mddf.dtcc; @@ -327,7 +327,7 @@ namespace Aaru.Filesystems.LisaFS stat.Blocks = buf.Length / _mddf.datasize; } - return Errno.NoError; + return ErrorNumber.NoError; } stat = new FileEntryInfo(); @@ -335,12 +335,12 @@ namespace Aaru.Filesystems.LisaFS error = GetAttributes(fileId, out FileAttributes fileAttributes); stat.Attributes = fileAttributes; - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; error = ReadExtentsFile(fileId, out file); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; stat.CreationTime = DateHandlers.LisaToDateTime(file.dtc); @@ -359,31 +359,31 @@ namespace Aaru.Filesystems.LisaFS stat.BlockSize = _mddf.datasize; stat.Blocks = file.length; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno ReadFile(short fileId, out byte[] buf) => ReadFile(fileId, out buf, false); + ErrorNumber ReadFile(short fileId, out byte[] buf) => ReadFile(fileId, out buf, false); - Errno ReadFile(short fileId, out byte[] buf, bool tags) + ErrorNumber ReadFile(short fileId, out byte[] buf, bool tags) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; tags &= _debug; if(fileId < 4 || (fileId == 4 && _mddf.fsversion != LISA_V2 && _mddf.fsversion != LISA_V1)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(!tags && _fileCache.TryGetValue(fileId, out buf)) - return Errno.NoError; + return ErrorNumber.NoError; - Errno error = ReadExtentsFile(fileId, out ExtentFile file); + ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; int sectorSize; @@ -425,16 +425,16 @@ namespace Aaru.Filesystems.LisaFS else buf = temp; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno LookupFileId(string path, out short fileId, out bool isDir) + ErrorNumber LookupFileId(string path, out short fileId, out bool isDir) { fileId = 0; isDir = false; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -446,13 +446,13 @@ namespace Aaru.Filesystems.LisaFS fileId = DIRID_ROOT; isDir = true; - return Errno.NoError; + return ErrorNumber.NoError; } // Only V3 supports subdirectories if(pathElements.Length > 1 && _mddf.fsversion != LISA_V3) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(_debug && pathElements.Length == 1) { @@ -460,35 +460,35 @@ namespace Aaru.Filesystems.LisaFS { fileId = (short)FILEID_MDDF; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(pathElements[0], "$Boot", StringComparison.InvariantCulture) == 0) { fileId = FILEID_BOOT_SIGNED; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(pathElements[0], "$Loader", StringComparison.InvariantCulture) == 0) { fileId = FILEID_LOADER_SIGNED; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(pathElements[0], "$Bitmap", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_BITMAP; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(pathElements[0], "$S-Record", StringComparison.InvariantCulture) == 0) { fileId = (short)FILEID_SRECORD; - return Errno.NoError; + return ErrorNumber.NoError; } if(string.Compare(pathElements[0], "$", StringComparison.InvariantCulture) == 0) @@ -496,7 +496,7 @@ namespace Aaru.Filesystems.LisaFS fileId = DIRID_ROOT; isDir = true; - return Errno.NoError; + return ErrorNumber.NoError; } } @@ -519,15 +519,15 @@ namespace Aaru.Filesystems.LisaFS // Not last path element, and it's not a directory if(lvl != pathElements.Length - 1 && !isDir) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; // Arrived last path element if(lvl == pathElements.Length - 1) - return Errno.NoError; + return ErrorNumber.NoError; } } - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/Super.cs b/Aaru.Filesystems/LisaFS/Super.cs index a7e171f13..d5c9696d2 100644 --- a/Aaru.Filesystems/LisaFS/Super.cs +++ b/Aaru.Filesystems/LisaFS/Super.cs @@ -48,8 +48,8 @@ namespace Aaru.Filesystems.LisaFS public sealed partial class LisaFS { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { try { @@ -63,7 +63,7 @@ namespace Aaru.Filesystems.LisaFS { AaruConsole.DebugWriteLine("LisaFS plugin", "Underlying device does not support Lisa tags"); - return Errno.InOutError; + return ErrorNumber.InOutError; } // Minimal LisaOS disk is 3.5" single sided double density, 800 sectors @@ -71,7 +71,7 @@ namespace Aaru.Filesystems.LisaFS { AaruConsole.DebugWriteLine("LisaFS plugin", "Device is too small"); - return Errno.InOutError; + return ErrorNumber.InOutError; } // MDDF cannot be at end of device, of course @@ -188,7 +188,7 @@ namespace Aaru.Filesystems.LisaFS { AaruConsole.DebugWriteLine("LisaFS plugin", "Incorrect MDDF found"); - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; } // Check MDDF version @@ -209,7 +209,7 @@ namespace Aaru.Filesystems.LisaFS default: AaruConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", _mddf.fsversion.ToString()); - return Errno.NotSupported; + return ErrorNumber.NotSupported; } // Initialize caches @@ -231,9 +231,9 @@ namespace Aaru.Filesystems.LisaFS _printedExtents = new List(); // Read the S-Records file - Errno error = ReadSRecords(); + ErrorNumber error = ReadSRecords(); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine("Error {0} reading S-Records file.", error); @@ -250,7 +250,7 @@ namespace Aaru.Filesystems.LisaFS // Read the Catalog File error = ReadCatalog(); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Cannot read Catalog File, error {0}", error.ToString()); @@ -265,7 +265,7 @@ namespace Aaru.Filesystems.LisaFS { error = ReadSystemFile(FILEID_BOOT_SIGNED, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot blocks"); _mounted = false; @@ -275,7 +275,7 @@ namespace Aaru.Filesystems.LisaFS error = ReadSystemFile(FILEID_LOADER_SIGNED, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot loader"); _mounted = false; @@ -285,7 +285,7 @@ namespace Aaru.Filesystems.LisaFS error = ReadSystemFile((short)FILEID_MDDF, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read MDDF"); _mounted = false; @@ -295,7 +295,7 @@ namespace Aaru.Filesystems.LisaFS error = ReadSystemFile((short)FILEID_BITMAP, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read volume bitmap"); _mounted = false; @@ -305,7 +305,7 @@ namespace Aaru.Filesystems.LisaFS error = ReadSystemFile((short)FILEID_SRECORD, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.DebugWriteLine("LisaFS plugin", "Unable to read S-Records file"); _mounted = false; @@ -341,23 +341,23 @@ namespace Aaru.Filesystems.LisaFS XmlFsType.VolumeName = _mddf.volname; XmlFsType.VolumeSerial = $"{_mddf.volid:X16}"; - return Errno.NoError; + return ErrorNumber.NoError; } AaruConsole.DebugWriteLine("LisaFS plugin", "Not a Lisa filesystem"); - return Errno.NotSupported; + return ErrorNumber.NotSupported; } catch(Exception ex) { AaruConsole.ErrorWriteLine("Exception {0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace); - return Errno.InOutError; + return ErrorNumber.InOutError; } } /// - public Errno Unmount() + public ErrorNumber Unmount() { _mounted = false; _extentCache = null; @@ -371,16 +371,16 @@ namespace Aaru.Filesystems.LisaFS _devTagSize = 0; _srecords = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = new FileSystemInfo { @@ -414,7 +414,7 @@ namespace Aaru.Filesystems.LisaFS break; } - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/LisaFS/Xattr.cs b/Aaru.Filesystems/LisaFS/Xattr.cs index febb11820..b68d9742d 100644 --- a/Aaru.Filesystems/LisaFS/Xattr.cs +++ b/Aaru.Filesystems/LisaFS/Xattr.cs @@ -34,7 +34,7 @@ using System; using System.Collections.Generic; using System.Text; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Decoders; using Aaru.Helpers; @@ -43,45 +43,45 @@ namespace Aaru.Filesystems.LisaFS public sealed partial class LisaFS { /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; - Errno error = LookupFileId(path, out short fileId, out bool isDir); + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; - return isDir ? Errno.InvalidArgument : ListXAttr(fileId, out xattrs); + return isDir ? ErrorNumber.InvalidArgument : ListXAttr(fileId, out xattrs); } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) { - Errno error = LookupFileId(path, out short fileId, out bool isDir); + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; - return isDir ? Errno.InvalidArgument : GetXattr(fileId, xattr, out buf); + return isDir ? ErrorNumber.InvalidArgument : GetXattr(fileId, xattr, out buf); } /// Lists special Apple Lisa filesystem features as extended attributes /// Error number. /// File identifier. /// Extended attributes. - Errno ListXAttr(short fileId, out List xattrs) + ErrorNumber ListXAttr(short fileId, out List xattrs) { xattrs = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; // System files if(fileId < 4) { if(!_debug || fileId == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; xattrs = new List(); @@ -98,9 +98,9 @@ namespace Aaru.Filesystems.LisaFS else { // Search for the file - Errno error = ReadExtentsFile(fileId, out ExtentFile file); + ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; xattrs = new List(); @@ -124,7 +124,7 @@ namespace Aaru.Filesystems.LisaFS xattrs.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } /// Lists special Apple Lisa filesystem features as extended attributes @@ -132,19 +132,19 @@ namespace Aaru.Filesystems.LisaFS /// File identifier. /// Extended attribute name. /// Buffer where the extended attribute will be stored. - Errno GetXattr(short fileId, string xattr, out byte[] buf) + ErrorNumber GetXattr(short fileId, string xattr, out byte[] buf) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; // System files if(fileId < 4) { if(!_debug || fileId == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; // Only MDDF contains an extended attributes if(fileId == FILEID_MDDF) @@ -152,20 +152,20 @@ namespace Aaru.Filesystems.LisaFS { buf = Encoding.ASCII.GetBytes(_mddf.password); - return Errno.NoError; + return ErrorNumber.NoError; } // But on debug mode even system files contain tags if(_debug && xattr == "com.apple.lisa.tags") return ReadSystemFile(fileId, out buf, true); - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; } // Search for the file - Errno error = ReadExtentsFile(fileId, out ExtentFile file); + ErrorNumber error = ReadExtentsFile(fileId, out ExtentFile file); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; switch(xattr) @@ -174,11 +174,11 @@ namespace Aaru.Filesystems.LisaFS buf = new byte[8]; Array.Copy(file.password, 0, buf, 0, 8); - return Errno.NoError; + return ErrorNumber.NoError; case "com.apple.lisa.serial" when file.serial > 0: buf = Encoding.ASCII.GetBytes(file.serial.ToString()); - return Errno.NoError; + return ErrorNumber.NoError; } if(!ArrayHelpers.ArrayIsNullOrEmpty(file.LisaInfo) && @@ -187,30 +187,30 @@ namespace Aaru.Filesystems.LisaFS buf = new byte[128]; Array.Copy(file.LisaInfo, 0, buf, 0, 128); - return Errno.NoError; + return ErrorNumber.NoError; } if(_debug && xattr == "com.apple.lisa.tags") return ReadFile(fileId, out buf, true); - return Errno.NoSuchExtendedAttribute; + return ErrorNumber.NoSuchExtendedAttribute; } /// Decodes a sector tag. Not tested with 24-byte tags. /// Error number. /// Sector tag. /// Decoded sector tag. - static Errno DecodeTag(byte[] tag, out LisaTag.PriamTag decoded) + static ErrorNumber DecodeTag(byte[] tag, out LisaTag.PriamTag decoded) { decoded = new LisaTag.PriamTag(); LisaTag.PriamTag? pmTag = LisaTag.DecodeTag(tag); if(!pmTag.HasValue) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; decoded = pmTag.Value; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/Opera/Dir.cs b/Aaru.Filesystems/Opera/Dir.cs index 55966ea7d..c92a6106d 100644 --- a/Aaru.Filesystems/Opera/Dir.cs +++ b/Aaru.Filesystems/Opera/Dir.cs @@ -34,7 +34,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems @@ -42,19 +42,19 @@ namespace Aaru.Filesystems public sealed partial class OperaFS { /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(string.IsNullOrWhiteSpace(path) || path == "/") { contents = _rootDirectoryCache.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string cutPath = path.StartsWith("/", StringComparison.Ordinal) @@ -66,7 +66,7 @@ namespace Aaru.Filesystems { contents = currentDirectory.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } string[] pieces = cutPath.Split(new[] @@ -78,10 +78,10 @@ namespace Aaru.Filesystems _rootDirectoryCache.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[0]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; string currentPath = pieces[0]; @@ -92,10 +92,10 @@ namespace Aaru.Filesystems entry = currentDirectory.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[p]); if(string.IsNullOrEmpty(entry.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; if((entry.Value.Entry.flags & FLAGS_MASK) != (int)FileFlags.Directory) - return Errno.NotDirectory; + return ErrorNumber.NotDirectory; currentPath = p == 0 ? pieces[0] : $"{currentPath}/{pieces[p]}"; @@ -103,7 +103,7 @@ namespace Aaru.Filesystems continue; if(entry.Value.Pointers.Length < 1) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; currentDirectory = DecodeDirectory((int)entry.Value.Pointers[0]); @@ -112,13 +112,12 @@ namespace Aaru.Filesystems contents = currentDirectory?.Keys.ToList(); - return Errno.NoError; + return ErrorNumber.NoError; } Dictionary DecodeDirectory(int firstBlock) { - Dictionary entries = - new Dictionary(); + Dictionary entries = new(); int nextBlock = firstBlock; diff --git a/Aaru.Filesystems/Opera/File.cs b/Aaru.Filesystems/Opera/File.cs index 930ff7a5e..6a92ff73d 100644 --- a/Aaru.Filesystems/Opera/File.cs +++ b/Aaru.Filesystems/Opera/File.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; namespace Aaru.Filesystems @@ -41,74 +42,74 @@ namespace Aaru.Filesystems public sealed partial class OperaFS { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entry); + ErrorNumber err = GetFileEntry(path, out DirectoryEntryWithPointers entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if((entry.Entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; deviceBlock = entry.Pointers[0] + fileBlock; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = Stat(path, out FileEntryInfo stat); + ErrorNumber err = Stat(path, out FileEntryInfo stat); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; attributes = stat.Attributes; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { buf = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entry); + ErrorNumber err = GetFileEntry(path, out DirectoryEntryWithPointers entry); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; if((entry.Entry.flags & FLAGS_MASK) == (uint)FileFlags.Directory && !_debug) - return Errno.IsDirectory; + return ErrorNumber.IsDirectory; if(entry.Pointers.Length < 1) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(entry.Entry.byte_count == 0) { buf = Array.Empty(); - return Errno.NoError; + return ErrorNumber.NoError; } if(offset >= entry.Entry.byte_count) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(size + offset >= entry.Entry.byte_count) size = entry.Entry.byte_count - offset; @@ -135,20 +136,20 @@ namespace Aaru.Filesystems buf = new byte[size]; Array.Copy(buffer, offsetInBlock, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; - Errno err = GetFileEntry(path, out DirectoryEntryWithPointers entryWithPointers); + ErrorNumber err = GetFileEntry(path, out DirectoryEntryWithPointers entryWithPointers); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; DirectoryEntry entry = entryWithPointers.Entry; @@ -171,10 +172,10 @@ namespace Aaru.Filesystems if(flags == FileFlags.Special) stat.Attributes |= FileAttributes.Device; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno GetFileEntry(string path, out DirectoryEntryWithPointers entry) + ErrorNumber GetFileEntry(string path, out DirectoryEntryWithPointers entry) { entry = null; @@ -188,15 +189,15 @@ namespace Aaru.Filesystems }, StringSplitOptions.RemoveEmptyEntries); if(pieces.Length == 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; string parentPath = string.Join("/", pieces, 0, pieces.Length - 1); if(!_directoryCache.TryGetValue(parentPath, out _)) { - Errno err = ReadDir(parentPath, out _); + ErrorNumber err = ReadDir(parentPath, out _); - if(err != Errno.NoError) + if(err != ErrorNumber.NoError) return err; } @@ -205,17 +206,17 @@ namespace Aaru.Filesystems if(pieces.Length == 1) parent = _rootDirectoryCache; else if(!_directoryCache.TryGetValue(parentPath, out parent)) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; KeyValuePair dirent = parent.FirstOrDefault(t => t.Key.ToLower(CultureInfo.CurrentUICulture) == pieces[^1]); if(string.IsNullOrEmpty(dirent.Key)) - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; entry = dirent.Value; - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/Opera/Opera.cs b/Aaru.Filesystems/Opera/Opera.cs index 23177d550..de019087c 100644 --- a/Aaru.Filesystems/Opera/Opera.cs +++ b/Aaru.Filesystems/Opera/Opera.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Schemas; @@ -63,22 +64,22 @@ namespace Aaru.Filesystems public string Author => "Natalia Portillo"; /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) => Errno.NotSupported; + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) => ErrorNumber.NotSupported; /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// diff --git a/Aaru.Filesystems/Opera/Super.cs b/Aaru.Filesystems/Opera/Super.cs index 4b6b6c70f..b0df1e976 100644 --- a/Aaru.Filesystems/Opera/Super.cs +++ b/Aaru.Filesystems/Opera/Super.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.Text; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -43,8 +44,8 @@ namespace Aaru.Filesystems public sealed partial class OperaFS { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { // TODO: Find correct default encoding Encoding = Encoding.ASCII; @@ -60,10 +61,10 @@ namespace Aaru.Filesystems if(sb.record_type != 1 || sb.record_version != 1) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; if(imagePlugin.Info.SectorSize == 2336 || imagePlugin.Info.SectorSize == 2352 || @@ -102,31 +103,31 @@ namespace Aaru.Filesystems _directoryCache = new Dictionary>(); _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; _mounted = false; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; stat = _statfs.ShallowCopy(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/UCSDPascal/Dir.cs b/Aaru.Filesystems/UCSDPascal/Dir.cs index 0337a2416..f733b3c40 100644 --- a/Aaru.Filesystems/UCSDPascal/Dir.cs +++ b/Aaru.Filesystems/UCSDPascal/Dir.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Aaru.CommonTypes.Structs; +using Aaru.CommonTypes.Enums; using Aaru.Helpers; namespace Aaru.Filesystems.UCSDPascal @@ -42,16 +42,16 @@ namespace Aaru.Filesystems.UCSDPascal public sealed partial class PascalPlugin { /// - public Errno ReadDir(string path, out List contents) + public ErrorNumber ReadDir(string path, out List contents) { contents = null; if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0) - return Errno.NotSupported; + return ErrorNumber.NotSupported; contents = _fileEntries.Select(ent => StringHandlers.PascalToString(ent.Filename, Encoding)).ToList(); @@ -63,7 +63,7 @@ namespace Aaru.Filesystems.UCSDPascal contents.Sort(); - return Errno.NoError; + return ErrorNumber.NoError; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/UCSDPascal/File.cs b/Aaru.Filesystems/UCSDPascal/File.cs index 937a3e799..cb2a21050 100644 --- a/Aaru.Filesystems/UCSDPascal/File.cs +++ b/Aaru.Filesystems/UCSDPascal/File.cs @@ -32,6 +32,7 @@ using System; using System.Linq; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -41,20 +42,20 @@ namespace Aaru.Filesystems.UCSDPascal public sealed partial class PascalPlugin { /// - public Errno MapBlock(string path, long fileBlock, out long deviceBlock) + public ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock) { deviceBlock = 0; - return !_mounted ? Errno.AccessDenied : Errno.NotImplemented; + return !_mounted ? ErrorNumber.AccessDenied : ErrorNumber.NotImplemented; } /// - public Errno GetAttributes(string path, out FileAttributes attributes) + public ErrorNumber GetAttributes(string path, out FileAttributes attributes) { attributes = new FileAttributes(); if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -62,11 +63,11 @@ namespace Aaru.Filesystems.UCSDPascal }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; - Errno error = GetFileEntry(path, out _); + ErrorNumber error = GetFileEntry(path, out _); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; attributes = FileAttributes.File; @@ -75,10 +76,10 @@ namespace Aaru.Filesystems.UCSDPascal } /// - public Errno Read(string path, long offset, long size, ref byte[] buf) + public ErrorNumber Read(string path, long offset, long size, ref byte[] buf) { if(!_mounted) - return Errno.AccessDenied; + return ErrorNumber.AccessDenied; string[] pathElements = path.Split(new[] { @@ -86,7 +87,7 @@ namespace Aaru.Filesystems.UCSDPascal }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; byte[] file; @@ -95,9 +96,9 @@ namespace Aaru.Filesystems.UCSDPascal file = string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ? _catalogBlocks : _bootBlocks; else { - Errno error = GetFileEntry(path, out PascalFileEntry entry); + ErrorNumber error = GetFileEntry(path, out PascalFileEntry entry); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; byte[] tmp = _device.ReadSectors((ulong)entry.FirstBlock * _multiplier, @@ -110,7 +111,7 @@ namespace Aaru.Filesystems.UCSDPascal } if(offset >= file.Length) - return Errno.EINVAL; + return ErrorNumber.EINVAL; if(size + offset >= file.Length) size = file.Length - offset; @@ -119,11 +120,11 @@ namespace Aaru.Filesystems.UCSDPascal Array.Copy(file, offset, buf, 0, size); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Stat(string path, out FileEntryInfo stat) + public ErrorNumber Stat(string path, out FileEntryInfo stat) { stat = null; @@ -133,7 +134,7 @@ namespace Aaru.Filesystems.UCSDPascal }, StringSplitOptions.RemoveEmptyEntries); if(pathElements.Length != 1) - return Errno.NotSupported; + return ErrorNumber.NotSupported; if(_debug) if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || @@ -159,12 +160,12 @@ namespace Aaru.Filesystems.UCSDPascal stat.Length = _bootBlocks.Length; } - return Errno.NoError; + return ErrorNumber.NoError; } - Errno error = GetFileEntry(path, out PascalFileEntry entry); + ErrorNumber error = GetFileEntry(path, out PascalFileEntry entry); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) return error; stat = new FileEntryInfo @@ -178,10 +179,10 @@ namespace Aaru.Filesystems.UCSDPascal Links = 1 }; - return Errno.NoError; + return ErrorNumber.NoError; } - Errno GetFileEntry(string path, out PascalFileEntry entry) + ErrorNumber GetFileEntry(string path, out PascalFileEntry entry) { entry = new PascalFileEntry(); @@ -194,10 +195,10 @@ namespace Aaru.Filesystems.UCSDPascal { entry = ent; - return Errno.NoError; + return ErrorNumber.NoError; } - return Errno.NoSuchFile; + return ErrorNumber.NoSuchFile; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/UCSDPascal/Super.cs b/Aaru.Filesystems/UCSDPascal/Super.cs index 8f92795a9..b519106fc 100644 --- a/Aaru.Filesystems/UCSDPascal/Super.cs +++ b/Aaru.Filesystems/UCSDPascal/Super.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -46,8 +47,8 @@ namespace Aaru.Filesystems.UCSDPascal public sealed partial class PascalPlugin { /// - public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, - Dictionary options, string @namespace) + public ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) { _device = imagePlugin; Encoding = encoding ?? new Apple2(); @@ -58,7 +59,7 @@ namespace Aaru.Filesystems.UCSDPascal bool.TryParse(debugString, out _debug); if(_device.Info.Sectors < 3) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; _multiplier = (uint)(imagePlugin.Info.SectorSize == 256 ? 2 : 1); @@ -90,7 +91,7 @@ namespace Aaru.Filesystems.UCSDPascal _mountedVolEntry.Blocks < 0 || (ulong)_mountedVolEntry.Blocks != _device.Info.Sectors / _multiplier || _mountedVolEntry.Files < 0) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; _catalogBlocks = _device.ReadSectors(_multiplier * 2, (uint)(_mountedVolEntry.LastBlock - _mountedVolEntry.FirstBlock - 2) * @@ -136,20 +137,20 @@ namespace Aaru.Filesystems.UCSDPascal _mounted = true; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Unmount() + public ErrorNumber Unmount() { _mounted = false; _fileEntries = null; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno StatFs(out FileSystemInfo stat) + public ErrorNumber StatFs(out FileSystemInfo stat) { stat = new FileSystemInfo { @@ -167,7 +168,7 @@ namespace Aaru.Filesystems.UCSDPascal foreach(PascalFileEntry entry in _fileEntries) stat.FreeBlocks -= (ulong)(entry.LastBlock - entry.FirstBlock); - return Errno.NotImplemented; + return ErrorNumber.NotImplemented; } } } \ No newline at end of file diff --git a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs index 043996286..7ed164aec 100644 --- a/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs +++ b/Aaru.Filesystems/UCSDPascal/UCSDPascal.cs @@ -33,8 +33,8 @@ using System; using System.Collections.Generic; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Schemas; namespace Aaru.Filesystems.UCSDPascal @@ -66,22 +66,22 @@ namespace Aaru.Filesystems.UCSDPascal public string Author => "Natalia Portillo"; /// - public Errno ListXAttr(string path, out List xattrs) + public ErrorNumber ListXAttr(string path, out List xattrs) { xattrs = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// - public Errno GetXattr(string path, string xattr, ref byte[] buf) => Errno.NotSupported; + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) => ErrorNumber.NotSupported; /// - public Errno ReadLink(string path, out string dest) + public ErrorNumber ReadLink(string path, out string dest) { dest = null; - return Errno.NotSupported; + return ErrorNumber.NotSupported; } /// diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index b618319a0..3c0fc7a4e 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -35,8 +35,8 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; @@ -321,14 +321,14 @@ namespace Aaru.Filters // Now way to have two files in a single byte array /// - public Errno Open(byte[] buffer) => Errno.NotSupported; + public ErrorNumber Open(byte[] buffer) => ErrorNumber.NotSupported; // Now way to have two files in a single stream /// - public Errno Open(Stream stream) => Errno.NotSupported; + public ErrorNumber Open(Stream stream) => ErrorNumber.NotSupported; /// - public Errno Open(string path) + public ErrorNumber Open(string path) { string filename = System.IO.Path.GetFileName(path); string filenameNoExt = System.IO.Path.GetFileNameWithoutExtension(path); @@ -338,7 +338,7 @@ namespace Aaru.Filters if(filename is null || filenameNoExt is null) - return Errno.InvalidArgument; + return ErrorNumber.InvalidArgument; // Prepend data fork name with "R." string proDosAppleDouble = System.IO.Path.Combine(parentFolder, "R." + filename); @@ -510,7 +510,7 @@ namespace Aaru.Filters // TODO: More appropriate error if(_headerPath is null) - return Errno.NotSupported; + return ErrorNumber.NotSupported; var fs = new FileStream(_headerPath, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); @@ -604,7 +604,7 @@ namespace Aaru.Filters fs.Close(); BasePath = path; - return Errno.NoError; + return ErrorNumber.NoError; } enum EntryId : uint diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index 5e51c185c..aa92850e5 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -35,8 +35,8 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Marshal = Aaru.Helpers.Marshal; @@ -217,7 +217,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); @@ -301,11 +301,11 @@ namespace Aaru.Filters _isBytes = true; _bytes = buffer; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { stream.Seek(0, SeekOrigin.Begin); @@ -388,11 +388,11 @@ namespace Aaru.Filters _isStream = true; _stream = stream; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); @@ -476,7 +476,7 @@ namespace Aaru.Filters _isPath = true; BasePath = path; - return Errno.NoError; + return ErrorNumber.NoError; } enum AppleSingleEntryID : uint diff --git a/Aaru.Filters/BZip2.cs b/Aaru.Filters/BZip2.cs index eab29826d..a7ae080e5 100644 --- a/Aaru.Filters/BZip2.cs +++ b/Aaru.Filters/BZip2.cs @@ -32,6 +32,7 @@ using System; using System.IO; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Ionic.BZip2; @@ -150,7 +151,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { _dataStream = new MemoryStream(buffer); BasePath = null; @@ -159,11 +160,11 @@ namespace Aaru.Filters _innerStream = new ForcedSeekStream(_dataStream, false); DataForkLength = _innerStream.Length; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { _dataStream = stream; BasePath = null; @@ -172,11 +173,11 @@ namespace Aaru.Filters _innerStream = new ForcedSeekStream(_dataStream, false); DataForkLength = _innerStream.Length; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); BasePath = System.IO.Path.GetFullPath(path); @@ -187,7 +188,7 @@ namespace Aaru.Filters _innerStream = new ForcedSeekStream(_dataStream, false); DataForkLength = _innerStream.Length; - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Filters/GZip.cs b/Aaru.Filters/GZip.cs index 445d2ae9c..b12d93df9 100644 --- a/Aaru.Filters/GZip.cs +++ b/Aaru.Filters/GZip.cs @@ -33,8 +33,8 @@ using System; using System.IO; using System.IO.Compression; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; namespace Aaru.Filters @@ -109,7 +109,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { byte[] mtimeB = new byte[4]; byte[] isizeB = new byte[4]; @@ -132,11 +132,11 @@ namespace Aaru.Filters _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { byte[] mtimeB = new byte[4]; byte[] isizeB = new byte[4]; @@ -159,11 +159,11 @@ namespace Aaru.Filters _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { byte[] mtimeB = new byte[4]; byte[] isizeB = new byte[4]; @@ -186,7 +186,7 @@ namespace Aaru.Filters LastWriteTime = DateHandlers.UnixUnsignedToDateTime(mtime); _zStream = new ForcedSeekStream(_decompressedSize, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Filters/LZip.cs b/Aaru.Filters/LZip.cs index 5fcc7a6c7..4c72f5c01 100644 --- a/Aaru.Filters/LZip.cs +++ b/Aaru.Filters/LZip.cs @@ -32,8 +32,8 @@ using System; using System.IO; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using SharpCompress.Compressors; using SharpCompress.Compressors.LZMA; @@ -111,7 +111,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { _dataStream = new MemoryStream(buffer); BasePath = null; @@ -121,11 +121,11 @@ namespace Aaru.Filters _innerStream = new ForcedSeekStream(DataForkLength, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { _dataStream = stream; BasePath = null; @@ -138,11 +138,11 @@ namespace Aaru.Filters _dataStream.Seek(0, SeekOrigin.Begin); _innerStream = new ForcedSeekStream(DataForkLength, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); BasePath = System.IO.Path.GetFullPath(path); @@ -157,7 +157,7 @@ namespace Aaru.Filters _dataStream.Seek(0, SeekOrigin.Begin); _innerStream = new ForcedSeekStream(DataForkLength, _dataStream, CompressionMode.Decompress); - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Filters/MacBinary.cs b/Aaru.Filters/MacBinary.cs index bf4f774ff..f3d2fac8f 100644 --- a/Aaru.Filters/MacBinary.cs +++ b/Aaru.Filters/MacBinary.cs @@ -34,6 +34,7 @@ using System; using System.IO; using System.Runtime.InteropServices; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Helpers; @@ -198,7 +199,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { var ms = new MemoryStream(buffer); ms.Seek(0, SeekOrigin.Begin); @@ -229,11 +230,11 @@ namespace Aaru.Filters _isBytes = true; _bytes = buffer; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { stream.Seek(0, SeekOrigin.Begin); @@ -263,11 +264,11 @@ namespace Aaru.Filters _isStream = true; _stream = stream; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { var fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); @@ -298,7 +299,7 @@ namespace Aaru.Filters _isPath = true; BasePath = path; - return Errno.NoError; + return ErrorNumber.NoError; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filters/PCExchange.cs b/Aaru.Filters/PCExchange.cs index 3a22d9d2e..e9748f120 100644 --- a/Aaru.Filters/PCExchange.cs +++ b/Aaru.Filters/PCExchange.cs @@ -37,8 +37,8 @@ using System.Globalization; using System.IO; using System.Runtime.InteropServices; using System.Text; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Helpers; using Marshal = System.Runtime.InteropServices.Marshal; @@ -171,13 +171,13 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) => Errno.NotSupported; + public ErrorNumber Open(byte[] buffer) => ErrorNumber.NotSupported; /// - public Errno Open(Stream stream) => Errno.NotSupported; + public ErrorNumber Open(Stream stream) => ErrorNumber.NotSupported; /// - public Errno Open(string path) + public ErrorNumber Open(string path) { string parentFolder = System.IO.Path.GetDirectoryName(path); string baseFilename = System.IO.Path.GetFileName(path); @@ -240,7 +240,7 @@ namespace Aaru.Filters finderDatStream.Close(); - return Errno.NoError; + return ErrorNumber.NoError; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs index a7ae23b9d..7e9603196 100644 --- a/Aaru.Filters/XZ.cs +++ b/Aaru.Filters/XZ.cs @@ -32,8 +32,8 @@ using System; using System.IO; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using SharpCompress.Compressors.Xz; namespace Aaru.Filters @@ -123,7 +123,7 @@ namespace Aaru.Filters } /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { _dataStream = new MemoryStream(buffer); BasePath = null; @@ -132,11 +132,11 @@ namespace Aaru.Filters GuessSize(); _innerStream = new ForcedSeekStream(DataForkLength, _dataStream); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { _dataStream = stream; BasePath = null; @@ -145,11 +145,11 @@ namespace Aaru.Filters GuessSize(); _innerStream = new ForcedSeekStream(DataForkLength, _dataStream); - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); BasePath = System.IO.Path.GetFullPath(path); @@ -160,7 +160,7 @@ namespace Aaru.Filters GuessSize(); _innerStream = new ForcedSeekStream(DataForkLength, _dataStream); - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Filters/ZZZNoFilter.cs b/Aaru.Filters/ZZZNoFilter.cs index 38a2ee8c5..6a1386115 100644 --- a/Aaru.Filters/ZZZNoFilter.cs +++ b/Aaru.Filters/ZZZNoFilter.cs @@ -32,8 +32,8 @@ using System; using System.IO; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; namespace Aaru.Filters { @@ -83,29 +83,29 @@ namespace Aaru.Filters public bool Identify(string path) => File.Exists(path); /// - public Errno Open(byte[] buffer) + public ErrorNumber Open(byte[] buffer) { _dataStream = new MemoryStream(buffer); BasePath = null; CreationTime = DateTime.UtcNow; LastWriteTime = CreationTime; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(Stream stream) + public ErrorNumber Open(Stream stream) { _dataStream = stream; BasePath = null; CreationTime = DateTime.UtcNow; LastWriteTime = CreationTime; - return Errno.NoError; + return ErrorNumber.NoError; } /// - public Errno Open(string path) + public ErrorNumber Open(string path) { _dataStream = new FileStream(path, FileMode.Open, FileAccess.Read); BasePath = System.IO.Path.GetFullPath(path); @@ -113,7 +113,7 @@ namespace Aaru.Filters CreationTime = fi.CreationTimeUtc; LastWriteTime = fi.LastWriteTimeUtc; - return Errno.NoError; + return ErrorNumber.NoError; } /// diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index f7e2d3204..b37519495 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -36,6 +36,7 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Reactive; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Structs; using Aaru.Console; @@ -63,9 +64,9 @@ namespace Aaru.Gui.ViewModels.Panels _model = model; _view = view; - Errno errno = model.Plugin.ReadDir(model.Path, out List dirents); + ErrorNumber errno = model.Plugin.ReadDir(model.Path, out List dirents); - if(errno != Errno.NoError) + if(errno != ErrorNumber.NoError) { MessageBoxManager. GetMessageBoxStandardWindow("Error", @@ -79,7 +80,7 @@ namespace Aaru.Gui.ViewModels.Panels { errno = model.Plugin.Stat(model.Path + "/" + dirent, out FileEntryInfo stat); - if(errno != Errno.NoError) + if(errno != ErrorNumber.NoError) { AaruConsole. ErrorWriteLine($"Error {errno} trying to get information about filesystem entry named {dirent}"); @@ -242,7 +243,7 @@ namespace Aaru.Gui.ViewModels.Panels chars[2] = '_'; } - string corrected = new string(chars); + string corrected = new(chars); mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Unsupported filename", $"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?", @@ -290,9 +291,10 @@ namespace Aaru.Gui.ViewModels.Panels { byte[] outBuf = Array.Empty(); - Errno error = _model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf); + ErrorNumber error = + _model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Error reading file", $"Error {error} reading file.\nDo you want to continue?", diff --git a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index c661ccb1f..f38e50791 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -41,7 +41,6 @@ using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interop; -using Aaru.CommonTypes.Structs; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Console; using Aaru.Core; @@ -624,11 +623,11 @@ namespace Aaru.Gui.ViewModels.Windows if(fsPlugin != null) { - Errno error = + ErrorNumber error = fsPlugin.Mount(imageFormat, partition, null, new Dictionary(), null); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) fsPlugin = null; } @@ -693,10 +692,10 @@ namespace Aaru.Gui.ViewModels.Windows if(fsPlugin != null) { - Errno error = fsPlugin.Mount(imageFormat, wholePart, null, - new Dictionary(), null); + ErrorNumber error = fsPlugin.Mount(imageFormat, wholePart, null, + new Dictionary(), null); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) fsPlugin = null; } diff --git a/Aaru.Images/KryoFlux/Read.cs b/Aaru.Images/KryoFlux/Read.cs index c4c6e261e..c1decf1a7 100644 --- a/Aaru.Images/KryoFlux/Read.cs +++ b/Aaru.Images/KryoFlux/Read.cs @@ -37,7 +37,6 @@ using System.IO; using System.Linq; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Console; using Aaru.Filters; using Aaru.Helpers; @@ -128,7 +127,7 @@ namespace Aaru.DiscImages var trackFilter = new ZZZNoFilter(); - if(trackFilter.Open(trackfile) != Errno.NoError) + if(trackFilter.Open(trackfile) != ErrorNumber.NoError) throw new IOException("Could not open KryoFlux track file."); _imageInfo.CreationTime = DateTime.MaxValue; diff --git a/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs b/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs index cb23c1a80..e230a92f7 100644 --- a/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs +++ b/Aaru.Tests/Filesystems/ReadOnlyFilesystemTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Text; using Aaru.Checksums; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Core; @@ -107,9 +108,9 @@ namespace Aaru.Tests.Filesystems test.Encoding ??= Encoding.ASCII; - Errno ret = fs.Mount(image, partition, test.Encoding, null, test.Namespace); + ErrorNumber ret = fs.Mount(image, partition, test.Encoding, null, test.Namespace); - Assert.AreEqual(Errno.NoError, ret, $"Unmountable: {testFile}"); + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unmountable: {testFile}"); var serializer = new JsonSerializer { @@ -259,7 +260,7 @@ namespace Aaru.Tests.Filesystems } else if(stat.Attributes.HasFlag(FileAttributes.Symlink)) { - if(fs.ReadLink(childPath, out string link) == Errno.NoError) + if(fs.ReadLink(childPath, out string link) == ErrorNumber.NoError) data.LinkTarget = link; } else @@ -284,9 +285,9 @@ namespace Aaru.Tests.Filesystems internal static void TestDirectory(IReadOnlyFilesystem fs, string path, Dictionary children, string testFile, bool testXattr) { - Errno ret = fs.ReadDir(path, out List contents); + ErrorNumber ret = fs.ReadDir(path, out List contents); - Assert.AreEqual(Errno.NoError, ret, + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unexpected error {ret} when reading directory \"{path}\" of {testFile}."); if(children.Count == 0 && @@ -303,7 +304,7 @@ namespace Aaru.Tests.Filesystems string childPath = $"{path}/{child.Key}"; ret = fs.Stat(childPath, out FileEntryInfo stat); - if(ret == Errno.NoSuchFile || + if(ret == ErrorNumber.NoSuchFile || !contents.Contains(child.Key)) { expectedNotFound.Add(child.Key); @@ -313,7 +314,7 @@ namespace Aaru.Tests.Filesystems contents.Remove(child.Key); - Assert.AreEqual(Errno.NoError, ret, + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unexpected error {ret} retrieving stats for \"{childPath}\" in {testFile}"); stat.Should().BeEquivalentTo(child.Value.Info, $"Wrong info for \"{childPath}\" in {testFile}"); @@ -324,7 +325,7 @@ namespace Aaru.Tests.Filesystems { ret = fs.Read(childPath, 0, 1, ref buffer); - Assert.AreEqual(Errno.IsDirectory, ret, + Assert.AreEqual(ErrorNumber.IsDirectory, ret, $"Got wrong data for directory \"{childPath}\" in {testFile}"); Assert.IsNotNull(child.Value.Children, @@ -337,7 +338,7 @@ namespace Aaru.Tests.Filesystems { ret = fs.ReadLink(childPath, out string link); - Assert.AreEqual(Errno.NoError, ret, + Assert.AreEqual(ErrorNumber.NoError, ret, $"Got wrong data for symbolic link \"{childPath}\" in {testFile}"); Assert.AreEqual(child.Value.LinkTarget, link, @@ -353,7 +354,7 @@ namespace Aaru.Tests.Filesystems ret = fs.ListXAttr(childPath, out List xattrs); - if(ret == Errno.NotSupported) + if(ret == ErrorNumber.NotSupported) { Assert.IsNull(child.Value.XattrsWithMd5, $"Defined extended attributes for \"{childPath}\" in {testFile} are not supported by filesystem."); @@ -361,7 +362,7 @@ namespace Aaru.Tests.Filesystems continue; } - Assert.AreEqual(Errno.NoError, ret, + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unexpected error {ret} when listing extended attributes for \"{childPath}\" in {testFile}"); if(xattrs.Count > 0) @@ -382,10 +383,10 @@ namespace Aaru.Tests.Filesystems static void TestFile(IReadOnlyFilesystem fs, string path, string md5, long length, string testFile) { - byte[] buffer = new byte[length]; - Errno ret = fs.Read(path, 0, length, ref buffer); + byte[] buffer = new byte[length]; + ErrorNumber ret = fs.Read(path, 0, length, ref buffer); - Assert.AreEqual(Errno.NoError, ret, $"Unexpected error {ret} when reading \"{path}\" in {testFile}"); + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unexpected error {ret} when reading \"{path}\" in {testFile}"); string data = Md5Context.Data(buffer, out _); @@ -405,10 +406,10 @@ namespace Aaru.Tests.Filesystems foreach(KeyValuePair xattr in xattrs) { - byte[] buffer = Array.Empty(); - Errno ret = fs.GetXattr(path, xattr.Key, ref buffer); + byte[] buffer = Array.Empty(); + ErrorNumber ret = fs.GetXattr(path, xattr.Key, ref buffer); - if(ret == Errno.NoSuchExtendedAttribute || + if(ret == ErrorNumber.NoSuchExtendedAttribute || !contents.Contains(xattr.Key)) { expectedNotFound.Add(xattr.Key); @@ -418,7 +419,7 @@ namespace Aaru.Tests.Filesystems contents.Remove(xattr.Key); - Assert.AreEqual(Errno.NoError, ret, + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unexpected error {ret} retrieving extended attributes for \"{path}\" in {testFile}"); string data = Md5Context.Data(buffer, out _); diff --git a/Aaru.Tests/Filters/AppleDoubleDave.cs b/Aaru.Tests/Filters/AppleDoubleDave.cs index e36846725..403dd7c7b 100644 --- a/Aaru.Tests/Filters/AppleDoubleDave.cs +++ b/Aaru.Tests/Filters/AppleDoubleDave.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -104,7 +105,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleDos.cs b/Aaru.Tests/Filters/AppleDoubleDos.cs index a3256cc6d..d3a6cd92b 100644 --- a/Aaru.Tests/Filters/AppleDoubleDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleDos.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -102,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs index 83cad70ab..af5f2f2f5 100644 --- a/Aaru.Tests/Filters/AppleDoubleNetatalk.cs +++ b/Aaru.Tests/Filters/AppleDoubleNetatalk.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -104,7 +105,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleOsX.cs b/Aaru.Tests/Filters/AppleDoubleOsX.cs index 7c06c3f0c..c76370cbb 100644 --- a/Aaru.Tests/Filters/AppleDoubleOsX.cs +++ b/Aaru.Tests/Filters/AppleDoubleOsX.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -102,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleProDos.cs b/Aaru.Tests/Filters/AppleDoubleProDos.cs index c49fac505..e31f98d18 100644 --- a/Aaru.Tests/Filters/AppleDoubleProDos.cs +++ b/Aaru.Tests/Filters/AppleDoubleProDos.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -102,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleUnAr.cs b/Aaru.Tests/Filters/AppleDoubleUnAr.cs index ba284b3d1..3fffbff9b 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnAr.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnAr.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -102,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleDoubleUnix.cs b/Aaru.Tests/Filters/AppleDoubleUnix.cs index 070c43e80..c73222896 100644 --- a/Aaru.Tests/Filters/AppleDoubleUnix.cs +++ b/Aaru.Tests/Filters/AppleDoubleUnix.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -102,7 +103,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new AppleDouble(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/AppleSingle.cs b/Aaru.Tests/Filters/AppleSingle.cs index 5705fb562..ef99aaccf 100644 --- a/Aaru.Tests/Filters/AppleSingle.cs +++ b/Aaru.Tests/Filters/AppleSingle.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using NUnit.Framework; @@ -93,7 +94,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.AppleSingle(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/BZip2.cs b/Aaru.Tests/Filters/BZip2.cs index bce5693c4..f994bfc67 100644 --- a/Aaru.Tests/Filters/BZip2.cs +++ b/Aaru.Tests/Filters/BZip2.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using NUnit.Framework; @@ -82,7 +83,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.BZip2(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(0, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/GZip.cs b/Aaru.Tests/Filters/GZip.cs index 878f2ea3c..bd0a552de 100644 --- a/Aaru.Tests/Filters/GZip.cs +++ b/Aaru.Tests/Filters/GZip.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using NUnit.Framework; @@ -82,7 +83,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.GZip(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(0, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/LZip.cs b/Aaru.Tests/Filters/LZip.cs index 6564496ab..01df17578 100644 --- a/Aaru.Tests/Filters/LZip.cs +++ b/Aaru.Tests/Filters/LZip.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using NUnit.Framework; @@ -82,7 +83,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.LZip(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(0, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/MacBinary1.cs b/Aaru.Tests/Filters/MacBinary1.cs index b264818d5..9b9dcd157 100644 --- a/Aaru.Tests/Filters/MacBinary1.cs +++ b/Aaru.Tests/Filters/MacBinary1.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -94,7 +95,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/MacBinary2.cs b/Aaru.Tests/Filters/MacBinary2.cs index 477a14da1..43a830ee0 100644 --- a/Aaru.Tests/Filters/MacBinary2.cs +++ b/Aaru.Tests/Filters/MacBinary2.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -94,7 +95,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/MacBinary3.cs b/Aaru.Tests/Filters/MacBinary3.cs index 10208ac50..59347b23f 100644 --- a/Aaru.Tests/Filters/MacBinary3.cs +++ b/Aaru.Tests/Filters/MacBinary3.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -94,7 +95,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new MacBinary(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(286, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/PCExchange.cs b/Aaru.Tests/Filters/PCExchange.cs index 892e59cf5..e72c5a3dd 100644 --- a/Aaru.Tests/Filters/PCExchange.cs +++ b/Aaru.Tests/Filters/PCExchange.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using NUnit.Framework; @@ -95,7 +96,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new Aaru.Filters.PcExchange(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(737280, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(546, filter.ResourceForkLength); diff --git a/Aaru.Tests/Filters/XZ.cs b/Aaru.Tests/Filters/XZ.cs index cc1e640e8..33ad510f5 100644 --- a/Aaru.Tests/Filters/XZ.cs +++ b/Aaru.Tests/Filters/XZ.cs @@ -28,6 +28,7 @@ using System.IO; using Aaru.Checksums; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Filters; @@ -83,7 +84,7 @@ namespace Aaru.Tests.Filters public void Test() { IFilter filter = new XZ(); - Assert.AreEqual(Errno.NoError, filter.Open(_location)); + Assert.AreEqual(ErrorNumber.NoError, filter.Open(_location)); Assert.AreEqual(1048576, filter.DataForkLength); Assert.AreNotEqual(null, filter.GetDataForkStream()); Assert.AreEqual(0, filter.ResourceForkLength); diff --git a/Aaru.Tests/Images/BlockMediaImageTest.cs b/Aaru.Tests/Images/BlockMediaImageTest.cs index 62e1a34c7..d221182d8 100644 --- a/Aaru.Tests/Images/BlockMediaImageTest.cs +++ b/Aaru.Tests/Images/BlockMediaImageTest.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.IO; using Aaru.Checksums; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; -using Aaru.CommonTypes.Structs; using Aaru.Core; using Aaru.Tests.Filesystems; using FluentAssertions.Execution; @@ -241,10 +241,10 @@ namespace Aaru.Tests.Images Errno error = fs.Mount(image, partitions[i], null, null, null); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Could not mount {pluginName} in partition {i}."); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) continue; expectedData[j] = new VolumeData @@ -282,12 +282,12 @@ namespace Aaru.Tests.Images Assert.IsNotNull(fs, $"Could not instantiate filesystem {pluginName} in {testFile}"); - Errno error = fs.Mount(image, partitions[i], null, null, null); + ErrorNumber error = fs.Mount(image, partitions[i], null, null, null); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Could not mount {pluginName} in partition {i} in {testFile}."); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) continue; VolumeData volumeData = expectedData[j]; diff --git a/Aaru.Tests/Images/OpticalMediaImageTest.cs b/Aaru.Tests/Images/OpticalMediaImageTest.cs index 817572844..7eba9b33f 100644 --- a/Aaru.Tests/Images/OpticalMediaImageTest.cs +++ b/Aaru.Tests/Images/OpticalMediaImageTest.cs @@ -227,10 +227,10 @@ namespace Aaru.Tests.Images track.FileSystems[i].Encoding ??= Encoding.ASCII; - Errno ret = rofs.Mount(image, partition, track.FileSystems[i].Encoding, null, - track.FileSystems[i].Namespace); + ErrorNumber ret = rofs.Mount(image, partition, track.FileSystems[i].Encoding, null, + track.FileSystems[i].Namespace); - Assert.AreEqual(Errno.NoError, ret, $"Unmountable: {testFile}"); + Assert.AreEqual(ErrorNumber.NoError, ret, $"Unmountable: {testFile}"); var serializer = new JsonSerializer { diff --git a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs index 752bdb9e0..1536df348 100644 --- a/Aaru.Tests/Issues/FsExtractHashIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractHashIssueTest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Text; using Aaru.Checksums; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Core; @@ -125,9 +126,9 @@ namespace Aaru.Tests.Issues filesystemFound = true; - Errno error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); + ErrorNumber error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); - Assert.AreEqual(Errno.NoError, error, $"Could not mount {pluginName} in partition {i}."); + Assert.AreEqual(ErrorNumber.NoError, error, $"Could not mount {pluginName} in partition {i}."); Assert.AreEqual(expectedData.Partitions[i].Volumes[j].VolumeName, fs.XmlFsType.VolumeName, $"Excepted volume name \"{expectedData.Partitions[i].Volumes[j].VolumeName}\" for filesystem {j} in partition {i} but found \"{fs.XmlFsType.VolumeName}\""); @@ -149,16 +150,16 @@ namespace Aaru.Tests.Issues if(path.StartsWith('/')) path = path[1..]; - Errno error = fs.ReadDir(path, out List directory); + ErrorNumber error = fs.ReadDir(path, out List directory); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, string.Format("Error {0} reading root directory {0}", error.ToString())); foreach(string entry in directory) { error = fs.Stat(path + "/" + entry, out FileEntryInfo stat); - Assert.AreEqual(Errno.NoError, error, $"Error getting stat for entry {entry}"); + Assert.AreEqual(ErrorNumber.NoError, error, $"Error getting stat for entry {entry}"); if(stat.Attributes.HasFlag(FileAttributes.Directory)) { @@ -200,12 +201,12 @@ namespace Aaru.Tests.Issues { error = fs.ListXAttr(path + "/" + entry, out List xattrs); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} getting extended attributes for entry {path + "/" + entry}"); Dictionary expectedXattrs = fileData.XattrsWithMd5; - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) foreach(string xattr in xattrs) { Assert.IsTrue(expectedXattrs.TryGetValue(xattr, out string expectedXattrMd5), @@ -216,7 +217,7 @@ namespace Aaru.Tests.Issues byte[] xattrBuf = Array.Empty(); error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} reading extended attributes for entry {path + "/" + entry}"); string xattrMd5 = Md5Context.Data(xattrBuf, out _); @@ -234,7 +235,7 @@ namespace Aaru.Tests.Issues error = fs.Read(path + "/" + entry, 0, stat.Length, ref outBuf); - Assert.AreEqual(Errno.NoError, error, $"Error {error} reading file {path + "/" + entry}"); + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} reading file {path + "/" + entry}"); string calculatedMd5 = Md5Context.Data(outBuf, out _); diff --git a/Aaru.Tests/Issues/FsExtractIssueTest.cs b/Aaru.Tests/Issues/FsExtractIssueTest.cs index 6cb78e61f..291e534b6 100644 --- a/Aaru.Tests/Issues/FsExtractIssueTest.cs +++ b/Aaru.Tests/Issues/FsExtractIssueTest.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; using Aaru.CommonTypes; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Core; @@ -74,7 +75,7 @@ namespace Aaru.Tests.Issues continue; IReadOnlyFilesystem plugin; - Errno error; + ErrorNumber error; if(idPlugins.Count > 1) { @@ -93,7 +94,8 @@ namespace Aaru.Tests.Issues error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); - Assert.AreEqual(Errno.NoError, error, $"Could not mount {pluginName} in partition {i}."); + Assert.AreEqual(ErrorNumber.NoError, error, + $"Could not mount {pluginName} in partition {i}."); ExtractFilesInDir("/", fs, Xattrs); } @@ -114,7 +116,7 @@ namespace Aaru.Tests.Issues error = fs.Mount(imageFormat, partitions[i], encodingClass, options, Namespace); - Assert.AreEqual(Errno.NoError, error, $"Could not mount {plugin.Name} in partition {i}."); + Assert.AreEqual(ErrorNumber.NoError, error, $"Could not mount {plugin.Name} in partition {i}."); ExtractFilesInDir("/", fs, Xattrs); } @@ -128,16 +130,16 @@ namespace Aaru.Tests.Issues if(path.StartsWith('/')) path = path[1..]; - Errno error = fs.ReadDir(path, out List directory); + ErrorNumber error = fs.ReadDir(path, out List directory); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, string.Format("Error {0} reading root directory {0}", error.ToString())); foreach(string entry in directory) { error = fs.Stat(path + "/" + entry, out FileEntryInfo stat); - Assert.AreEqual(Errno.NoError, error, $"Error getting stat for entry {entry}"); + Assert.AreEqual(ErrorNumber.NoError, error, $"Error getting stat for entry {entry}"); if(stat.Attributes.HasFlag(FileAttributes.Directory)) { @@ -150,16 +152,16 @@ namespace Aaru.Tests.Issues { error = fs.ListXAttr(path + "/" + entry, out List xattrs); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} getting extended attributes for entry {path + "/" + entry}"); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) foreach(string xattr in xattrs) { byte[] xattrBuf = Array.Empty(); error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf); - Assert.AreEqual(Errno.NoError, error, + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} reading extended attributes for entry {path + "/" + entry}"); } } @@ -168,7 +170,7 @@ namespace Aaru.Tests.Issues error = fs.Read(path + "/" + entry, 0, stat.Length, ref outBuf); - Assert.AreEqual(Errno.NoError, error, $"Error {error} reading file {path + "/" + entry}"); + Assert.AreEqual(ErrorNumber.NoError, error, $"Error {error} reading file {path + "/" + entry}"); } } } diff --git a/Aaru/Commands/Device/DeviceReport.cs b/Aaru/Commands/Device/DeviceReport.cs index 0a160f6a0..70ff2bec1 100644 --- a/Aaru/Commands/Device/DeviceReport.cs +++ b/Aaru/Commands/Device/DeviceReport.cs @@ -158,7 +158,7 @@ namespace Aaru.Commands.Device AaruConsole.ErrorWriteLine("Not continuing."); - return (int)ErrorNumber.NotEnoughPermissions; + return (int)ErrorNumber.NotPermitted; } var report = new DeviceReportV2 diff --git a/Aaru/Commands/Filesystem/ExtractFiles.cs b/Aaru/Commands/Filesystem/ExtractFiles.cs index f28253451..8c52bc0ff 100644 --- a/Aaru/Commands/Filesystem/ExtractFiles.cs +++ b/Aaru/Commands/Filesystem/ExtractFiles.cs @@ -225,7 +225,7 @@ namespace Aaru.Commands.Filesystem { AaruConsole.ErrorWriteLine("Destination exists, aborting."); - return (int)ErrorNumber.DestinationExists; + return (int)ErrorNumber.FileExists; } Directory.CreateDirectory(outputDir); @@ -316,7 +316,7 @@ namespace Aaru.Commands.Filesystem else { IReadOnlyFilesystem plugin; - Errno error = Errno.InvalidArgument; + ErrorNumber error = ErrorNumber.InvalidArgument; if(idPlugins.Count > 1) { @@ -339,7 +339,7 @@ namespace Aaru.Commands.Filesystem @namespace); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) { string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; @@ -372,7 +372,7 @@ namespace Aaru.Commands.Filesystem error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, @namespace); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) { string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName) ? "NO NAME" : fs.XmlFsType.VolumeName; @@ -404,9 +404,9 @@ namespace Aaru.Commands.Filesystem if(path.StartsWith('/')) path = path.Substring(1); - Errno error = fs.ReadDir(path, out List directory); + ErrorNumber error = fs.ReadDir(path, out List directory); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); @@ -423,7 +423,7 @@ namespace Aaru.Commands.Filesystem error = fs.Stat(path + "/" + entry, out stat); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) { string outputPath; @@ -486,7 +486,7 @@ namespace Aaru.Commands.Filesystem error = fs.ListXAttr(path + "/" + entry, out xattrs); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) foreach(string xattr in xattrs) { byte[] xattrBuf = Array.Empty(); @@ -497,7 +497,7 @@ namespace Aaru.Commands.Filesystem error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf); }); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) continue; outputPath = Path.Combine(outputDir, fs.XmlFsType.Type, volumeName, ".xattrs", path, @@ -595,7 +595,7 @@ namespace Aaru.Commands.Filesystem error = fs.Read(path + "/" + entry, position, bytesToRead, ref outBuf); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) outputFile.Write(outBuf, 0, outBuf.Length); else { diff --git a/Aaru/Commands/Filesystem/Ls.cs b/Aaru/Commands/Filesystem/Ls.cs index 7453ee556..21bb588d4 100644 --- a/Aaru/Commands/Filesystem/Ls.cs +++ b/Aaru/Commands/Filesystem/Ls.cs @@ -287,7 +287,7 @@ namespace Aaru.Commands.Filesystem else { IReadOnlyFilesystem plugin; - Errno error = Errno.InvalidArgument; + ErrorNumber error = ErrorNumber.InvalidArgument; if(idPlugins.Count > 1) { @@ -313,7 +313,7 @@ namespace Aaru.Commands.Filesystem @namespace); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) { ListFilesInDir("/", fs, longFormat); @@ -346,7 +346,7 @@ namespace Aaru.Commands.Filesystem error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, @namespace); }); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) { ListFilesInDir("/", fs, longFormat); @@ -371,7 +371,7 @@ namespace Aaru.Commands.Filesystem static void ListFilesInDir(string path, [NotNull] IReadOnlyFilesystem fs, bool longFormat) { - Errno error = Errno.InvalidArgument; + ErrorNumber error = ErrorNumber.InvalidArgument; List directory = new(); if(path.StartsWith('/')) @@ -385,7 +385,7 @@ namespace Aaru.Commands.Filesystem error = fs.ReadDir(path, out directory); }); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) { AaruConsole.ErrorWriteLine("Error {0} reading root directory {1}", error.ToString(), path); @@ -426,7 +426,7 @@ namespace Aaru.Commands.Filesystem error = fs.ListXAttr(path + "/" + entry.Key, out List xattrs); - if(error != Errno.NoError) + if(error != ErrorNumber.NoError) continue; foreach(string xattr in xattrs) @@ -434,7 +434,7 @@ namespace Aaru.Commands.Filesystem byte[] xattrBuf = Array.Empty(); error = fs.GetXattr(path + "/" + entry.Key, xattr, ref xattrBuf); - if(error == Errno.NoError) + if(error == ErrorNumber.NoError) AaruConsole.WriteLine("\t\t{0}\t{1:##,#}", Markup.Escape(xattr), xattrBuf.Length); } } diff --git a/Aaru/Commands/Image/Convert.cs b/Aaru/Commands/Image/Convert.cs index 1d7746476..b187f0cd6 100644 --- a/Aaru/Commands/Image/Convert.cs +++ b/Aaru/Commands/Image/Convert.cs @@ -417,7 +417,7 @@ namespace Aaru.Commands.Image { AaruConsole.ErrorWriteLine("Could not find metadata sidecar, not continuing..."); - return (int)ErrorNumber.FileNotFound; + return (int)ErrorNumber.NoSuchFile; } xs = new XmlSerializer(typeof(Resume)); @@ -441,7 +441,7 @@ namespace Aaru.Commands.Image { AaruConsole.ErrorWriteLine("Could not find resume file, not continuing..."); - return (int)ErrorNumber.FileNotFound; + return (int)ErrorNumber.NoSuchFile; } var filtersList = new FiltersList(); @@ -464,7 +464,7 @@ namespace Aaru.Commands.Image { AaruConsole.ErrorWriteLine("Output file already exists, not continuing."); - return (int)ErrorNumber.DestinationExists; + return (int)ErrorNumber.FileExists; } PluginBase plugins = GetPluginBase.Instance; @@ -730,7 +730,7 @@ namespace Aaru.Commands.Image foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag => !force || outputFormat.SupportedMediaTags.Contains(mediaTag))) { - ErrorNumber errno = ErrorNumber.NoError; + ErrorNumber ErrorNumber = ErrorNumber.NoError; AnsiConsole.Progress().AutoClear(false).HideCompleted(false). Columns(new TaskDescriptionColumn(), new SpinnerColumn()).Start(ctx => @@ -749,12 +749,12 @@ namespace Aaru.Commands.Image AaruConsole.ErrorWriteLine("Error {0} writing media tag, not continuing...", outputFormat.ErrorMessage); - errno = ErrorNumber.WriteError; + ErrorNumber = ErrorNumber.WriteError; } }); - if(errno != ErrorNumber.NoError) - return (int)errno; + if(ErrorNumber != ErrorNumber.NoError) + return (int)ErrorNumber; } AaruConsole.WriteLine("{0} sectors to convert", inputFormat.Info.Sectors); @@ -837,7 +837,7 @@ namespace Aaru.Commands.Image AaruConsole. ErrorWriteLine("Input image is not returning raw sectors, use force if you want to continue..."); - errno = (ErrorNumber)Errno.InOutError; + errno = ErrorNumber.InOutError; return; } @@ -1196,7 +1196,7 @@ namespace Aaru.Commands.Image outputFormat.ErrorMessage); } - ErrorNumber errno = ErrorNumber.NoError; + ErrorNumber ErrorNumber = ErrorNumber.NoError; AnsiConsole.Progress().AutoClear(true).HideCompleted(true). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). @@ -1258,7 +1258,7 @@ namespace Aaru.Commands.Image ErrorWriteLine("Error {0} writing sector {1}, not continuing...", outputFormat.ErrorMessage, doneSectors); - errno = ErrorNumber.WriteError; + ErrorNumber = ErrorNumber.WriteError; return; } @@ -1335,7 +1335,7 @@ namespace Aaru.Commands.Image ErrorWriteLine("Error {0} writing sector {1}, not continuing...", outputFormat.ErrorMessage, doneSectors); - errno = ErrorNumber.WriteError; + ErrorNumber = ErrorNumber.WriteError; return; } @@ -1379,8 +1379,8 @@ namespace Aaru.Commands.Image partitionTask.StopTask(); }); - if(errno != ErrorNumber.NoError) - return (int)errno; + if(ErrorNumber != ErrorNumber.NoError) + return (int)ErrorNumber; } if(resume != null || diff --git a/Aaru/Commands/Image/CreateSidecar.cs b/Aaru/Commands/Image/CreateSidecar.cs index 750f8675a..c2d47135e 100644 --- a/Aaru/Commands/Image/CreateSidecar.cs +++ b/Aaru/Commands/Image/CreateSidecar.cs @@ -157,7 +157,7 @@ namespace Aaru.Commands.Image { AaruConsole.ErrorWriteLine("You cannot use --tape option when input is a file."); - return (int)ErrorNumber.ExpectedDirectory; + return (int)ErrorNumber.NotDirectory; } var filtersList = new FiltersList(); @@ -317,7 +317,7 @@ namespace Aaru.Commands.Image { AaruConsole.ErrorWriteLine("Cannot create a sidecar from a directory."); - return (int)ErrorNumber.ExpectedFile; + return (int)ErrorNumber.IsDirectory; } string[] contents = Directory.GetFiles(imagePath, "*", SearchOption.TopDirectoryOnly); diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs index 078958b6b..123e78af9 100644 --- a/Aaru/Commands/Media/Dump.cs +++ b/Aaru/Commands/Media/Dump.cs @@ -638,7 +638,7 @@ namespace Aaru.Commands.Media if(isResponse) continue; - return (int)ErrorNumber.FileNotFound; + return (int)ErrorNumber.NoSuchFile; } plugins = GetPluginBase.Instance;