You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/02/16 21:54:26 UTC

svn commit: r1245174 - /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java

Author: dblevins
Date: Thu Feb 16 20:54:25 2012
New Revision: 1245174

URL: http://svn.apache.org/viewvc?rev=1245174&view=rev
Log:
tweaks to not use asserts

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java?rev=1245174&r1=1245173&r2=1245174&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java Thu Feb 16 20:54:25 2012
@@ -75,29 +75,35 @@ public class Files {
         return accepted;
     }
 
-    public static void exists(File file, String s) {
+    public static File exists(File file, String s) {
         if (!file.exists()) throw new RuntimeException(s + " does not exist: " + file.getAbsolutePath());
+        return file;
     }
 
-    public static void dir(File file) {
+    public static File dir(File file) {
         if (!file.isDirectory()) throw new RuntimeException("Not a directory: " + file.getAbsolutePath());
+        return file;
     }
 
-    public static void file(File file) {
+    public static File file(File file) {
         if (!file.isFile()) throw new RuntimeException("Not a file: " + file.getAbsolutePath());
+        return file;
     }
 
-    public static void writable(File file) {
+    public static File writable(File file) {
         if (!file.canWrite()) throw new RuntimeException("Not writable: " + file.getAbsolutePath());
+        return file;
     }
 
-    public static void readable(File file) {
+    public static File readable(File file) {
         if (!file.canRead()) throw new RuntimeException("Not readable: " + file.getAbsolutePath());
+        return file;
     }
 
-    public static void mkdir(File file) {
-        if (file.exists()) return;
+    public static File mkdir(File file) {
+        if (file.exists()) return file;
         if (!file.mkdirs()) throw new RuntimeException("Cannot mkdir: " + file.getAbsolutePath());
+        return file;
     }
 
     public static File tmpdir() {
@@ -112,20 +118,21 @@ public class Files {
         }
     }
 
-    public static void mkparent(File file) {
+    public static File mkparent(File file) {
         mkdirs(file.getParentFile());
+        return file;
     }
 
-    public static void mkdirs(File file) {
+    public static File mkdirs(File file) {
 
         if (!file.exists()) {
 
-            assert file.mkdirs() : "mkdirs " + file;
+            if (file.mkdirs()) throw new RuntimeException("Cannot mkdirs: " + file.getAbsolutePath());
 
-            return;
+            return file;
         }
 
-        assert file.isDirectory() : "not a directory" + file;
+        return dir(file);
     }