public String translatePath ( String path ) { String translated ; // special character: ~ maps to the user's home directory if ( path . startsWith ( "~" + File . separator ) ) { translated = System . getProperty ( "user.home" ) + path . substring ( 1 ) ; } else if ( path . startsWith ( "~" ) ) { String userName = path . substring ( 1 ) ; translated = new File ( new File ( System . getProperty ( "user.home" ) ) . getParent ( ) , userName ) . getAbsolutePath ( ) ; // Keep the path separator in translated or add one if no user home specified translated = userName . isEmpty ( ) || path . endsWith ( File . separator ) ? translated + File . separator : translated ; } else if ( ! new File ( path ) . isAbsolute ( ) ) { translated = ctx . getCurrentDir ( ) . getAbsolutePath ( ) + File . separator + path ; } else { translated = path ; } return translated ; }
Translate a path that has previously been unescaped and unquoted . That is called at command execution when the calue is retrieved prior to be used as ModelNode value .