• Introduction
  • C# API
  • GraphQL API
  • Home
  • Blog
  • Docs
  • GitHub
  • Snowflake.Filesystem
  • IReadOnlyDirectory
Show / Hide Table of Contents
  • Snowflake.Configuration
    • ConfigurationCollection<T>
    • ConfigurationCollectionDescriptor<T>
    • ConfigurationOptionDescriptor
    • ConfigurationOptionType
    • ConfigurationSection<T>
    • ConfigurationSectionDescriptor<T>
    • ConfigurationValueCollection
    • IConfigurationCollection
    • IConfigurationCollection<T>
    • IConfigurationCollectionDescriptor
    • IConfigurationOptionDescriptor
    • IConfigurationProperty
    • IConfigurationSection
    • IConfigurationSection<T>
    • IConfigurationSectionDescriptor
    • IConfigurationTypeMapper
    • IConfigurationValue
    • IConfigurationValueCollection
    • ISelectionOptionDescriptor
    • PathType
    • SelectionOptionDescriptor
  • Snowflake.Configuration.Attributes
    • ConfigurationOptionAttribute
    • ConfigurationSectionAttribute
    • ConfigurationTargetAttribute
    • ConfigurationTargetMemberAttribute
    • CustomMetadataAttribute
    • InputTemplateAttribute
    • SelectionOptionAttribute
  • Snowflake.Configuration.Input
    • DictionaryInputMapping
    • IDeviceInputMapping
    • IInputOption
    • IInputSerializer
    • IInputTemplate
    • IInputTemplate<T>
    • InputConfigurationSection<T>
    • InputOption
    • InputOptionAttribute
    • InputTemplate<T>
  • Snowflake.Configuration.Interceptors
    • ConfigurationInterceptor
  • Snowflake.Configuration.Serialization
    • AbstractConfigurationNode<T>
    • BooleanConfigurationNode
    • ConfigurationTarget
    • ConfigurationTraversalContext
    • DecimalConfigurationNode
    • DeviceCapabilityElementConfigurationNode
    • EnumConfigurationNode
    • IAbstractConfigurationNode
    • IAbstractConfigurationNode<T>
    • IConfigurationSerializationContext<T>
    • IConfigurationTarget
    • IConfigurationTransformer<TOutput>
    • IConfigurationTraversalContext
    • IntegralConfigurationNode
    • ListConfigurationNode
    • StringConfigurationNode
    • UnknownConfigurationNode
  • Snowflake.Configuration.Serialization.Serializers
    • AbstractStringConfigurationSerializer
    • ConfigurationSerializer<T>
    • StringSerializationContext
    • StringSerializationContextExtensions
  • Snowflake.Configuration.Serialization.Serializers.Implementations
    • SimpleCfgConfigurationSerializer
    • SimpleIniConfigurationSerializer
    • SimpleJsonConfigurationSerializer
    • SimpleXmlConfigurationSerializer
  • Snowflake.Extensibility
    • IEmptyPluginConfiguration
    • ILogger
    • IPlugin
    • IPluginCollection<T>
    • LogLevel
    • PluginAttribute
    • PluginCollection<T>
    • PluginInfoFields
  • Snowflake.Extensibility.Configuration
    • IPluginConfigurationStore
  • Snowflake.Extensibility.Provisioning
    • IPluginProperties
    • IPluginProvision
    • IProvisionedPlugin
    • PluginProvision
    • ProvisionedPlugin
  • Snowflake.Extensibility.Provisioning.Standalone
    • StandalonePlugin
    • StandalonePluginProvision
  • Snowflake.Extensibility.Queueing
    • IAsyncJobQueue
    • IAsyncJobQueue<T>
    • IAsyncJobQueue<TAsyncEnumerable, T>
    • IAsyncJobQueueFactory
  • Snowflake.Filesystem
    • DirectoryExtensions
    • FileExtensions
    • IDirectory
    • IFile
    • IIndelibleDirectory
    • IReadOnlyDirectory
    • IReadOnlyFile
  • Snowflake.Input.Controller
    • ControllerElement
    • ControllerElementCollection
    • ControllerElementExtensions
    • ControllerElementInfo
    • ControllerElementType
    • ControllerElementTypeExtensions
    • ControllerId
    • IControllerElementCollection
    • IControllerElementInfo
    • IControllerLayout
    • InvalidControllerIdException
  • Snowflake.Input.Controller.Mapped
    • ControllerElementMapping
    • ControllerElementMappingProfile
    • IControllerElementMappingProfile
    • IControllerElementMappingProfileStore
  • Snowflake.Input.Device
    • DefaultDeviceCapabilityLabels
    • DeviceCapability
    • DeviceCapabilityClass
    • DeviceCapabilityClasses
    • DeviceCapabilityExtensions
    • DeviceLayoutMapping
    • DictionaryDeviceCapabilityLabels
    • DirectInputDeviceInstance
    • IDeviceCapabilityLabels
    • IDeviceLayoutMapping
    • IInputDevice
    • IInputDeviceInstance
    • InputDriver
    • KeyboardDeviceInstance
    • PassthroughDeviceInstance
    • XInputDeviceInstance
  • Snowflake.Installation
    • AsyncInstallTask<T>
    • AsyncInstallTaskEnumerable<T>
    • ITaskResult
    • TaskResult
    • TaskResult<T>
  • Snowflake.Installation.Extensibility
    • GameInstaller
    • IGameInstaller
    • IInstallable
    • Installable
    • SupportedPlatformAttribute
  • Snowflake.Installation.Tasks
    • CopyDirectoryContentsTask
    • CopyFileTask
    • ExecuteAsyncTask<TResult>
    • ExtractZipTask
    • FailureTask<T>
  • Snowflake.Loader
    • IComposable
    • IModule
    • IModuleEnumerator
    • IModuleLoader<T>
    • ImportServiceAttribute
    • IServiceRepository
    • Module
  • Snowflake.Model.Database.Exceptions
    • DependentEntityNotExistsException
    • EntityAlreadyExistsException
  • Snowflake.Model.Database.Migrations
    • Empty
    • InitialCreate
  • Snowflake.Model.Game
    • Game
    • IGame
    • IGameExtension
    • IGameLibrary
    • IPlatformInfo
    • ISystemFile
    • PlatformId
  • Snowflake.Model.Game.LibraryExtensions
    • GameConfigurationExtensionExtensions
    • GameFileExtensionExtensions
    • IGameConfigurationExtension
    • IGameConfigurationExtensionProvider
    • IGameExtensionProvider
    • IGameExtensionProvider<TExtension>
    • IGameFileExtension
    • IGameFileExtensionProvider
  • Snowflake.Model.Records
    • FileRecord
    • GameRecord
    • IMetadataCollection
    • IRecord
    • IRecordMetadata
    • IRecordMetadataQuery
    • MetadataCollection
    • RecordMetadata
  • Snowflake.Model.Records.File
    • FileMetadataKeys
    • IFileRecord
    • ImageMetadataKeys
    • ImageTypes
  • Snowflake.Model.Records.Game
    • GameMetadataKeys
    • IGameRecord
    • IGameRecordQuery
  • Snowflake.Orchestration.Extensibility
    • EmulatedController
    • EmulatedPortsManager
    • EmulatorCompatibility
    • EmulatorOrchestrator
    • GameEmulation
    • GameEmulation<TConfigurationCollection>
    • GameEmulationState
    • IEmulatedController
    • IEmulatedPortDeviceEntry
    • IEmulatedPortsManager
    • IEmulatedPortStore
    • IEmulatorOrchestrator
    • IGameEmulation
  • Snowflake.Orchestration.Extensibility.Extensions
    • DeviceEnumeratorExtensions
  • Snowflake.Orchestration.Process
    • IEmulatorExecutable
    • IEmulatorExecutableProvider
    • IProcessBuilder
    • ProcessExtensions
  • Snowflake.Orchestration.Saving
    • GameFileExtensionGameSaveManagerExtensions
    • IGameSaveManager
    • ISaveGame
    • ISaveProfile
    • SaveGame
    • SaveManagementStrategy
  • Snowflake.Orchestration.SystemFiles
    • ISystemFileProvider
  • Snowflake.Persistence
    • ISqlDatabase
    • SqliteDatabase
    • SqliteMemoryDatabase
  • Snowflake.Remoting.Electron
    • IElectronPackage
    • IElectronPackageProvider
  • Snowflake.Remoting.Kestrel
    • IKestrelServerMiddlewareProvider
    • IKestrelWebServerService
  • Snowflake.Romfile
    • IFileSignature
    • IRomFileInfo
    • IStructuredFilename
    • NamingConvention
    • RomFileInfo
    • StructuredFilename
  • Snowflake.Romfile.Extensions
    • StringExtensions
  • Snowflake.Romfile.Tokenizer
    • FieldType
    • GoodToolsTokenClassifier
    • NoIntroTokenClassifier
    • StructuredFilenameToken
  • Snowflake.Scraping
    • GameScrapeContext
    • IScrapeContext
    • ISeed
    • ISeedRootContext
    • Seed
    • SeedContent
    • SeedRootContext
  • Snowflake.Scraping.Extensibility
    • AttachTarget
    • Culler
    • Directive
    • DirectiveAttribute
    • FileInstallationTraverserBase
    • GameMetadataTraverserBase
    • ICuller
    • IFileInstallationTraverser
    • IGameMetadataTraverser
    • IScraper
    • IScraperDirective
    • ITraverser<TProducts, TEffectTarget>
    • Scraper
    • SeedBuilder
    • SeedTree
    • Traverser<TProducts, TEffectTarget>
  • Snowflake.Services
    • IContentDirectoryProvider
    • IDeviceEnumerator
    • ILogProvider
    • IPluginManager
    • IServiceEnumerator
    • IServiceRegistrationProvider
    • IStoneProvider
  • Snowflake.Shiragame
    • IRomInfo
    • ISerialInfo
    • IShiragameProvider
    • RomInfo
    • SerialInfo

Interface IReadOnlyDirectory

Represents a readonly view over the root of a Directory, where each file that is access through a directory is associated with a GUID in the directory's manifest.

When files are moved between IDirectories, the files GUID is preserved. Thus, metadata can be preserved throughout.

Namespace: Snowflake.Filesystem
Assembly: Snowflake.Framework.Primitives.dll
Syntax
public interface IReadOnlyDirectory

Properties

Name

Gets the name of the directory

Declaration
string Name { get; }
Property Value
Type Description
System.String

RootedPath

Gets the contextual path of the directory, relative to the root of the directory provider context. For example, with paths produced by IGameFileExtension, the rooted path would be relative to Root. Keep in mind, these paths do not have meaning outside of the context of the directory, which may or may not be known. They are also not entirely compatible with System.IO.Path APIs, and are only meaningfull within the Snowflake.Filesystem API.

Declaration
string RootedPath { get; }
Property Value
Type Description
System.String

Methods

ContainsDirectory(String)

Whether or not this directory contains directory as a direct child. full path, this will truncate the path using System.IO.Path.GetDirectoryName(System.String)

Declaration
bool ContainsDirectory(string directory)
Parameters
Type Name Description
System.String directory

The name of the directory to check.

Returns
Type Description
System.Boolean

Whether or not this directory contains the given directory.

ContainsFile(String)

Whether or not this directory contains a file in its manifest. If provided a full path, this will truncate the path using System.IO.Path.GetFileName(System.String)

Declaration
bool ContainsFile(string file)
Parameters
Type Name Description
System.String file

The name of the file to check.

Returns
Type Description
System.Boolean

Whether or not this directory contains the given file.

EnumerateDirectories()

Enumerates all direct child directories of this IDirectory.

Declaration
IEnumerable<IReadOnlyDirectory> EnumerateDirectories()
Returns
Type Description
System.Collections.Generic.IEnumerable<IReadOnlyDirectory>

All direct children directories.

EnumerateFiles()

Enumerates all files in this directory,

Declaration
IEnumerable<IReadOnlyFile> EnumerateFiles()
Returns
Type Description
System.Collections.Generic.IEnumerable<IReadOnlyFile>

All direct children files.

EnumerateFilesRecursive()

Recursively enumerates all files that are contained in this directory.

This method is usually implemented as a Breadth-first search, but no order is guaranteed.

Declaration
IEnumerable<IReadOnlyFile> EnumerateFilesRecursive()
Returns
Type Description
System.Collections.Generic.IEnumerable<IReadOnlyFile>

All files contained within this directory, including descendant subfolders.

OpenDirectory(String)

Opens an existing descendant directory with the given name. If the directory does not exist, throws IOException. You can open a nested directory using '/' as the path separator, and it will be created relative to this current directory.

Declaration
IReadOnlyDirectory OpenDirectory(string name)
Parameters
Type Name Description
System.String name

The name of the existing directory

Returns
Type Description
IReadOnlyDirectory

The directory if it exists, or null if it does not.

OpenDirectory(String, Boolean)

Opens an existing descendant directory with the given name. If the directory does not exist, throws IOException. You can open a nested directory using '/' as the path separator, and it will be created relative to this current directory.

Declaration
IReadOnlyDirectory OpenDirectory(string name, bool createIfNotExists)
Parameters
Type Name Description
System.String name

The name of the existing directory

System.Boolean createIfNotExists

If the directory does not exist, will create the directory.

Returns
Type Description
IReadOnlyDirectory

The directory if it exists, or null if it does not.

OpenFile(String)

Opens a file if it exists. If the file does not exist, will throw an FileNotFoundException.

Unlike OpenDirectory(String), you can not use the path separator to open a nested file. Paths will be truncated with System.IO.Path.GetFileName(System.String).

Instead, use OpenDirectory(String) to open the directory of the desired file, then call OpenFile(String) on the returned instance.

Keep in mind this does not actually create a file on the underlying file system. However, you can use OpenStream() and friends to create the file if it does not yet exist.

Declaration
IReadOnlyFile OpenFile(string file)
Parameters
Type Name Description
System.String file

The name of the file. If this is a path, will be truncated with System.IO.Path.GetFileName(System.String)

Returns
Type Description
IReadOnlyFile

An object that associates a given file with a with a unique System.Guid

OpenFile(String, Boolean)

Opens a file if it exists.

Unlike OpenDirectory(String), you can not use the path separator to open a nested file. Paths will be truncated with System.IO.Path.GetFileName(System.String).

Instead, use OpenDirectory(String) to open the directory of the desired file, then call OpenFile(String) on the returned instance.

Keep in mind this does not actually create a file on the underlying file system. However, you can use OpenStream() and friends to create the file if it does not yet exist.

Declaration
IReadOnlyFile OpenFile(string file, bool createIfNotExists)
Parameters
Type Name Description
System.String file

The name of the file. If this is a path, will be truncated with System.IO.Path.GetFileName(System.String)

System.Boolean createIfNotExists

If true, then the handle will be created for the file if it does not exists. No actual file will be created but the filename will receive an entry in the manifest.

Returns
Type Description
IReadOnlyFile

An object that associates a given file with a with a unique System.Guid

UnsafeGetPath()

Gets the underlying System.IO.DirectoryInfo where files are contained.

This is very rarely necessary, and most IO tasks can be done efficiently and safely using the provided API. Manipulating the underlying file system will potentially desync the manifest, and cause loss of associated metadata.

Declaration
[Obsolete("Avoid accessing the underlying file path, and use the object methods instead.")]
DirectoryInfo UnsafeGetPath()
Returns
Type Description
System.IO.DirectoryInfo

The underlying System.IO.DirectoryInfo where files are contained.

In This Article
  • Properties
    • Name
    • RootedPath
  • Methods
    • ContainsDirectory(String)
    • ContainsFile(String)
    • EnumerateDirectories()
    • EnumerateFiles()
    • EnumerateFilesRecursive()
    • OpenDirectory(String)
    • OpenDirectory(String, Boolean)
    • OpenFile(String)
    • OpenFile(String, Boolean)
    • UnsafeGetPath()
Built with ❤️ by @chyyran. Text content licensed under CC-BY-SA 4.0.