HttpFileListing

Description

sealed class Tinman.Core.IO.Files.HttpFileListing

The HttpFileListing class holds a list of URLs which are known to point to existing resources, which is used by HttpFileSystem to implement IFileSystem.ListDirectories and IFileSystem.ListFiles.

The workflow involving HttpFileListing data looks like this:

  1. Use Build to create a HttpFileListing for a directory structure on the local system.

  2. Call Save to write an HTTP listing file.

  3. Upload the HTTP listing file to a server where it is accessible as a document in the root HTTP URL, for example:
    https://my.domain.com/root/listing.txt

  4. Call Fetch to obtain a HttpFileListing object for a root HTTP URL. For the above example, the root URL would be:
    https://my.domain.com/root/

  5. Use HttpFile.ListingAdd and HttpFile.ListingRemove to provide HttpFileListing objects for being used by the singleton HttpFileSystem object.

Actions 1 to 3 are usually performed in a separate preparation step. Applications performs actions 4 and 5 at runtime to set up its remote resources, usually at initialization time.

Public / Constructors

Build


public static method Build → (3)

directory in : Path

[not-null]
The local directory to scan for files and directories.

filter opt : PathFilterDelegate = null

The filter predicate that determines which Paths to collect. If null, all child Paths are collected.

recur opt : PredicateDelegate<Path> = null

The filter predicate that decides whether to recur into the tested directory or not. If null, recursion is done for all child directories.

returns → HttpFileListing

The created HttpFileListing.

Build a listing for an HTTP base URL, using Path.FindAll with the given filter opt and recur opt predicates.

IOException

If an I/O error has occurred.

Fetch


public static method Fetch → (3)

httpListing in : string

[not-null]
The URL to the uploaded listing file.

result out : SimpleHttpResult

The result of the HTTP request.

http opt : ISimpleHttp = null

The ISimpleHttp object to use or null to use a temporary one.

returns → HttpFileListing

The fetched HttpFileListing object or null if the HTTP request has failed (see result out for more information).

Fetches the listing for an HTTP base URL.

After fetching the content of the HTTP listing file, this method delegates to Load2, using the given httpListing in as BasePath.

Load

2 overloads


public static method Load1 → (2)

listingFile in : Path

[not-null]
The path to an HTTP listing file.

basePath in : Path

[not-null]
The value for BasePath.

returns → HttpFileListing

The created HttpFileListing object.

Creates a new instance of HttpFileListing from an HTTP listing file.

IOException

If an I/O error has occurred.


public static method Load2 → (2)

listingFile in : string

[not-null]
The contents of the HTTP listing file, as returned by object.ToString.

basePath in : Path

[not-null]
The value for BasePath.

returns → HttpFileListing

The created HttpFileListing object.

Creates a new instance of HttpFileListing from HTTP listing file content.

Public / Methods

Save


public method Save → (1)

file in : Path

[not-null]
The local file.

Saves this HTTP listing to the given local file.

Use Load1 to load a HTTP listing file, for testing and debugging.

IOException

If an I/O error has occurred.

Public / Attributes

Base​Path


[Constant]
public attribute BasePath → (get)

value : Path

The base path or null if this HttpFileListing object has not been created with Fetch.

Returns the base path of this HTTP listing.

To obtain the base URL, use Path.ToUrl.

Entries


[Constant]
public attribute Entries → (get)

value : ISortedSetConst<Path>

[not-null]
The HTTP listing entries.

Returns the HTTP listing entries.

Each entry is a relative path, to be resolved against BasePath, using slashes to separate path elements (see Path.ToSeparator), having a trailing separator iff the entry represents a directory.