diff --git a/Enums/ErrorNumber.cs b/Enums/ErrorNumber.cs
index 4b6890a..fa0dfeb 100644
--- a/Enums/ErrorNumber.cs
+++ b/Enums/ErrorNumber.cs
@@ -38,9 +38,81 @@
namespace Aaru.CommonTypes.Enums
{
- /// Enumerates error codes. Positive for warnings or informative codes, negative for errors.
+ /// Enumerates error codes. Negative for UNIX error number equivalents, positive for Aaru error numbers.
public enum ErrorNumber
{
+ NotPermitted = -1,
+ /// No such file or directory
+ NoSuchFile = -2, NoSuchProcess = -3, InterruptedSyscall = -4,
+ /// I/O error
+ InOutError = -5, NoSuchDeviceOrAddress = -6, ArgumentListTooLong = -7, ExecutableFormatError = -8,
+ BadFileNumber = -9, NoChildProcess = -10, TryAgain = -11,
+ OutOfMemory = -12,
+ /// Access denied
+ AccessDenied = -13, BadAddress = -14, NotABlockDevice = -15,
+ /// Busy, cannot complete
+ Busy = -16, FileExists = -17, CrossDeviceLink = -18,
+ /// No such device
+ NoSuchDevice = -19,
+ /// Is not a directory (e.g.: trying to ReadDir() a file)
+ NotDirectory = -20,
+ /// Is a directory (e.g.: trying to Read() a dir)
+ IsDirectory = -21,
+ /// Invalid argument
+ InvalidArgument = -22, FileTableOverflow = -23, TooManyOpenFiles = -24, NotTypewriter = -25,
+ TextFileBusy = -26,
+ /// File is too large
+ FileTooLarge = -27, NoSpaceLeft = -28, IllegalSeek = -29, ReadOnly = -30,
+ TooManyLinks = -31, BrokenPipe = -32, OutOfDomain = -33,
+ OutOfRange = -34, DeadlockWouldOccur = -35,
+ /// Name is too long
+ NameTooLong = -36, NoLocksAvailable = -37,
+ /// Not implemented
+ NotImplemented = -38,
+ /// There is no data available
+ NoData = -61,
+ /// Link is severed
+ SeveredLink = -67,
+ /// There is no such attribute
+ NoSuchExtendedAttribute = NoData,
+ /// Not supported
+ NotSupported = -252, EPERM = NotPermitted,
+ /// No such file or directory
+ ENOENT = NoSuchFile, ESRCH = NoSuchProcess, EINTR = InterruptedSyscall,
+ /// I/O error
+ EIO = InOutError, ENXIO = NoSuchDeviceOrAddress, E2BIG = ArgumentListTooLong, ENOEXEC = ExecutableFormatError,
+ EBADF = BadFileNumber, ECHILD = NoChildProcess, EAGAIN = TryAgain,
+ ENOMEM = OutOfMemory,
+ /// Access denied
+ EACCES = AccessDenied, EFAULT = BadAddress, ENOTBLK = NotABlockDevice,
+ /// Busy, cannot complete
+ EBUSY = Busy, EEXIST = FileExists, EXDEV = CrossDeviceLink,
+ /// No such device
+ ENODEV = NoSuchDevice,
+ /// Is not a directory (e.g.: trying to ReadDir() a file)
+ ENOTDIR = NotDirectory,
+ /// Is a directory (e.g.: trying to Read() a dir)
+ EISDIR = IsDirectory,
+ /// Invalid argument
+ EINVAL = InvalidArgument, ENFILE = FileTableOverflow, EMFILE = TooManyOpenFiles, ENOTTY = NotTypewriter,
+ ETXTBSY = TextFileBusy,
+ /// File is too large
+ EFBIG = FileTooLarge, ENOSPC = NoSpaceLeft, ESPIPE = IllegalSeek, EROFS = ReadOnly,
+ EMLINK = TooManyLinks, EPIPE = BrokenPipe, EDOM = OutOfDomain,
+ ERANGE = OutOfRange, EDEADLK = DeadlockWouldOccur,
+ /// Name is too long
+ ENAMETOOLONG = NameTooLong, ENOLCK = NoLocksAvailable,
+ /// Not implemented
+ ENOSYS = NotImplemented,
+ /// Link is severed
+ ENOLINK = SeveredLink,
+ /// Not supported
+ ENOTSUP = NotSupported, DirectoryNotEmpty = -39, TooManySymbolicLinks = -40, ENOTEMPTY = DirectoryNotEmpty,
+ ELOOP = TooManySymbolicLinks,
+ /// There is no such attribute
+ ENOATTR = NoSuchExtendedAttribute,
+ /// There is no data available
+ ENODATA = NoData,
/// No error
NoError = 0,
/// User requested help to be shown
@@ -66,50 +138,38 @@ namespace Aaru.CommonTypes.Enums
/// Image is good and there are bad sectors
CorrectImageBadSectors = 11,
/// Exception has been raised
- UnexpectedException = -1,
+ UnexpectedException = 12,
/// The number of arguments is not as expected
- UnexpectedArgumentCount = -2,
+ UnexpectedArgumentCount = 13,
/// A required argument is not present
- MissingArgument = -3,
- /// A specified argument contains an invalid value
- InvalidArgument = -4,
- /// The specified file cannot be found
- FileNotFound = -5,
+ MissingArgument = 14,
/// The specified file cannot be opened
- CannotOpenFile = -6,
+ CannotOpenFile = 15,
/// The specified encoding cannot be found
- EncodingUnknown = -7,
+ EncodingUnknown = 16,
/// The image format has not been recognized
- UnrecognizedFormat = -8,
+ UnrecognizedFormat = 17,
/// The image format failed to open
- CannotOpenFormat = -9,
+ CannotOpenFormat = 18,
/// The specified metadata sidecar does not have the correct format
- InvalidSidecar = -10,
+ InvalidSidecar = 19,
/// The specified resume map does not have the correct format
- InvalidResume = -11,
- /// The specified destination file/folder already exists
- DestinationExists = -12,
+ InvalidResume = 20,
/// The specified image format cannot be found
- FormatNotFound = -13,
+ FormatNotFound = 21,
/// More than one format found for the specified search criteria
- TooManyFormats = -14,
+ TooManyFormats = 22,
/// The specified format does not support the specified media
- UnsupportedMedia = -15,
+ UnsupportedMedia = 23,
/// Data will be lost writing the specified format
- DataWillBeLost = -16,
+ DataWillBeLost = 24,
/// Cannot create destination format
- CannotCreateFormat = -17,
+ CannotCreateFormat = 25,
/// Error writing data
- WriteError = -18,
- /// Argument expected a directory, but found a file
- ExpectedDirectory = -19,
- /// Argument expected a file, but found a directory
- ExpectedFile = -20,
+ WriteError = 26,
/// Cannot open device
- CannotOpenDevice = -21,
- /// The specified operation requires administrative privileges
- NotEnoughPermissions = -22,
+ CannotOpenDevice = 27,
/// Cannot remove the existing database
- CannotRemoveDatabase = -23
+ CannotRemoveDatabase = -28
}
}
\ No newline at end of file
diff --git a/Filters.cs b/Filters.cs
index 3cff3ce..47c2744 100644
--- a/Filters.cs
+++ b/Filters.cs
@@ -41,8 +41,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
-using Aaru.CommonTypes.Structs;
using Aaru.Console;
namespace Aaru.CommonTypes
@@ -94,7 +94,7 @@ namespace Aaru.CommonTypes
var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
{});
- if(foundFilter?.Open(path) == Errno.NoError)
+ if(foundFilter?.Open(path) == ErrorNumber.NoError)
return foundFilter;
}
else
diff --git a/Interfaces/IFilter.cs b/Interfaces/IFilter.cs
index eb6d863..f75ab10 100644
--- a/Interfaces/IFilter.cs
+++ b/Interfaces/IFilter.cs
@@ -38,7 +38,7 @@
using System;
using System.IO;
-using Aaru.CommonTypes.Structs;
+using Aaru.CommonTypes.Enums;
namespace Aaru.CommonTypes.Interfaces
{
@@ -134,14 +134,14 @@ namespace Aaru.CommonTypes.Interfaces
/// Opens the specified path with this filter instance
/// Path.
- Errno Open(string path);
+ ErrorNumber Open(string path);
/// Opens the specified stream with this filter instance
/// Stream.
- Errno Open(Stream stream);
+ ErrorNumber Open(Stream stream);
/// Opens the specified buffer with this filter instance
/// Buffer.
- Errno Open(byte[] buffer);
+ ErrorNumber Open(byte[] buffer);
}
}
\ No newline at end of file
diff --git a/Interfaces/IReadOnlyFilesystem.cs b/Interfaces/IReadOnlyFilesystem.cs
index c6d188b..72e3275 100644
--- a/Interfaces/IReadOnlyFilesystem.cs
+++ b/Interfaces/IReadOnlyFilesystem.cs
@@ -40,6 +40,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Structs;
namespace Aaru.CommonTypes.Interfaces
@@ -63,62 +64,62 @@ namespace Aaru.CommonTypes.Interfaces
/// Which encoding to use for this filesystem.
/// Dictionary of key=value pairs containing options to pass to the filesystem
/// Filename namespace
- Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary options,
- string @namespace);
+ ErrorNumber Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
+ Dictionary options, string @namespace);
/// Frees all internal structures created by
- Errno Unmount();
+ ErrorNumber Unmount();
/// Maps a filesystem block from a file to a block from the underlying device.
/// Error number.
/// File path.
/// File block.
/// Device block.
- Errno MapBlock(string path, long fileBlock, out long deviceBlock);
+ ErrorNumber MapBlock(string path, long fileBlock, out long deviceBlock);
/// Gets the attributes of a file or directory
/// Error number.
/// File path.
/// File attributes.
- Errno GetAttributes(string path, out FileAttributes attributes);
+ ErrorNumber GetAttributes(string path, out FileAttributes attributes);
/// Lists all extended attributes, alternate data streams and forks of the given file.
/// Error number.
/// Path.
/// List of extended attributes, alternate data streams and forks.
- Errno ListXAttr(string path, out List xattrs);
+ ErrorNumber ListXAttr(string path, out List xattrs);
/// Reads an extended attribute, alternate data stream or fork from the given file.
/// Error number.
/// File path.
/// Extended attribute, alternate data stream or fork name.
/// Buffer.
- Errno GetXattr(string path, string xattr, ref byte[] buf);
+ ErrorNumber GetXattr(string path, string xattr, ref byte[] buf);
/// Reads data from a file (main/only data stream or data fork).
/// File path.
/// Offset.
/// Bytes to read.
/// Buffer.
- Errno Read(string path, long offset, long size, ref byte[] buf);
+ ErrorNumber Read(string path, long offset, long size, ref byte[] buf);
/// Lists contents from a directory.
/// Directory path.
/// Directory contents.
- Errno ReadDir(string path, out List contents);
+ ErrorNumber ReadDir(string path, out List contents);
/// Gets information about the mounted volume.
/// Information about the mounted volume.
- Errno StatFs(out FileSystemInfo stat);
+ ErrorNumber StatFs(out FileSystemInfo stat);
/// Gets information about a file or directory.
/// File path.
/// File information.
- Errno Stat(string path, out FileEntryInfo stat);
+ ErrorNumber Stat(string path, out FileEntryInfo stat);
/// Solves a symbolic link.
/// Link path.
/// Link destination.
- Errno ReadLink(string path, out string dest);
+ ErrorNumber ReadLink(string path, out string dest);
}
}
\ No newline at end of file
diff --git a/Structs/Filesystems.cs b/Structs/Filesystems.cs
index fb2a796..985ced8 100644
--- a/Structs/Filesystems.cs
+++ b/Structs/Filesystems.cs
@@ -38,7 +38,6 @@
// ****************************************************************************/
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
@@ -279,72 +278,4 @@ namespace Aaru.CommonTypes.Structs
[FieldOffset(3)]
public Guid uuid;
}
-
- /// Errors
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- public enum Errno
- {
- /// No error happened
- NoError = 0,
- /// Access denied
- AccessDenied = -13,
- /// Busy, cannot complete
- Busy = -16,
- /// File is too large
- FileTooLarge = -27,
- /// Invalid argument
- InvalidArgument = -22,
- /// I/O error
- InOutError = -5,
- /// Is a directory (e.g.: trying to Read() a dir)
- IsDirectory = -21,
- /// Name is too long
- NameTooLong = -36,
- /// There is no data available
- NoData = 61,
- /// There is no such attribute
- NoSuchExtendedAttribute = NoData,
- /// No such device
- NoSuchDevice = -19,
- /// No such file or directory
- NoSuchFile = -2,
- /// Is not a directory (e.g.: trying to ReadDir() a file)
- NotDirectory = -20,
- /// Not implemented
- NotImplemented = -38,
- /// Not supported
- NotSupported = -252,
- /// Link is severed
- SeveredLink = -67,
- /// Access denied
- EACCES = AccessDenied,
- /// Busy, cannot complete
- EBUSY = Busy,
- /// File is too large
- EFBIG = FileTooLarge,
- /// Invalid argument
- EINVAL = InvalidArgument,
- /// I/O error
- EIO = InOutError,
- /// Is a directory (e.g.: trying to Read() a dir)
- EISDIR = IsDirectory,
- /// Name is too long
- ENAMETOOLONG = NameTooLong,
- /// There is no such attribute
- ENOATTR = NoSuchExtendedAttribute,
- /// There is no data available
- ENODATA = NoData,
- /// No such device
- ENODEV = NoSuchDevice,
- /// No such file or directory
- ENOENT = NoSuchFile,
- /// Link is severed
- ENOLINK = SeveredLink,
- /// Not implemented
- ENOSYS = NotImplemented,
- /// Is not a directory (e.g.: trying to ReadDir() a file)
- ENOTDIR = NotDirectory,
- /// Not supported
- ENOTSUP = NotSupported
- }
}
\ No newline at end of file