Skip to content

Conversation

redruin1
Copy link
Contributor

Implements the proposed function. Needs testing, however.

fgardt added 30 commits November 7, 2023 04:26
- 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
fgardt and others added 9 commits July 12, 2025 00:22
* 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
@redruin1
Copy link
Contributor Author

Notably, the function here returns a Result<Vec<ModEntry>>, where each ModEntry has a path() and is_file/dir() methods. This slightly changes the syntax from before; e.g:

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.

@fgardt fgardt linked an issue Sep 19, 2025 that may be closed by this pull request
Copy link
Owner

@fgardt fgardt left a 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.

@fgardt
Copy link
Owner

fgardt commented Sep 19, 2025

The CI test report failing is weird but not a blocker, the clippy lints would be nice to solve tho.

@fgardt
Copy link
Owner

fgardt commented Sep 19, 2025

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.

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.

fgardt and others added 8 commits September 19, 2025 14:40
* 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
@redruin1
Copy link
Contributor Author

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 mod_util/test folder and write some code to try and read some example mods in that folder?

@fgardt
Copy link
Owner

fgardt commented Sep 24, 2025

Switched branch to make tracking easier. Implemented the iterator, no idea if it's "proper", but the compiler doesn't complain.

I have not checked through it yet, my own implementation approach got a bit stuck at some point.

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 mod_util/test folder and write some code to try and read some example mods in that folder?

For the blueprint and prototypes crates I made separate folders for tests BPs / data.raw dumps and put the things in there so in this case I guess we could have a test_mods folder under mod_util/test_mods that would contain different test mods. The actual test code itself can be in the same file at the bottom in a tests module (see the rust book on how to write tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mod_util] Iterate over a Mod's folder
3 participants