Skip to content

Set Default File Extension for `NIOLeafFiles`

Pre-release
Pre-release

Choose a tag to compare

@tanner0101 tanner0101 released this 24 Jun 17:20
c772598
This patch was authored and released by @tdotclare.

This release adds an initialization parameter to NIOLeafFiles to allow setting the default extension to be used for Leaf files.

public struct NIOLeafFiles: LeafSource {
    ...
    /// Initialize `NIOLeafFiles` with a NIO file IO object, limit options, and sandbox/view dirs
    /// - Parameters:
    ///   - fileio: `NonBlockingFileIO` file object
    ///   - limits: Options for constraining which files may be read - see `NIOLeafFiles.Limit`
    ///   - sandboxDirectory: Full path of the lowest directory which may be escaped to
    ///   - viewDirectory: Full path of the default directory templates are relative to
    ///   - defaultExtension: The default extension inferred files will have (defaults to `leaf`)
    ///
    /// `viewDirectory` must be contained within (or overlap) `sandboxDirectory`
    public init(fileio: NonBlockingFileIO,
                limits: Limit = .default,
                sandboxDirectory: String = "/",
                viewDirectory: String = "/",
                defaultExtension: String = "leaf") {...}

Usage:

    // Use "leaf4" instead of "leaf" as the implied file extension
    let source: LeafSource = NIOLeafFiles(..., defaultExtension: "leaf4")

Internal Changes

  • Various documentation of public protocols/objects
  • General rearrangement of code for clarity