using System;
using System.IO;
namespace Cosmos.System.FileSystem.Listing
{
///
/// Enumeration for the directory entry type.
///
public enum DirectoryEntryTypeEnum
{
///
/// Directory
///
Directory,
///
/// File
///
File,
///
/// Unknown
///
Unknown
}
///
/// A generic file system directory entry.
///
public abstract class DirectoryEntry
{
///
/// Entry size.
///
public long mSize;
///
/// Entry full path.
///
public string mFullPath;
///
/// Entry name.
///
public string mName;
protected readonly FileSystem mFileSystem;
///
/// Entry parent.
///
public readonly DirectoryEntry mParent;
///
/// Entry type.
///
public readonly DirectoryEntryTypeEnum mEntryType;
///
/// Initializes a new instance of the class.
///
/// The file system that contains the directory entry.
/// The parent directory entry or null if the current entry is the root.
/// The full path to the entry.
/// The entry name.
/// The size of the entry.
/// The ype of the entry.
/// Thrown if aFileSystem is null.
/// Thrown if aFullPath / aName is null.
protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, long aSize, DirectoryEntryTypeEnum aEntryType)
{
if (aFileSystem == null)
{
throw new ArgumentNullException(nameof(aFileSystem));
}
if (string.IsNullOrEmpty(aFullPath))
{
throw new ArgumentException("Argument is null or empty", nameof(aFullPath));
}
if (string.IsNullOrEmpty(aName))
{
throw new ArgumentException("Argument is null or empty", nameof(aName));
}
mFileSystem = aFileSystem;
mParent = aParent;
mEntryType = aEntryType;
mName = aName;
mSize = aSize;
mFullPath = aFullPath;
}
///
/// Set entry name.
///
/// A name to be set.
public abstract void SetName(string aName);
///
/// Set entry size.
///
/// A size to be set.
public abstract void SetSize(long aSize);
///
/// Get file stream.
///
/// Stream value.
public abstract Stream GetFileStream();
///
/// Get used space.
///
/// long value.
public abstract long GetUsedSpace();
}
}