001: /*
002: * SSHTools - Java SSH2 API
003: *
004: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
005: *
006: * Contributions made by:
007: *
008: * Brett Smith
009: * Richard Pernavas
010: * Erwin Bolwidt
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016: *
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: */
026: package com.sshtools.daemon.vfs;
027:
028: import com.sshtools.j2ssh.configuration.*;
029:
030: import java.io.*;
031:
032: import java.util.*;
033:
034: /**
035: *
036: *
037: * @author $author$
038: * @version $Revision: 1.12 $
039: */
040: public class VFSMount {
041: private String mount;
042: private String path;
043: private HashMap acl = new HashMap();
044: private boolean isroot = false;
045:
046: /**
047: * Creates a new VFSMount object.
048: *
049: * @param mount
050: * @param path
051: *
052: * @throws IOException
053: */
054: public VFSMount(String mount, String path) throws IOException {
055: path.replace('\\', '/');
056:
057: // Replace any tokens
058: int index = path.indexOf("%HOME%");
059:
060: if (index >= 0) {
061: path = ((index > 0) ? path.substring(0, index) : "")
062: + ConfigurationLoader.getHomeDirectory()
063: + (((index + 6) < (path.length() - 1)) ? path
064: .substring(index
065: + ((path.charAt(index + 6) == '/') ? 7
066: : 6))
067: : "");
068: }
069:
070: File f = new File(path);
071:
072: if (!f.exists()) {
073: f.mkdirs();
074: }
075:
076: if (!mount.trim().startsWith("/")) {
077: this .mount = "/" + mount.trim();
078: } else {
079: this .mount = mount.trim();
080: }
081:
082: this .path = f.getCanonicalPath();
083: }
084:
085: /**
086: *
087: *
088: * @return
089: */
090: public boolean isRoot() {
091: return isroot;
092: }
093:
094: /**
095: *
096: *
097: * @param isroot
098: */
099: public void setRoot(boolean isroot) {
100: this .isroot = isroot;
101: }
102:
103: /**
104: *
105: *
106: * @param permissions
107: */
108: public void setPermissions(VFSPermission permissions) {
109: acl.put(permissions.getName(), permissions);
110: }
111:
112: /**
113: *
114: *
115: * @return
116: */
117: public String getPath() {
118: return path.replace('\\', '/');
119: }
120:
121: /**
122: *
123: *
124: * @return
125: */
126: public String getMount() {
127: return mount;
128: }
129:
130: /**
131: *
132: *
133: * @return
134: */
135: public Map getPermissions() {
136: return acl;
137: }
138: }
|