structstd.Build.Step.WriteFile.Directory.Options[src]

Fields

exclude_extensions: []const []const u8 = &.{}

File paths that end in any of these suffixes will be excluded from copying.

include_extensions: ?[]const []const u8 = null

Only file paths that end in any of these suffixes will be included in copying. null means that all suffixes will be included. exclude_extensions takes precedence over include_extensions.

Functions

Functiondupe[src]

pub fn dupe(opts: Options, b: *std.Build) Options

Parameters

opts: Options

Source Code

Source code
pub fn dupe(opts: Options, b: *std.Build) Options {
    return .{
        .exclude_extensions = b.dupeStrings(opts.exclude_extensions),
        .include_extensions = if (opts.include_extensions) |incs| b.dupeStrings(incs) else null,
    };
}

FunctionpathIncluded[src]

pub fn pathIncluded(opts: Options, path: []const u8) bool

Parameters

opts: Options
path: []const u8

Source Code

Source code
pub fn pathIncluded(opts: Options, path: []const u8) bool {
    for (opts.exclude_extensions) |ext| {
        if (std.mem.endsWith(u8, path, ext))
            return false;
    }
    if (opts.include_extensions) |incs| {
        for (incs) |inc| {
            if (std.mem.endsWith(u8, path, inc))
                return true;
        } else {
            return false;
        }
    }
    return true;
}

Source Code

Source code
pub const Options = struct {
    /// File paths that end in any of these suffixes will be excluded from copying.
    exclude_extensions: []const []const u8 = &.{},
    /// Only file paths that end in any of these suffixes will be included in copying.
    /// `null` means that all suffixes will be included.
    /// `exclude_extensions` takes precedence over `include_extensions`.
    include_extensions: ?[]const []const u8 = null,

    pub fn dupe(opts: Options, b: *std.Build) Options {
        return .{
            .exclude_extensions = b.dupeStrings(opts.exclude_extensions),
            .include_extensions = if (opts.include_extensions) |incs| b.dupeStrings(incs) else null,
        };
    }

    pub fn pathIncluded(opts: Options, path: []const u8) bool {
        for (opts.exclude_extensions) |ext| {
            if (std.mem.endsWith(u8, path, ext))
                return false;
        }
        if (opts.include_extensions) |incs| {
            for (incs) |inc| {
                if (std.mem.endsWith(u8, path, inc))
                    return true;
            } else {
                return false;
            }
        }
        return true;
    }
}