widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #13668
Re: [Merge] lp:~lucki1/widelands/add-xdg-support into lp:widelands
Hello Luki, thanks for your support!
I was no ware about that spec. But on OSX such Files should e.g. be found
at ~/Library/Application Support/Wesnoth<Version>/...
OK just found "NOT APPLE". Sound Like I have to do this on a seperate branch,
and it can be tested on *nix only.
Gun: I am not sure if this should make it into R20 it may break some tescases
and documentation. So I would suggets to put this in at the begin of R21,
once R20 is on the road to be relased.
I will try to check how this beaves on OSX perhaps on Sunday.
Not sure If I will be able to unpack that Linux Box in my corner soon.
One nit inline, code looks so far so good.
Diff comments:
>
> === modified file 'src/io/filesystem/filesystem.cc'
> --- src/io/filesystem/filesystem.cc 2018-06-06 19:45:06 +0000
> +++ src/io/filesystem/filesystem.cc 2018-06-07 21:43:45 +0000
> @@ -262,6 +262,51 @@
> return homedir;
> }
>
> +std::string FileSystem::get_xdgdir() {
> + std::string xdgdir;
> +#ifdef HAS_GETENV
> + if (char const* const h = getenv("HOME")) {
> + if (char const* const x = getenv("XDG_DATA_HOME")) {
> + xdgdir = x;
> +
> + // Unlike the other function, this function returns the program name
> + // with. This is handled in 'src/wlapplication.cc'.
> + xdgdir = xdgdir + "/widelands";
> + }
> + else {
> + // If XDG_DATA_HOME is not set, the default path is used.
> + xdgdir = h;
> + xdgdir = xdgdir + "/.local/share";
> +
> + // Unlike the other function, this function returns the program name
> + // with. This is handled in 'src/wlapplication.cc'.
> + xdgdir = xdgdir + "/widelands";
> + }
> +
> + // Use dotfolder for backwards compatibility if it exists.
> + RealFSImpl dot(h);
> + if (dot.is_directory(".widelands")) {
> + xdgdir = h;
> +
> + // Unlike the other function, this function returns the program name
> + // with. This is handled in 'src/wlapplication.cc'.
> + xdgdir = xdgdir + "/.widelands";
> + }
> + }
> +#endif
> +
> + if (xdgdir.empty()) {
> + log("\nWARNING: either we can not detect your XDG or home directory "
> + "or you do not have one! Please contact the developers.\n\n");
> +
> + // TODO(unknown): is it really a good idea to set xdgdir to "." then ??
please use TODO(Luki):
> + log("Instead of your XDG or home directory, '.' will be used.\n\n");
> + xdgdir = "./.widelands";
> + }
> +
> + return xdgdir;
> +}
> +
> /**
> * Split a string into components separated by a certain character.
> *
--
https://code.launchpad.net/~lucki1/widelands/add-xdg-support/+merge/347652
Your team Widelands Developers is requested to review the proposed merge of lp:~lucki1/widelands/add-xdg-support into lp:widelands.
References