Skip to content

Add associations of file extensions with NDS files#6

Merged
WinterMute merged 6 commits into
devkitPro:masterfrom
chishm:file-extensions
Apr 10, 2019
Merged

Add associations of file extensions with NDS files#6
WinterMute merged 6 commits into
devkitPro:masterfrom
chishm:file-extensions

Conversation

@chishm

@chishm chishm commented Jan 28, 2019

Copy link
Copy Markdown
Contributor

Following the feedback on #5, I've implemented proposal 3.

This pull request adds a way to associate file extensions (e.g. .mp3 or .m3u) with an NDS file that can open them. Extension files should be named like <type>.ext, where <type> is an extension like mp3 or m3u, and placed in /nds. Their contents are formatted like .argv files, with the first argument pointing to the NDS file to open and all of the arguments passed to the NDS file. The name of the data file will be appended to the argument list. A relative path for the NDS file is resolved to the /nds/ directory.

So, for example, with the following file layout:

/nds/mp3.ext (contents: music-player.nds)
/nds/m3u.ext (contents: /nds/music-player.nds --list)
/nds/music-player.nds
/song1.mp3
/music/song2.mp3
/playlist.m3u

Results in the following:

  • All .mp3 and .m3u files will appear in file listings.
  • Opening /song1.mp3 will result in music-player.nds being run with the arguments list /nds/music-player.nds fat:/song1.mp3.
  • Opening song2.mp3 will have the arguments list /nds/music-player.nds fat:/music/song2.mp3.
  • Opening /playlist.m3u will also open music-player.nds but with the arguments list /nds/music-player.nds --list fat:/playlist.m3u.

I've also done a bit of refactoring to make the implementation cleaner and easier.

chishm added 6 commits March 4, 2019 14:29
Move ".argv" file parsing to a single location (args.cpp) and use it for
all path and argument conversions.
File extension handlers are files named "<type>.ext" where <type>
specifies the file type to associate it with. The contents of *.ext
files are argument lists (like .argv files) that point to an NDS file
and provide optional arguments too. They are placed in the /nds
directory.

Handlers allow browsing for data files, which are then opened by the
correct NDS file.

For example, a file named "mp3.ext" containing "/nds/music-player.avi" will
allow .mp3 files to be found and opened with music-player.avi. Another
file named "m3u.ext" containing "/nds/music-player.avi --list" will let
.m3u files be opened with music-player.avi, and the passed-in command
line will be "/nds/music-player --list /path/to/file.m3u" (sans quotes).
@chishm

chishm commented Mar 4, 2019

Copy link
Copy Markdown
Contributor Author

Hi @WinterMute, have you had a chance to take a look at this? I realise things have been a bit chaotic with the DKP forum breach, so just making sure this doesn't slip through the cracks.

@WinterMute WinterMute merged commit 58c500d into devkitPro:master Apr 10, 2019
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.

2 participants