@@ -294,13 +294,16 @@ long freeSpaceOS(final String path, final int os, final boolean kb, final long t
294294 * @throws IOException if an error occurs
295295 */
296296 long freeSpaceWindows (String path , final long timeout ) throws IOException {
297- path = FilenameUtils .normalize (path , false );
298- if (path .length () > 0 && path .charAt (0 ) != '"' ) {
299- path = "\" " + path + "\" " ;
297+ String normPath = FilenameUtils .normalize (path , false );
298+ if (normPath == null ) {
299+ throw new IllegalArgumentException (path );
300+ }
301+ if (normPath .length () > 0 && normPath .charAt (0 ) != '"' ) {
302+ normPath = "\" " + normPath + "\" " ;
300303 }
301304
302305 // build and run the 'dir' command
303- final String [] cmdAttribs = new String [] {"cmd.exe" , "/C" , "dir /a /-c " + path };
306+ final String [] cmdAttribs = new String [] {"cmd.exe" , "/C" , "dir /a /-c " + normPath };
304307
305308 // read in the output of the command to an ArrayList
306309 final List <String > lines = performCommand (cmdAttribs , Integer .MAX_VALUE , timeout );
@@ -312,13 +315,13 @@ long freeSpaceWindows(String path, final long timeout) throws IOException {
312315 for (int i = lines .size () - 1 ; i >= 0 ; i --) {
313316 final String line = lines .get (i );
314317 if (line .length () > 0 ) {
315- return parseDir (line , path );
318+ return parseDir (line , normPath );
316319 }
317320 }
318321 // all lines are blank
319322 throw new IOException (
320323 "Command line 'dir /-c' did not return any info " +
321- "for path '" + path + "'" );
324+ "for path '" + normPath + "'" );
322325 }
323326
324327 /**
0 commit comments