Set Default File Extension for `NIOLeafFiles`
Pre-release
Pre-release
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