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.
Features
Section titled “Features”FileSystem.Features returns the set the current storage supports:
if (fileSystem.Features.HasFlag(FileSystemFeatures.Watcher)) directory.CreateWatcher();| Feature | Meaning |
|---|---|
HiddenAttribute | The hidden attribute is stored and can be changed. |
ReadOnlyAttribute | The read-only attribute is stored and can be changed. |
LastWriteTimeAttributes | The last write time is stored and can be changed. |
Write | Files and directories can be created, changed and removed. Without it every write throws NotSupportedException. |
ConcurrentWriteOperations | More than one write may run at a time. |
Permissions | Read and write rights can be queried before an operation runs. |
Watcher | Changes can be observed through CreateWatcher(). |
Sync | Synchronous calls are available. |
Async | Asynchronous calls are available. |
HierarchicalDirectories | Directories 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.