Skip to content
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

Whitelisting of extensions for consoles #92

Merged
merged 17 commits into from
Oct 13, 2013

Conversation

Spongeroberto
Copy link
Contributor

This small edit allows you to supply a number of accepted file extensions for consoles.

When checking for roms, Ice will validate the file path against the whitelist. If no extensions are entered, or the extensions parameter in consoles.txt is omitted, all roms will be accepted.

Reasons to use this:

  • Avoid double entries for games that come in a bin/cue pair
  • Avoid double entries for Wii games; For big games, images can be split in a .wbfs file and .wbf1, .wbf2, etcetera. By just adding 'wbfs' to your extensions parameter
  • Avoid adding savestates / memory cards / ram files as duplicates of your game

My apologies for the unnecessary edits with line breaks - a result of my using Linux. I'll see about fixing that for future pull requests :)

…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
…alid rom' method to console instead of emulator.
@marcusmoller
Copy link
Contributor

You probably should just remove them from your commit.
I am not certain, but I fear that your recent commit (Spongeroberto@5dfea65) might just remove the content within emulators.txt, consoles.txt and config.txt of the master branch.


if self.extensions == "":
return True
return any(path.lower().endswith('.'+x) for x in self.extensions.split(' '))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: os.path provides a helper function to split a file extension away from a path. The function you want is

http://docs.python.org/2/library/os.path.html#os.path.splitext

Please change the logic to check if it ends with the extension to use this function. It should look something like:

(Note: no guarantees on the one-liner tuple syntax)

return any(path.endswith(os.path.splitext(path)[1]) for x in self.extensions.split(' '))

Also, would you make the list comma-separated instead of space-separated? It's sort of a personal preference, but I feel that commas convey the concept of a list much better than spaces do.

@Spongeroberto Spongeroberto reopened this Oct 11, 2013
@Spongeroberto
Copy link
Contributor Author

Extensions list may now be comma delimited (I trim each extension too for good measure). Also I don't ruin the existing config files this time around.

My apologies for the mess - I've always been a lurker rather than a contributor

scottrice added a commit that referenced this pull request Oct 13, 2013
Whitelisting of extensions for consoles
@scottrice scottrice merged commit 6d0de2b into scottrice:master Oct 13, 2013
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