[jboss-cvs] JBossAS SVN: r95112 - in projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs: spi and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 19 10:19:21 EDT 2009


Author: david.lloyd at jboss.com
Date: 2009-10-19 10:19:20 -0400 (Mon, 19 Oct 2009)
New Revision: 95112

Modified:
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/AssemblyFileSystem.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/FileSystem.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/JavaZipFileSystem.java
   projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/RealFileSystem.java
Log:
Add "isFile()" method.

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java	2009-10-19 12:41:12 UTC (rev 95111)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/VirtualFile.java	2009-10-19 14:19:20 UTC (rev 95112)
@@ -193,6 +193,11 @@
         return !isDirectory();
     }
 
+    public boolean isFile() {
+        final VFS.Mount mount = VFS.getMount(this);
+        return mount.getFileSystem().isFile(mount.getMountPoint(), this);
+    }
+
     /**
      * Determine whether the named virtual file is a directory.
      *

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/AssemblyFileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/AssemblyFileSystem.java	2009-10-19 12:41:12 UTC (rev 95111)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/AssemblyFileSystem.java	2009-10-19 14:19:20 UTC (rev 95112)
@@ -68,6 +68,12 @@
     }
 
     /** {@inheritDoc} */
+    public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) {
+        VirtualFile assemblyFile = assembly.getFile(mountPoint, target);
+        return assemblyFile != null && assemblyFile.isFile();
+    }
+
+    /** {@inheritDoc} */
     public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) {
         VirtualFile assemblyFile = assembly.getFile(mountPoint, target);
         if (assemblyFile == null) {

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/FileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/FileSystem.java	2009-10-19 12:41:12 UTC (rev 95111)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/FileSystem.java	2009-10-19 14:19:20 UTC (rev 95112)
@@ -118,6 +118,16 @@
     boolean exists(VirtualFile mountPoint, VirtualFile target);
 
     /**
+     * Ascertain whether a virtual file within this filesystem is a plain file.
+     *
+     * @param mountPoint the mount point of the filesystem instance (guaranteed to be a parent of {@code target})
+     * @param target the virtual file to act upon
+     *
+     * @return {@code true} if the file exists and is a plain file, {@code false} otherwise
+     */
+    boolean isFile(VirtualFile mountPoint, VirtualFile target);
+
+    /**
      * Ascertain whether a virtual file within this filesystem is a directory.
      *
      * @param mountPoint the mount point of the filesystem instance (guaranteed to be a parent of {@code target})
@@ -137,14 +147,14 @@
      * @return the collection of children names
      */
     List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target);
-    
+
     /**
      * Get the {@link CodeSigner}s for a the virtual file.
-     * 
+     *
      * @param mountPoint the mount point of the filesystem instance (guaranteed to be a parent of {@code target})
      * @param target the virtual file to act upon
      *
-     * @return {@link CodeSigner} for the virtual file or null if not signed. 
+     * @return {@link CodeSigner} for the virtual file or null if not signed.
      */
     CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target);
 

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/JavaZipFileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/JavaZipFileSystem.java	2009-10-19 12:41:12 UTC (rev 95111)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/JavaZipFileSystem.java	2009-10-19 14:19:20 UTC (rev 95112)
@@ -127,10 +127,12 @@
         log.tracef("Created zip filesystem for file %s in temp dir %s", archiveFile, tempDir);
     }
 
+    /** {@inheritDoc} */
     private static <T> Iterable<T> iter(final Enumeration<T> entries) {
         return new EnumerationIterable<T>(entries);
     }
 
+    /** {@inheritDoc} */
     public File getFile(VirtualFile mountPoint, VirtualFile target) throws IOException {
         final ZipNode zipNode = getExistingZipNode(mountPoint, target);
         // check if we have cached one already
@@ -155,6 +157,7 @@
         }
     }
 
+    /** {@inheritDoc} */
    public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException {
         final ZipNode zipNode = getExistingZipNode(mountPoint, target);
         final File cachedFile = zipNode.cachedFile;
@@ -171,6 +174,7 @@
         return zipFile.getInputStream(entry);
     }
 
+    /** {@inheritDoc} */
     public boolean delete(VirtualFile mountPoint, VirtualFile target) {
         final ZipNode zipNode = getZipNode(mountPoint, target);
         if (zipNode == null) {
@@ -180,6 +184,7 @@
         return cachedFile != null && cachedFile.delete();
     }
 
+    /** {@inheritDoc} */
     public long getSize(VirtualFile mountPoint, VirtualFile target) {
         final ZipNode zipNode = getZipNode(mountPoint, target);
         if (zipNode == null) {
@@ -193,6 +198,7 @@
         return cachedFile != null ? cachedFile.length() : entry == null ? 0L : entry.getSize();
     }
 
+    /** {@inheritDoc} */
     public long getLastModified(VirtualFile mountPoint, VirtualFile target) {
         final ZipNode zipNode = getZipNode(mountPoint, target);
         if (zipNode == null) {
@@ -203,6 +209,7 @@
         return cachedFile != null ? cachedFile.lastModified() : entry == null ? zipTime : entry.getTime();
     }
 
+    /** {@inheritDoc} */
     public boolean exists(VirtualFile mountPoint, VirtualFile target) {
         final ZipNode zipNode = rootNode.find(mountPoint, target);
         if (zipNode == null) {
@@ -213,11 +220,19 @@
         }
     }
 
-    public boolean isDirectory(VirtualFile mountPoint, VirtualFile target) {
+    /** {@inheritDoc} */
+    public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) {
         final ZipNode zipNode = rootNode.find(mountPoint, target);
         return zipNode != null && zipNode.entry == null;
     }
 
+    /** {@inheritDoc} */
+    public boolean isDirectory(VirtualFile mountPoint, VirtualFile target) {
+        final ZipNode zipNode = rootNode.find(mountPoint, target);
+        return zipNode != null && zipNode.entry != null;
+    }
+
+    /** {@inheritDoc} */
     public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) {
         final ZipNode zipNode = getZipNode(mountPoint, target);
         if (zipNode == null) {
@@ -273,10 +288,12 @@
         return zipNode;
     }
 
+    /** {@inheritDoc} */
     public boolean isReadOnly() {
         return true;
     }
     
+    /** {@inheritDoc} */
     public void close() throws IOException {
         log.tracef("Closing zip filesystem %s", this);
         VFSUtils.safeClose(new Closeable() {

Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/RealFileSystem.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/RealFileSystem.java	2009-10-19 12:41:12 UTC (rev 95111)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/vfs/spi/RealFileSystem.java	2009-10-19 14:19:20 UTC (rev 95112)
@@ -115,6 +115,11 @@
         return getFile(mountPoint, target).exists();
     }
 
+    /** {@inheritDoc} */
+    public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) {
+        return getFile(mountPoint, target).isFile();
+    }
+
     /**
      * {@inheritDoc}
      */




More information about the jboss-cvs-commits mailing list