[cvs] expresso commit by lhamel: don't add initial slash to windows path

JCorporate Ltd jcorp at jcorporate.com
Sat Feb 19 05:13:38 UTC 2005


Log Message:
-----------
don't add initial slash to windows path

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc:
        ConfigManager.java

Revision Data
-------------
Index: ConfigManager.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java,v
retrieving revision 1.81
retrieving revision 1.82
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java -u -r1.81 -r1.82
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/ConfigManager.java
@@ -1027,9 +1027,11 @@
                 } else {
                     configDir = FileUtil.makeAbsolutePath(rootDir, configDir);
 
-                    if (!('/' == configDir.charAt(0))) {
-                        configDir = "/" + configDir;
-                    }
+                    /* if there isn't a drive specification for windows-type path
+                        nor a beginning slash, add a slash;
+                        @todo: what is the use case for needing this test?  doesn't getRealPath() above always give absolute path?
+                        */
+                    configDir = addInitialSlashIfNecessary(configDir);
 
 //                    setupLog.info("ConfigManager: Config dir is now '" +
 //                            configDir + "'");
@@ -1038,9 +1040,11 @@
             } else {
                 configDir = FileUtil.makeAbsolutePath(rootDir, configDir);
 
-                if (!('/' == configDir.charAt(0))) {
-                    configDir = "/" + configDir;
-                }
+                /* if there isn't a drive specification for windows-type path
+                nor a beginning slash, add a slash;
+                @todo: what is the use case for needing this test?  doesn't getRealPath() above always give absolute path?
+                */
+                configDir = addInitialSlashIfNecessary(configDir);
 
 //                setupLog.info("ConfigManager: Config dir is now '" +
 //                        configDir + "'");
@@ -1067,6 +1071,14 @@
             configurationFailed = true;
             throw new ServletException(thrown);
         }
+    }
+
+    private static String addInitialSlashIfNecessary(String path) {
+        if ('/' != path.charAt(0) && path.charAt(1) != ':') {
+            path = "/" + path;
+            log.warn("adding slash to configDir to create path: " + configDir);
+        }
+        return path;
     }
 
     /**


More information about the cvs mailing list