Skip to content
Auto
Products

Provider capabilities

Storages differ. FTP keeps a last write time but no hidden flag, S3 keeps neither, and only the local file system watches for changes made by another process. TagBites.IO reports the difference rather than emulating it, so code that needs a capability asks for it first.

FileSystem.Features returns the set the current storage supports:

if (fileSystem.Features.HasFlag(FileSystemFeatures.Watcher))
directory.CreateWatcher();
FeatureMeaning
HiddenAttributeThe hidden attribute is stored and can be changed.
ReadOnlyAttributeThe read-only attribute is stored and can be changed.
LastWriteTimeAttributesThe last write time is stored and can be changed.
WriteFiles and directories can be created, changed and removed. Without it every write throws NotSupportedException.
ConcurrentWriteOperationsMore than one write may run at a time.
PermissionsRead and write rights can be queried before an operation runs.
WatcherChanges can be observed through CreateWatcher().
SyncSynchronous calls are available.
AsyncAsynchronous calls are available.
HierarchicalDirectoriesDirectories are real objects of the storage. When absent, a directory exists only as a prefix of a key, so an empty directory cannot be represented.

Sync and Async are both reported outside a browser environment, because a provider that implements only one half is wrapped to offer the other.

Permissions is advisory. It stops calls made through this API, not access to the storage by anything else.

An update that asks for metadata a storage does not keep throws instead of failing silently:

if (fileSystem.Features.HasFlag(FileSystemFeatures.ReadOnlyAttribute))
file.UpdateMetadata(new FileSystemLinkMetadata { IsReadOnly = true });

A provider declares its half of this through IFileSystemFeatureSupport, described in custom file system.

FileSystem.Root is the top directory of the storage:

var root = fileSystem.Root;
if (root != null)
foreach (var link in root.GetLinks())
Console.WriteLine(link.FullName);

The property returns null when the storage has no single top directory. The local file system on Windows is the case that matters: a path made only of the separator resolves against the current drive, so there is no one directory that contains everything.

Reading the property asks the storage to resolve the separator. The returned link carries the loaded information, so Exists costs no further request.