@@ -106,15 +106,15 @@ private static class Space {
106106 Space (String name ) {
107107 this .name = name ;
108108 long [] sizes = new long [4 ];
109- if (Platform .isWindows () & isCDDrive (name )) {
109+ if (Platform .isWindows () && isCDDrive (name )) {
110110 try {
111111 getCDDriveSpace (name , sizes );
112112 } catch (IOException e ) {
113113 e .printStackTrace ();
114114 throw new RuntimeException ("can't get CDDrive sizes" );
115115 }
116116 } else {
117- if (getSpace0 (name , sizes ))
117+ if (getSpace (name , sizes ))
118118 System .err .println ("WARNING: total space is estimated" );
119119 }
120120 this .size = sizes [0 ];
@@ -184,7 +184,7 @@ private static void compare(Space s) {
184184
185185 out .format ("%s (%d):%n" , s .name (), s .size ());
186186 String fmt = " %-4s total = %12d free = %12d usable = %12d%n" ;
187- String method = Platform .isWindows () & isCDDrive (s .name ()) ? "getCDDriveSpace" : "getSpace0 " ;
187+ String method = Platform .isWindows () && isCDDrive (s .name ()) ? "getCDDriveSpace" : "getSpace " ;
188188 out .format (fmt , method , s .total (), s .free (), s .available ());
189189 out .format (fmt , "getXSpace" , ts , fs , us );
190190
@@ -336,7 +336,7 @@ private static int testFile(Path dir) {
336336 private static int testVolumes () {
337337 out .println ("--- Testing volumes" );
338338 // Find all of the partitions on the machine and verify that the sizes
339- // returned by File::getXSpace are equivalent to those from getSpace0 or getCDDriveSpace
339+ // returned by File::getXSpace are equivalent to those from getSpace or getCDDriveSpace
340340 ArrayList <String > l ;
341341 try {
342342 l = paths ();
@@ -412,6 +412,19 @@ public static void main(String[] args) throws Exception {
412412
413413 private static native boolean isCDDrive (String root );
414414
415+ private static boolean getSpace (String root , long [] space ) {
416+ try {
417+ return getSpace0 (root , space );
418+ } catch (RuntimeException e ) {
419+ File f = new File (root );
420+ boolean exists = f .exists ();
421+ boolean readable = f .canRead ();
422+ System .err .printf ("getSpace0 failed for %s (%s, %s)%n" ,
423+ root , exists , readable );
424+ throw e ;
425+ }
426+ }
427+
415428 private static void getCDDriveSpace (String root , long [] sizes )
416429 throws IOException {
417430 String [] cmd = new String [] {"df" , "-k" , "-P" , root };
0 commit comments