ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <ddevie...@gmail.com>
Subject Re: svn commit: r423009 - in /ant/core/trunk: docs/manual/CoreTasks/style.html src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java
Date Tue, 18 Jul 2006 12:55:58 GMT
>         String fileName = FileUtils.getRelativePath(baseDir, inFile);
> -        File file = new File(fileName);
> -
> +
> +        String name;
> +        String dir;
> +        int lastDirSep = fileName.lastIndexOf("/");
> +        if (lastDirSep > -1) {
> +            name = fileName.substring(lastDirSep + 1);
> +            dir  = fileName.substring(0, lastDirSep);
> +        } else {
> +            name = fileName;
> +            dir  = ".";      // so a dir+"/"+name would not result in an absolute path
> +        }
> +
>         if (fileNameParameter != null) {
> -            liaison.addParam(fileNameParameter, inFile.getName());
> +            liaison.addParam(fileNameParameter, name);
>         }
>         if (fileDirParameter != null) {
> -            liaison.addParam(fileDirParameter, (file.getParent()!=null) ? file.getParent()
: "" );
> +            liaison.addParam(fileDirParameter, dir);
>         }
>     }

FWIW, I prefered the File.getParent()/getName() version. I believe the
statement that getParent would use \ as filesep to find the parent to
be incorrect. getParent is both more explicit and shorter. But maybe
I'm missing something about getParent()? Thanks, --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message