Creating / maintaining those folders should be done by the xdg support in your OS, not by freecol.
The xdg base dir spec has been around since 2003 and should be available in all linux variants , what OS / distro are you using ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using Arch / XFCE, but it's not really relevant because I run freecol in a jailed environment. The filesystem on ~ is a separate mount in the jail, which is initially empty.
I wonder how XDG-compliant apps should behave if those dirs are non-existent. All programs I encountered so far just create everything they need.
As far as I understand XDG, it tells where to store your files, but does not say you dirs should already be created.
// As a side note, I like freecol be compliant to XDG specs regarding file placement and directory layout. It's just the question how to behave if they don't exist, yet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700"
However AFAICT it does not require the directory/s to be created on read.
For Freecol, I think this means we need to tolerate the .config directory being absent, as we usually only read from it. The other two will need to be created on file write, which happens immediately in the case of the log file in .cache, and when the first auto/save file for the data directory.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That would be the usual practice, but not in this case:
1. There is no logger available in FreeColDirectories, its routines are/can be called before we even configure the logger.
2. I am struggling to think of a circumstance where you can successfully create the directory but then not be able to chmod.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Those folders are part of the XDG Base Directory specification .
see https://specifications.freedesktop.org/basedir-spec/latest/
Creating / maintaining those folders should be done by the xdg support in your OS, not by freecol.
The xdg base dir spec has been around since 2003 and should be available in all linux variants , what OS / distro are you using ?
I'm using Arch / XFCE, but it's not really relevant because I run freecol in a jailed environment. The filesystem on ~ is a separate mount in the jail, which is initially empty.
I wonder how XDG-compliant apps should behave if those dirs are non-existent. All programs I encountered so far just create everything they need.
As far as I understand XDG, it tells where to store your files, but does not say you dirs should already be created.
// As a side note, I like freecol be compliant to XDG specs regarding file placement and directory layout. It's just the question how to behave if they don't exist, yet.
According to the XDG spec:
"If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700"
However AFAICT it does not require the directory/s to be created on read.
For Freecol, I think this means we need to tolerate the .config directory being absent, as we usually only read from it. The other two will need to be created on file write, which happens immediately in the case of the log file in .cache, and when the first auto/save file for the data directory.
sounds like a good solution, mike.
Should be fixed in git.c287b74.
Sourceforge doesn't seem to allow commit lines commenting, so I'll comment here. Is it OK?:
Should we maybe log what's going on? Like logger.warn("Failed to set directory permissions for " + dir.toPath()) ? Or the System.out thing, anyway.
Last edit: vasya novikov 2017-11-11
No worries.
That would be the usual practice, but not in this case:
1. There is no logger available in FreeColDirectories, its routines are/can be called before we even configure the logger.
2. I am struggling to think of a circumstance where you can successfully create the directory but then not be able to chmod.