Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.daemon.vfs » [javadoc | source]
    1   /*
    2    *  SSHTools - Java SSH2 API
    3    *
    4    *  Copyright (C) 2002-2003 Lee David Painter and Contributors.
    5    *
    6    *  Contributions made by:
    7    *
    8    *  Brett Smith
    9    *  Richard Pernavas
   10    *  Erwin Bolwidt
   11    *
   12    *  This program is free software; you can redistribute it and/or
   13    *  modify it under the terms of the GNU General Public License
   14    *  as published by the Free Software Foundation; either version 2
   15    *  of the License, or (at your option) any later version.
   16    *
   17    *  This program is distributed in the hope that it will be useful,
   18    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   19    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20    *  GNU General Public License for more details.
   21    *
   22    *  You should have received a copy of the GNU General Public License
   23    *  along with this program; if not, write to the Free Software
   24    *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   25    */
   26   package com.sshtools.daemon.vfs;
   27   
   28   import com.sshtools.j2ssh.configuration;
   29   
   30   import java.io;
   31   
   32   import java.util;
   33   
   34   
   35   /**
   36    *
   37    *
   38    * @author $author$
   39    * @version $Revision: 1.12 $
   40    */
   41   public class VFSMount {
   42       private String mount;
   43       private String path;
   44       private HashMap acl = new HashMap();
   45       private boolean isroot = false;
   46   
   47       /**
   48    * Creates a new VFSMount object.
   49    *
   50    * @param mount
   51    * @param path
   52    *
   53    * @throws IOException
   54    */
   55       public VFSMount(String mount, String path) throws IOException {
   56           path.replace('\\', '/');
   57   
   58           // Replace any tokens
   59           int index = path.indexOf("%HOME%");
   60   
   61           if (index >= 0) {
   62               path = ((index > 0) ? path.substring(0, index) : "") +
   63                   ConfigurationLoader.getHomeDirectory() +
   64                   (((index + 6) < (path.length() - 1))
   65                   ? path.substring(index +
   66                       ((path.charAt(index + 6) == '/') ? 7 : 6)) : "");
   67           }
   68   
   69           File f = new File(path);
   70   
   71           if (!f.exists()) {
   72               f.mkdirs();
   73           }
   74   
   75           if (!mount.trim().startsWith("/")) {
   76               this.mount = "/" + mount.trim();
   77           } else {
   78               this.mount = mount.trim();
   79           }
   80   
   81           this.path = f.getCanonicalPath();
   82       }
   83   
   84       /**
   85    *
   86    *
   87    * @return
   88    */
   89       public boolean isRoot() {
   90           return isroot;
   91       }
   92   
   93       /**
   94    *
   95    *
   96    * @param isroot
   97    */
   98       public void setRoot(boolean isroot) {
   99           this.isroot = isroot;
  100       }
  101   
  102       /**
  103    *
  104    *
  105    * @param permissions
  106    */
  107       public void setPermissions(VFSPermission permissions) {
  108           acl.put(permissions.getName(), permissions);
  109       }
  110   
  111       /**
  112    *
  113    *
  114    * @return
  115    */
  116       public String getPath() {
  117           return path.replace('\\', '/');
  118       }
  119   
  120       /**
  121    *
  122    *
  123    * @return
  124    */
  125       public String getMount() {
  126           return mount;
  127       }
  128   
  129       /**
  130    *
  131    *
  132    * @return
  133    */
  134       public Map getPermissions() {
  135           return acl;
  136       }
  137   }

Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.daemon.vfs » [javadoc | source]