private String stripBasedirToken( String s ) { if ( s != null ) { String basedirExpr = null; for ( String expression : BASEDIR_EXPRESSIONS ) { if ( s.startsWith( expression ) ) { basedirExpr = expression; break; } } if ( basedirExpr != null ) { if ( s.length() > basedirExpr.length() ) { // Take out basedir expression and the leading slash s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) ); } else { s = "."; } } } return s; }
/** * {@inheritDoc} */ public String unalignFromBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } path = path.trim(); String base = basedir.getAbsolutePath(); if ( path.startsWith( base ) ) { path = chopLeadingFileSeparator( path.substring( base.length() ) ); } if ( !new File( path ).isAbsolute() ) { path = path.replace( '\\', '/' ); } return path; }
s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) );
public String unalignFromBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } path = path.trim(); String base = basedir.getAbsolutePath(); if ( path.startsWith( base ) ) { path = chopLeadingFileSeparator( path.substring( base.length() ) ); } if ( path.length() <= 0 ) { path = "."; } if ( !new File( path ).isAbsolute() ) { path = path.replace( '\\', '/' ); } return path; }