Views: 367,849 Homepage | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 03-20-19 05:13 AM

0 users reading Discussion for Implementing XDG Support | 1 bot

Main - Development - Discussion for Implementing XDG Support New reply

Posted on 07-30-17 12:38 PM (rev. 2 of 07-30-17 12:40 PM) Link | #287
Hello Everyone,

I am currently looking into implementing the XDG Base Directory standard for MelonDS. I asked StapleButter about implementing this feature and he said it is okay to implement as long his requirements are fulfilled.

For those who don't know, the XDG Base Directory states where files, generated by the program, should be located. This standard is used on some Linux applications. In this case, I want everything to be stored in $XDG_DATA_HOME/melonds (or $HOME/.local/share/melonds if $XDG_DATA_HOME is not defined)

My Proposal:
So I have been looking around to see what cross-platform library would be best suited to add XDG support. It seems like the C++ filesystem library is the best option.
* the path class makes it super easy to concatenate two paths together and also has a stem function to separate the name from the extension (useful for creating .sav files).
* It has a function called create_directory (self-explanatory).
* For the path class, you can return a C string using c_str() (needed for fopen).

* This is a fairly new addition to the C++ ISO (c++17), so some compilers might not support this (or require the "experimental/" added).
* While the filesystem library works on both Windows (Visual Studio) and Linux (g++), Linux requires that you add the "-lstdc++fs" flag. I am not sure how to add that on cmake.
* I haven't tested the filesystem library on a Mac.

I also want to change how MelonDS organizes its files. Currently, it stores everything in the same location as the binary. I want to change that so the program stores certain files in a particular folder.

Here are the folders I have in mind:
* config
* bios
* saves

In terms of how this should be implemented in MelonDS, I was thinking of having three functions:
* Function 1: Returns the platform specific location of where the program files should be stored. For example, function1() returns $XDG_DATA_HOME.
* Function 2: Combine Function 1 + melonds folder + a relative path to the data it wants to access. For example, function2(dummyfile) returns $XDG_DATA_HOME/melonds/dummyfile.
* Function 3: Create the melonds, config, bios, and saves folders if they are not there already.

In general, one big downside to this is that you remove the portable aspect of melonDS. Linux user won't be able to have files be stored in the same folder as the binary once I implement this feature (unless melonDS has a way of stating that it want to run in portable mode).

So yeah, this is my plan. Tell me what you think!

Posted on 07-30-17 12:39 PM (rev. 2 of 07-30-17 12:41 PM) Link | #288
why is it in a spoiler

well if it kills portability, it's a no-no

however, having configurable paths is something I could very well do


Posted on 07-30-17 12:51 PM Link | #289
I see, then I guess this thread can be closed then if you are going you add configurable paths in the future.

Main - Development - Discussion for Implementing XDG Support New reply

Page rendered in 0.014 seconds. (2048KB of memory used)
MySQL - queries: 27, rows: 78/78, time: 0.011 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.