Oops, copy/paste error in my previous mail .
applying that to the code would lead to something like this :
File home = getUserDefaultDirectory();
if (home == null) return -1; // Fail badly
String[][] xdg = { { XDG_CONFIG_HOME, ".local/share" },
{ XDG_DATA_HOME, ".config" },
{ XDG_CACHE_HOME, ".cache" } };
File[] todo = new File[xdg.length];
for (int i = 0; i < xdg.length; i++) {
String env = System.getenv(xdg[i] [0]);
File d = (env != null) ? new File(home, env)
: new File(home, xdg[i][1]);
# not sure if File (a, b) can handle a relative path as 2nd parameter, if not
it needs adjusting
if (d.exists()) {
if (!d.isDirectory() || !d.canWrite()) {
return -1; // Fail hard if something is broken
}
ret = Math.max(ret, 0);
File f = new File(d, FREECOL_DIRECTORY);
if (f.exists()) {
if (!f.isDirectory() || !f.canWrite()) {
return -1; // Again, fail hard
}
dirs[i] = f;
todo[i] = null;
ret++;
} else {
dirs[i] = d;
todo[i] = f;
}
} else {
dirs[i] = null;
todo[i] = d;
}
}
LoneVVolf
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers