-
Notifications
You must be signed in to change notification settings - Fork 5
Add read_dir
to mod_util::Mod
(#232)
#234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- added mod presets - added mod dependency resolving - does not actually resolve anything but just checks if the latest versions are a valid solution - should support reading installed mods info.json files instead of always fetching from the mod portal api - lots of refactors - properly implemented the `FactorioArray` fix - loading & rendering of SE and K2 was successfully tested
* feat(blueprint): store individual test BPs in JSON format * feat(blueprint): add more test BPs & fix issues accordingly
* feat: add space-age preset * feat: BP data members impl `Default` * feat: test BP renderer example
* chore: restructure & more test BPs * feat: improve artillery wagon & rolling stock rendering * feat: example renderer filter by name * feat: show glow sprites * feat: skip non normal blend modes * feat: improve rail signal rendering
initial implementation
* changed name to `read_dir` to mimic fs * Now returns a `Vec<ModEntry>` structs, too dumb atm to figure out an iterator and the difference should be minimal for normal sized dirs * ModEntry has `is_file()` and `is_dir()` helpers, and most other convenient stuff can be grabbed from `path()` * ModEntry can be easily expanded with additional metadata if desired
Notably, the function here returns a let mod: Mod = ...;
let cfg_files = mod.read_dir("locale/en")?.iter()
.filter(|&x| x.is_file() && x.path().extension() == Some("cfg"));
for cfg_file in cfg_files {
let data = mod.read_file(&cfg_file.path())?;
// ...
} The returned value should probably be an iterator instead of a Vec, but I'm too smoothbrained with Rust to be able to do that at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nice for a start. One thought I have is that instead of returning a Vec<ModEntry>
we could have a new struct like ModDir
that then also implements Iterator
so its usage would be very similar to the regular fs::read_dir
.
The CI test report failing is weird but not a blocker, the clippy lints would be nice to solve tho. |
oh I just read this now, if you're fine with it I'll clean the PR up and change it into the iterator like I proposed. |
* deps: update to konst 0.4 * fix: make clippy happy * feat: generics for `get_zip_internal_folder` * fix: get mod dependency info during `ModList::generate_custom` * fix: correct zip, versioned folder and folder load order
* feat: implement datastage * ci: switch windows to msvc
* feat(factorio_datastage): impl `LuaHelpers::multilingual_to_lower` * chore(factorio_datastage): update to 2.0.68 * chore(blueprint): update test BPs to 2.0.68 * fix(prototypes): add missing `rail-support` * feat(prototypes): add `icon_draw_specification` & `icons_positioning` * chore(prototypes): update a couple prototypes * chore: update test dumps * feat(prototypes): add splitter circuit connections * feat: add `water_reflection` to `*GraphicsSet` * fix(types): remove `LocalisedString` number & bool variants * fix: support `BoundingBox` with orientations
+ all the clippy lints on my machine
Switched branch to make tracking easier. Implemented the iterator, no idea if it's "proper", but the compiler doesn't complain. I want to write some tests to make sure it actually behaves, ideally with some actual mod folders/zips. Whats the rusty way to do this? Should I make a |
I have not checked through it yet, my own implementation approach got a bit stuck at some point.
For the |
Implements the proposed function. Needs testing, however.