1 16 package org.apache.commons.vfs.provider.local; 17 18 import org.apache.commons.vfs.FileName; 19 import org.apache.commons.vfs.FileObject; 20 import org.apache.commons.vfs.FileSelector; 21 import org.apache.commons.vfs.FileSystem; 22 import org.apache.commons.vfs.FileSystemException; 23 import org.apache.commons.vfs.FileSystemOptions; 24 import org.apache.commons.vfs.provider.AbstractFileSystem; 25 26 import java.io.File ; 27 import java.io.FilePermission ; 28 import java.util.Collection ; 29 30 35 public class LocalFileSystem 36 extends AbstractFileSystem 37 implements FileSystem 38 { 39 private final String rootFile; 40 41 public LocalFileSystem(final FileName rootName, 42 final String rootFile, 43 final FileSystemOptions opts) 44 { 45 super(rootName, null, opts); 46 this.rootFile = rootFile; 47 } 48 49 52 protected FileObject createFile(final FileName name) throws FileSystemException 53 { 54 String fileName = rootFile + name.getPath(); 56 return new LocalFile(this, fileName, name); 57 } 58 59 62 protected void addCapabilities(final Collection caps) 63 { 64 caps.addAll(DefaultLocalFileProvider.capabilities); 65 } 66 67 70 protected File doReplicateFile(final FileObject fileObject, 71 final FileSelector selector) 72 throws Exception 73 { 74 final LocalFile localFile = (LocalFile) fileObject; 75 final File file = localFile.getLocalFile(); 76 final SecurityManager sm = System.getSecurityManager(); 77 if (sm != null) 78 { 79 final FilePermission requiredPerm = new FilePermission (file.getAbsolutePath(), "read"); 80 sm.checkPermission(requiredPerm); 81 } 82 return file; 83 } 84 85 } 86 | Popular Tags |