Skip to content

[mod_util] Iterate over a Mod's folder #232

@redruin1

Description

@redruin1

Mod has get_file, which is great for getting the contents of a particular named file. However, certain processes (localization + migrations) are filename agnostic - meaning that their location in some folder indicates their function instead of their filename. In these cases, it would be much nicer to give a folder and return a iterator containing all of the files/folders inside of it (probably alphabetically). Essentially, this would be a fs::read_dir equivalent:

let some_mod: Mod = ...;

let english_locale = some_mod.read_dir("locale/en")?;
for filename in english_locale {
    let data = mod.get_file(filename)?;

    // ...
}

This should be pretty easy to implement, so I'm willing to contribute a PR if you don't have any complaints.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions