geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject cvs commit: incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle Twiddle.java
Date Mon, 25 Aug 2003 18:44:06 GMT
jdillon     2003/08/25 11:44:06

  Modified:    modules/twiddle/src/java/org/apache/geronimo/twiddle
                        Twiddle.java
  Log:
   o Exposing Twiddle's ClassWorld
   o Getting Canonical file for twiddle.home even when property is set to get
     rid of any ../ bits
  
  Revision  Changes    Path
  1.10      +29 -11    incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/Twiddle.java
  
  Index: Twiddle.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/Twiddle.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Twiddle.java	25 Aug 2003 16:07:45 -0000	1.9
  +++ Twiddle.java	25 Aug 2003 18:44:06 -0000	1.10
  @@ -156,6 +156,16 @@
       }
       
       /**
  +     * Get the class world.
  +     *
  +     * @return The class world.
  +     */
  +    public ClassWorld getClassWorld()
  +    {
  +        return world;
  +    }
  +    
  +    /**
        * Get the command container.
        *
        * @return The command container.
  @@ -249,20 +259,28 @@
       {
           // Determine what our home directory is
           String temp = System.getProperty(TWIDDLE_HOME);
  -        if (temp == null) {
  -            String path = Twiddle.class.getProtectionDomain().getCodeSource().getLocation().getFile();
  -            try {
  +        File dir = null;
  +        
  +        try {
  +            if (temp == null) {
  +                String path = Twiddle.class.getProtectionDomain().getCodeSource().getLocation().getFile();
                   path = URLDecoder.decode(path, "UTF-8");
  -                //
  -                // jason: home dir is expected to be lib/..
  -                //
  -                temp = new File(path).getParentFile().getParentFile().getCanonicalPath();
  +                
  +                // home dir is expected to be lib/..
  +                dir = new File(path).getParentFile().getParentFile();
               }
  -            catch (IOException e) {
  -                throw new RuntimeException("Unable to determine home dir", e);
  +            else {
  +                dir = new File(temp);
               }
  +            
  +            // Make sure the home dir does not have any ../ bits
  +            dir = dir.getCanonicalFile();
           }
  -        return new File(temp);
  +        catch (IOException e) {
  +            throw new RuntimeException("Unable to determine home dir", e);
  +        }
  +        
  +        return dir;
       }
       
       /**
  
  
  

Mime
View raw message