Skip to content

Add noExtension flag to getFolderContent for cleaner Paths usage #654

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

Merged
merged 6 commits into from
Jul 5, 2025

Conversation

HeroEyad
Copy link
Contributor

I think this is annoying every time I have to do Path.withoutExtension() manually just so I can use Paths.image() when pushing folder contents to an array.

This PR adds a new noExtension:Bool = false argument to Paths.getFolderContent() to simplify that process. Internally, it uses Path.withoutExtension() to return filenames without their extensions when the flag is set.

Why this helps:

  • Makes folder-to-path workflows easier, especially with Paths.image(), Paths.font(), etc. (this would work with easter eggs and such)
  • Cuts down repetitive code (Path.withoutExtension(...)).
  • Keeps default behavior intact (noExtension = false).

Example usage:

var iconFiles:Array<String> = [];
var icons = Paths.getFolderContent("images/icons", false, false, true); // noExtension = true

for (icon in icons) {
    iconFiles.push(icon);
}

var spr = new FunkinSprite(0,0,Paths.image(FlxG.random.getObject(iconFiles)))
add(spr);
// or make a better use to it idk.

Before: you'd have to strip extensions manually.

Now: just set noExtension to true and you're done.

@HeroEyad
Copy link
Contributor Author

HeroEyad commented Jul 2, 2025

thank you furo pls dont kill me

@NexIsDumb NexIsDumb merged commit 9d13923 into CodenameCrew:main Jul 5, 2025
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.

3 participants