|
= |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package org.jboss.vfs.spi; |
|
package org.jboss.vfs.spi; |
|
|
|
import java.net.URI; |
|
import java.net.URI; |
import java.net.URISyntaxException; |
|
import java.net.URISyntaxException; |
import org.jboss.vfs.VirtualFile; |
|
import org.jboss.vfs.VirtualFile; |
import org.jboss.logging.Logger; |
|
import org.jboss.logging.Logger; |
|
|
|
import java.io.File; |
|
import java.io.File; |
|
-+ |
import java.io.FileFilter; |
|
|
import java.io.FilenameFilter; |
import java.io.IOException; |
= |
import java.io.IOException; |
import java.io.InputStream; |
|
import java.io.InputStream; |
import java.io.FileInputStream; |
|
import java.io.FileInputStream; |
import java.security.CodeSigner; |
|
import java.security.CodeSigner; |
import java.util.List; |
|
import java.util.List; |
import java.util.Arrays; |
|
import java.util.Arrays; |
import java.util.Collections; |
|
import java.util.Collections; |
|
-+ |
import java.util.UUID; |
|
= |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final class RootFileSystem implements FileSystem { |
|
public final class RootFileSystem implements FileSystem { |
|
|
|
private static final Logger log = Logger.getLogger("org.jboss.vfs.root"); |
|
private static final Logger log = Logger.getLogger("org.jboss.vfs.root"); |
|
|
|
public static final RootFileSystem ROOT_INSTANCE = new RootFileSystem(); |
|
public static final RootFileSystem ROOT_INSTANCE = new RootFileSystem(); |
|
|
|
|
<> |
private boolean forceCaseSensative = false; |
|
|
|
private RootFileSystem(){} |
|
private RootFileSystem() { |
|
|
forceCaseSensative = "true".equals(System.getProperty("jboss.vfs.forceCaseSensative")); |
|
|
} |
|
= |
|
|
|
|
|
|
|
|
|
|
public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException { |
|
public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException { |
return new FileInputStream(getFile(mountPoint, target)); |
|
return new FileInputStream(getFile(mountPoint, target)); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isReadOnly() { |
|
public boolean isReadOnly() { |
return false; |
|
return false; |
} |
|
} |
|
|
|
|
-+ |
public class WindowsCaseSensativeFileFilter implements FilenameFilter { |
|
|
private String virtualFileName = ""; |
|
|
|
|
|
public WindowsCaseSensativeFileFilter(String virtualFileName) { |
|
|
this.virtualFileName = virtualFileName; |
|
|
if (virtualFileName == null) { |
|
|
virtualFileName = ""; |
|
|
} |
|
|
} |
|
|
|
|
|
@Override |
|
|
public boolean accept(File dir, String name) { |
|
|
return virtualFileName.equals(name); // Now it won't find the file unless it actually matched the case. |
|
|
} |
|
|
} |
|
|
|
|
= |
|
|
|
|
|
|
|
public File getFile(VirtualFile mountPoint, VirtualFile target) { |
|
public File getFile(VirtualFile mountPoint, VirtualFile target) { |
return new File(target.getPathName()); |
<> |
File retFile = new File(target.getPathName()); |
|
|
if (forceCaseSensative && retFile != null && retFile.isFile() && retFile.getAbsolutePath().contains("\\")) { |
|
|
File parentFile = retFile.getParentFile(); |
|
|
if (parentFile != null) { |
|
|
WindowsCaseSensativeFileFilter wc = new WindowsCaseSensativeFileFilter(target.getName()); |
|
|
if (parentFile.list(wc).length == 0) { |
|
|
retFile = new File(target.getPathName() + UUID.randomUUID().toString()); |
|
|
} |
|
|
} |
|
|
} |
|
|
return retFile; |
} |
= |
} |
|
|
|
|
|
|
|
|
|
|
|
|
public boolean delete(VirtualFile mountPoint, VirtualFile target) { |
|
public boolean delete(VirtualFile mountPoint, VirtualFile target) { |
return getFile(mountPoint, target).delete(); |
|
return getFile(mountPoint, target).delete(); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public long getSize(VirtualFile mountPoint, VirtualFile target) { |
|
public long getSize(VirtualFile mountPoint, VirtualFile target) { |
return getFile(mountPoint, target).length(); |
|
return getFile(mountPoint, target).length(); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public long getLastModified(VirtualFile mountPoint, VirtualFile target) { |
|
public long getLastModified(VirtualFile mountPoint, VirtualFile target) { |
return getFile(mountPoint, target).lastModified(); |
|
return getFile(mountPoint, target).lastModified(); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public boolean exists(VirtualFile mountPoint, VirtualFile target) { |
|
public boolean exists(VirtualFile mountPoint, VirtualFile target) { |
return getFile(mountPoint, target).exists(); |
|
return getFile(mountPoint, target).exists(); |
} |
|
} |
|
|
|
|
|
|
public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) { |
|
public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) { |
return getFile(mountPoint, target).isFile(); |
|
return getFile(mountPoint, target).isFile(); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isDirectory(VirtualFile mountPoint, VirtualFile target) { |
|
public boolean isDirectory(VirtualFile mountPoint, VirtualFile target) { |
return getFile(mountPoint, target).isDirectory(); |
|
return getFile(mountPoint, target).isDirectory(); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) { |
|
public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) { |
final String[] names = getFile(mountPoint, target).list(); |
|
final String[] names = getFile(mountPoint, target).list(); |
return names == null ? Collections.<String>emptyList() : Arrays.asList(names); |
|
return names == null ? Collections.<String>emptyList() : Arrays.asList(names); |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target) { |
|
public CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target) { |
return null; |
|
return null; |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public File getMountSource() { |
|
public File getMountSource() { |
return null; |
|
return null; |
} |
|
} |
|
|
|
public URI getRootURI() throws URISyntaxException { |
|
public URI getRootURI() throws URISyntaxException { |
return null; |
|
return null; |
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
public void close() throws IOException { |
|
public void close() throws IOException { |
|
|
|
} |
|
} |
} |
|
} |