// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Structs.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Component
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Description
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
namespace DiscImageChef.Filesystems
{
///
/// File attributes.
///
[Flags]
public enum FileAttributes
{
/// File is an alias (Mac OS)
Alias,
/// Indicates that the file can only be writable appended
AppendOnly,
/// File is candidate for archival/backup
Archive,
/// File is a block device
BlockDevice,
/// File is stored on filesystem block units instead of device sectors
BlockUnits,
/// Directory is a bundle or file contains a BNDL resource
Bundle,
/// File is a char device
CharDevice,
/// File is compressed
Compressed,
/// File is compressed and should not be uncompressed on read
CompressedRaw,
/// File has compression errors
CompressionError,
/// Compressed file is dirty
CompressionDirty,
/// File is a device
Device,
/// File is a directory
Directory,
/// File is encrypted
Encrypted,
/// File is stored on disk using extents
Extents,
/// File is a FIFO
FIFO,
/// File is a normal file
File,
/// File is a Mac OS file containing desktop databases that has already been added to the desktop database
HasBeenInited,
/// File contains an icon resource / EA
HasCustomIcon,
/// File is a Mac OS extension or control panel lacking INIT resources
HasNoINITs,
/// File is hidden/invisible
Hidden,
/// File cannot be written, deleted, modified or linked to
Immutable,
/// Directory is indexed using hashed trees
IndexedDirectory,
/// File contents are stored alongside its inode (or equivalent)
Inline,
/// File contains integrity checks
IntegrityStream,
/// File is on desktop
IsOnDesk,
/// File changes are written to filesystem journal before being written to file itself
Journaled,
/// Access time will not be modified
NoAccessTime,
/// File will not be subject to copy-on-write
NoCopyOnWrite,
/// File will not be backed up
NoDump,
/// File contents should not be scrubed
NoScrub,
/// File contents should not be indexed
NotIndexed,
/// File is offline
Offline,
/// File is password protected, but contents are not encrypted on disk
Password,
/// File is read-only
ReadOnly,
/// File is a reparse point
ReparsePoint,
/// When file is removed its content will be overwritten with zeroes
Secured,
/// File contents are sparse
Sparse,
/// File is a shadow (OS/2)
Shadow,
/// File is shared
Shared,
/// File is a stationery
Stationery,
/// File is a symbolic link
Symlink,
/// File writes are synchronously written to disk
Sync,
/// File belongs to the operating system
System,
/// If file end is a partial block its contend will be merged with other files
TailMerged,
/// File is temporary
Temporary,
/// Subdirectories inside of this directory are not related and should be allocated elsewhere
TopDirectory,
/// If file is deleted, contents should be stored, for a possible future undeletion
Undeletable
}
///
/// Information about a file entry
///
public class FileEntryInfo
{
DateTime crtimeUtc;
DateTime atimeUtc;
DateTime ctimeUtc;
DateTime btimeUtc;
DateTime mtimeUtc;
/// File attributes
public FileAttributes Attributes;
/// File creation date in UTC
public DateTime CreationTimeUtc { get { return crtimeUtc; } set { crtimeUtc = value; } }
/// File last access date in UTC
public DateTime AccessTimeUtc { get { return atimeUtc; } set { atimeUtc = value; } }
/// File attributes change date in UTC
public DateTime StatusChangeTimeUtc { get { return ctimeUtc; } set { ctimeUtc = value; } }
/// File last backup date in UTC
public DateTime BackupTimeUtc { get { return btimeUtc; } set { btimeUtc = value; } }
/// File last modification date in UTC
public DateTime LastWriteTimeUtc { get { return mtimeUtc; } set { mtimeUtc = value; } }
/// File creation date
public DateTime CreationTime { get { return crtimeUtc.ToLocalTime(); } set { crtimeUtc = value.ToUniversalTime(); } }
/// File last access date
public DateTime AccessTime { get { return atimeUtc.ToLocalTime(); } set { atimeUtc = value.ToUniversalTime(); } }
/// File attributes change date
public DateTime StatusChangeTime { get { return ctimeUtc.ToLocalTime(); } set { ctimeUtc = value.ToUniversalTime(); } }
/// File last backup date
public DateTime BackupTime { get { return btimeUtc.ToLocalTime(); } set { btimeUtc = value.ToUniversalTime(); } }
/// File last modification date
public DateTime LastWriteTime { get { return mtimeUtc.ToLocalTime(); } set { mtimeUtc = value.ToUniversalTime(); } }
/// Path of device that contains this file
public string DevicePath;
/// inode number for this file
public ulong Inode;
/// POSIX permissions/mode for this file
public uint Mode;
/// Number of hard links pointing to this file
public ulong Links;
/// POSIX owner ID
public ulong UID;
/// POSIX group ID
public ulong GID;
/// If file points to a device, device number
public ulong DeviceNo;
/// File length in bytes
public long Length;
/// File block size in bytes
public long BlockSize;
/// File length in blocks
public long Blocks;
}
public class FileSystemInfo
{
/// Filesystem type
public string Type;
/// ID of plugin for this file
public Guid PluginId;
/// Blocks for this filesystem
public long Blocks;
/// Blocks free on this filesystem
public long FreeBlocks;
/// Files on this filesystem
public ulong Files;
/// Free inodes on this filesystem
public ulong FreeFiles;
/// Maximum length of filenames on this filesystem
public ushort FilenameLength;
/// Filesystem ID
public Guid Id;
}
///
/// Errors
///
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,
/// 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,
/// 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
}
}