Author: zothar
Date: 2007-02-18 17:57:50 +0000 (Sun, 18 Feb 2007)
New Revision: 11834

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Fix bug 1092: allow configuring a non-system-default home directory, used 
mainly by the onion FEC library files at the moment.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2007-02-18 17:56:22 UTC (rev 
11833)
+++ trunk/freenet/src/freenet/node/Node.java    2007-02-18 17:57:50 UTC (rev 
11834)
@@ -402,6 +402,8 @@
        public static final short DEFAULT_MAX_HTL = (short)10;
        public static final int DEFAULT_SWAP_INTERVAL = 2000;
        private short maxHTL;
+       private String homeDir;
+       private final String systemDefaultHomeDir = 
System.getProperty("user.home");
        public static final int EXIT_STORE_FILE_NOT_FOUND = 1;
        public static final int EXIT_STORE_IOEXCEPTION = 2;
        public static final int EXIT_STORE_OTHER = 3;
@@ -847,6 +849,29 @@

                maxHTL = nodeConfig.getShort("maxHTL");

+               nodeConfig.register("homeDir", "", sortOrder++, true, false, 
"Freenet-used home directory", "Freenet used home directory (i.e. where to put 
Onion FEC library files)(leave empty for user's default home directory 
(recommended))",
+                               new StringCallback() {
+
+                                       public String get() {
+                                               return homeDir;
+                                       }
+
+                                       public void set(String val) throws 
InvalidConfigValueException {
+                                               if(homeDir == null) throw new 
InvalidConfigValueException("Tried setting the home directory to null");
+                                               homeDir = val;
+                                               if(!homeDir.equals("")) {
+                                                       
System.setProperty("user.home", homeDir);
+                                               } else {
+                                                       
System.setProperty("user.home", systemDefaultHomeDir);
+                                               }
+                                       }
+               });
+               
+               homeDir = nodeConfig.getString("homeDir");
+               if(!homeDir.equals("")) {
+                       System.setProperty("user.home", homeDir);
+               }
+               
                // FIXME maybe these should persist? They need to be private.
                decrementAtMax = random.nextDouble() <= DECREMENT_AT_MAX_PROB;
                decrementAtMin = random.nextDouble() <= DECREMENT_AT_MIN_PROB;


Reply via email to