Return to Snippet

Revision: 43629
at March 28, 2011 11:59 by laurenceosx


Initial Code
def expandUserPath( aPath ) {
    def somethingToDo = aPath.trim().indexOf('~') == 0;
    if (!somethingToDo)
        return aPath; // !!!!!!!!!!!!!
        
    def pathAfterTilde = (aPath.trim() + ' ')[1..-1].trim();
                
    def home = System.getProperty('user.home')
    def fileSep = System.getProperty( 'file.separator' );
   
    def afterTildeIsSlash = pathAfterTilde.startsWith( fileSep )

    def slash = fileSep    
    if (afterTildeIsSlash)
        slash = ''
        
    def result = ( home + slash + pathAfterTilde ).trim();
    return result;
}

Initial URL


Initial Description


Initial Title
Groovy expandUserPath ~

Initial Tags
groovy

Initial Language
Groovy