public final String getDirectoryName ( final String property ) { String directory = properties . get ( property ) ; if ( directory == null || directory . isEmpty ( ) ) { return null ; } if ( IS_WINDOWS ) { // Windows swings both ways. If a forward slash was already used, we'll // add one at the end if missing. Otherwise use the windows default of \ if ( directory . charAt ( directory . length ( ) - 1 ) == ' ' || directory . charAt ( directory . length ( ) - 1 ) == ' ' ) { return directory ; } if ( directory . contains ( "/" ) ) { return directory + "/" ; } return directory + "\\" ; } if ( directory . contains ( "\\" ) ) { throw new IllegalArgumentException ( "Unix path names cannot contain a back slash" ) ; } if ( directory == null || directory . isEmpty ( ) ) { return null ; } if ( directory . charAt ( directory . length ( ) - 1 ) == ' ' ) { return directory ; } return directory + "/" ; }
Returns the directory name making sure the end is an OS dependent slash