geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r701924 - /geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
Date Mon, 06 Oct 2008 03:30:43 GMT
Author: jdillon
Date: Sun Oct  5 20:30:42 2008
New Revision: 701924

URL: http://svn.apache.org/viewvc?rev=701924&view=rev
Log:
Helper for FileObject stuff

Added:
    geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
  (contents, props changed)
      - copied, changed from r701826, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java

Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
(from r701826, geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java&r1=701826&r2=701924&rev=701924&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
Sun Oct  5 20:30:42 2008
@@ -21,28 +21,48 @@
 
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.geronimo.gshell.command.Variables;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Provides access to VFS file systems.
+ * Utility methods for operating on {@link FileObject} instances.
  *
  * @version $Rev$ $Date$
  */
-public interface FileSystemAccess
+public class FileObjects
 {
-    String CWD = "vfs.cwd";
+    private static final Logger log = LoggerFactory.getLogger(FileObjects.class);
 
-    FileSystemManager getManager();
+    public static boolean hasChildren(final FileObject file) throws FileSystemException {
+        assert file != null;
 
-    FileObject getCurrentDirectory(Variables vars) throws FileSystemException;
-
-    FileObject getCurrentDirectory() throws FileSystemException;
-
-    void setCurrentDirectory(Variables vars, FileObject dir) throws FileSystemException;
-
-    FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException;
-
-    FileObject resolveFile(String name) throws FileSystemException;
-
-}
+        if (file.getType().hasChildren()) {
+            FileObject[] children = file.getChildren();
+            
+            if (children != null && children.length != 0) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public static void close(final FileObject file) {
+        if (file != null) {
+            try {
+                file.close();
+            }
+            catch (FileSystemException e) {
+                log.trace("Failed to close file: " + file, e);
+            }
+        }
+    }
+
+    public static void closeAll(final FileObject... files) {
+        if (files != null && files.length != 0) {
+            for (FileObject file : files) {
+                close(file);
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjects.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message