Jump to content

List and iterate over resources


Katherine1

Recommended Posts

In my mod, I have scripts for initializing and updating the database it will be using as separate resources. They are all in the same folder and named with <number>.sql

Now, I can access any of them with 

new ResourceLocation("modid", "sql/1.sql");

The issue is that this list of files may grow and it'd be preferable to iterate over these files. Is there a way to get how many files are in that sql folder?

Link to comment
Share on other sites

I think I got it. I tossed out using Forge's resource loader for Java's. I can get the folder as a File object, and then I can get an array of files contained by the folder, which gives me a count of the schema revisions in the app. Then it's simply a matter of iterating through the files in that folder in numeric order and running the SQL scripts against the database.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.