On 01/27/2014 11:29 AM, Michael T. Pope wrote:
The question is why freecol doesn't see my system as xdg-compliant,
although the fallback
directories for XDG_DATA_HOME & XDG_CACHE_HOME are present, and
XDG_CONFIG_HOME is set.
You are in a better place to answer that than anyone else.  Add a few
trace prints to the code and tell us what is wrong.

Cheers,
Mike Pope


Thanks for encouraging me to look further in the code, Mike.

I had a feeling the problem was with this part of the code :

            String env = System.getenv(xdg[i][0]);
            File d = (env != null) ? new File(home, env)
                : new File(home, xdg[i][1]);

the xdg[i][1] entries are all relative paths, but the env string holds an absolute path.

I looked up the java File specification http://docs.oracle.com/javase/7/docs/api/java/io/File.html.

File(home, env) would be correct if env holds a relative path, but NOT for an absolute path. changing it to File(env) made the test succeed and freecol copied the files.

I've attached a patch file created with diff -aur to change the code in src/net/sf/freecol/common/io/FreeColDirectories.java .

LW


diff -aur a/src/net/sf/freecol/common/io/FreeColDirectories.java b/src/net/sf/freecol/common/io/FreeColDirectories.java
--- a/src/net/sf/freecol/common/io/FreeColDirectories.java	2014-01-27 15:48:52.000000000 +0100
+++ b/src/net/sf/freecol/common/io/FreeColDirectories.java	2014-01-27 15:56:12.640620433 +0100
@@ -232,7 +232,7 @@
         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)
+            File d = (env != null) ? new File(env)
                 : new File(home, xdg[i][1]);
             if (d.exists()) {
                 if (!d.isDirectory() || !d.canWrite()) {
------------------------------------------------------------------------------
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
Freecol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freecol-developers

Reply via email to