commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r321346 - in /jakarta/commons/proper/io/trunk: RELEASE-NOTES.txt project.xml src/java/org/apache/commons/io/FileSystemUtils.java src/test/org/apache/commons/io/FileSystemUtilsTestCase.java
Date Sat, 15 Oct 2005 15:13:36 GMT
Author: scolebourne
Date: Sat Oct 15 08:13:27 2005
New Revision: 321346

URL: http://svn.apache.org/viewcvs?rev=321346&view=rev
Log:
Switch to using dir /-c in FileSystemUtils.freeSpace for French locale
bug 37027, from Thomas Ledoux

Modified:
    jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
    jakarta/commons/proper/io/trunk/project.xml
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileSystemUtils.java
    jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileSystemUtilsTestCase.java

Modified: jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt?rev=321346&r1=321345&r2=321346&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt (original)
+++ jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt Sat Oct 15 08:13:27 2005
@@ -30,6 +30,8 @@
 
 Bug fixes from 1.1
 ------------------
+- FileSystemUtils.freeSpace(drive)
+  Fix to allow Windows based command to function in French locale
 
 
 Enhancements from 1.1

Modified: jakarta/commons/proper/io/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/project.xml?rev=321346&r1=321345&r2=321346&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/project.xml (original)
+++ jakarta/commons/proper/io/trunk/project.xml Sat Oct 15 08:13:27 2005
@@ -175,6 +175,9 @@
       <name>Chris Eldredge</name>
     </contributor>
     <contributor>
+      <name>Thomas Ledoux</name>
+    </contributor>
+    <contributor>
       <name>Andy Lehane</name>
     </contributor>
     <contributor>

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileSystemUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileSystemUtils.java?rev=321346&r1=321345&r2=321346&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileSystemUtils.java (original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileSystemUtils.java Sat
Oct 15 08:13:27 2005
@@ -34,6 +34,7 @@
  *
  * @author Frank W. Zammetti
  * @author Stephen Colebourne
+ * @author Thomas Ledoux
  * @version $Id$
  * @since Commons IO 1.1
  */
@@ -163,7 +164,7 @@
         }
 
         // build and run the 'dir' command
-        String[] cmdAttrbs = new String[] {"cmd.exe", "/C", "dir /c " + path};
+        String[] cmdAttrbs = new String[] {"cmd.exe", "/C", "dir /-c " + path};
 
         // read in the output of the command to an ArrayList
         BufferedReader in = null;

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileSystemUtilsTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileSystemUtilsTestCase.java?rev=321346&r1=321345&r2=321346&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileSystemUtilsTestCase.java
(original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/FileSystemUtilsTestCase.java
Sat Oct 15 08:13:27 2005
@@ -38,7 +38,7 @@
         TestRunner.run(suite());
         
 //        try {
-//            System.out.println(FileSystemUtils.getFreeSpace("C:\\"));
+//            System.out.println(FileSystemUtils.freeSpace("C:\\"));
 //        } catch (IOException ex) {
 //            ex.printStackTrace();
 //        }
@@ -112,7 +112,9 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception {
+    public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes() throws Exception {
+        // this is the format of response when calling dir /c
+        // we have now switched to dir /-c, so we should never get this
         String lines =
             " Volume in drive C is HDD\n" +
             " Volume Serial Number is XXXX-YYYY\n" +
@@ -128,7 +130,30 @@
         final StringReader reader = new StringReader(lines);
         FileSystemUtils fsu = new FileSystemUtils() {
             protected BufferedReader openProcessStream(String[] params) {
-                assertEquals("dir /c ", params[2]);
+                return new BufferedReader(reader);
+            }
+        };
+        assertEquals(41411551232L, fsu.freeSpaceWindows(""));
+    }
+
+    //-----------------------------------------------------------------------
+    public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception {
+        String lines =
+            " Volume in drive C is HDD\n" +
+            " Volume Serial Number is XXXX-YYYY\n" +
+            "\n" +
+            " Directory of C:\\Documents and Settings\\Xxxx\n" +
+            "\n" +
+            "19/08/2005  22:43    <DIR>          .\n" +
+            "19/08/2005  22:43    <DIR>          ..\n" +
+            "11/08/2005  01:07                81 build.properties\n" +
+            "17/08/2005  21:44    <DIR>          Desktop\n" +
+            "               7 File(s)         180260 bytes\n" +
+            "              10 Dir(s)     41411551232 bytes free";
+        final StringReader reader = new StringReader(lines);
+        FileSystemUtils fsu = new FileSystemUtils() {
+            protected BufferedReader openProcessStream(String[] params) {
+                assertEquals("dir /-c ", params[2]);
                 return new BufferedReader(reader);
             }
         };
@@ -146,12 +171,12 @@
             "19/08/2005  22:43    <DIR>          ..\n" +
             "11/08/2005  01:07                81 build.properties\n" +
             "17/08/2005  21:44    <DIR>          Desktop\n" +
-            "               7 File(s)        180,260 bytes\n" +
-            "              10 Dir(s)  41,411,551,232 bytes free";
+            "               7 File(s)         180260 bytes\n" +
+            "              10 Dir(s)     41411551232 bytes free";
         final StringReader reader = new StringReader(lines);
         FileSystemUtils fsu = new FileSystemUtils() {
             protected BufferedReader openProcessStream(String[] params) {
-                assertEquals("dir /c C:", params[2]);
+                assertEquals("dir /-c C:", params[2]);
                 return new BufferedReader(reader);
             }
         };
@@ -169,12 +194,12 @@
             "19/08/2005  22:43    <DIR>          ..\n" +
             "11/08/2005  01:07                81 build.properties\n" +
             "17/08/2005  21:44    <DIR>          Desktop\n" +
-            "               7 File(s)        180,260 bytes\n" +
-            "              10 Dir(s)  41,411,551,232 bytes free";
+            "               7 File(s)         180260 bytes\n" +
+            "              10 Dir(s)     41411551232 bytes free";
         final StringReader reader = new StringReader(lines);
         FileSystemUtils fsu = new FileSystemUtils() {
             protected BufferedReader openProcessStream(String[] params) {
-                assertEquals("dir /c C:", params[2]);
+                assertEquals("dir /-c C:", params[2]);
                 return new BufferedReader(reader);
             }
         };



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message