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

Store properties in a more appropriate directory on Mac and Linux #1

Open
lukeu opened this issue Feb 4, 2016 · 2 comments
Open

Store properties in a more appropriate directory on Mac and Linux #1

lukeu opened this issue Feb 4, 2016 · 2 comments

Comments

@lukeu
Copy link
Owner

lukeu commented Feb 4, 2016

Reported to me: "On my Mac, TracInstant tries to store the config file in the directory". That is an odd location because it is in the top-level directory of my account:

/Users/foo/bettyluke.net/TracInstant/TracInstant.properties

Indeed, it falls back to that when it can't find the Windows-specific Application Data\Roaming folder.

It looks like on Mac to use:

$(HOME)/Library/Application Support/

And on Linux I guess "the right thing" would be to make it a hidden folder. Possibly:

    ~/.TracInstant/TracInstant.properties
@lukeu lukeu changed the title Store properties in a more appropriate directory on Mac Store properties in a more appropriate directory on Mac and Linux Jul 20, 2016
@japanoise
Copy link

And on Linux I guess "the right thing" would be to make it a hidden folder. Possibly:

    ~/.TracInstant/TracInstant.properties

On linux the right thing to do would be to respect $XDG_CONFIG_DIR, or put a directory in .config otherwise: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

There is likely a library to "do the right thing" in respecting $XDG_CONFIG_DIR, but I'm not 100% up on my Java so that's an exercise for the reader ;)

@japanoise
Copy link

Very silly pseudocode:

    protected File getGeneralDataDirectory() throws IOException {
        File baseDir = null;
        String homePath = (String) System.getProperties().get("user.home");
#ifdef windows
        if (homePath != null) {
            baseDir = new File(homePath);
        }
        if (baseDir == null || !baseDir.isDirectory()) {
            throw new IOException("User home directory not found.");
        }
        File f = new File(baseDir, "Application Data");
        return f.isDirectory() ? f : baseDir;
#ifdef linux
        String configPath = System.getEnvironmentVariable("XDG_CONFIG_DIR")
        if (configPath.equals("")) configPath = homePath+"/.config/TracInstant/"
        else configpath += "/TracInstant"
        File f = new File(configPath, "Application Data");
        return f.isDirectory() ? f : baseDir;
}

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

No branches or pull requests

2 participants