提交 a24f7921 编写于 作者: K kohsuke

simplified.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4250 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cb99122b
...@@ -153,8 +153,7 @@ public final class DirectoryBrowserSupport { ...@@ -153,8 +153,7 @@ public final class DirectoryBrowserSupport {
req.setAttribute("it",this); req.setAttribute("it",this);
List<Path> parentPaths = buildParentPath(path); List<Path> parentPaths = buildParentPath(path);
req.setAttribute("parentPath",parentPaths); req.setAttribute("parentPath",parentPaths);
req.setAttribute("topPath", req.setAttribute("topPath", createBackRef(parentPaths.size()));
parentPaths.isEmpty() ? "." : repeat("../",parentPaths.size()));
req.setAttribute("files",files); req.setAttribute("files",files);
req.setAttribute("icon",icon); req.setAttribute("icon",icon);
req.setAttribute("path",path); req.setAttribute("path",path);
...@@ -209,16 +208,17 @@ public final class DirectoryBrowserSupport { ...@@ -209,16 +208,17 @@ public final class DirectoryBrowserSupport {
int current=1; int current=1;
while(tokens.hasMoreTokens()) { while(tokens.hasMoreTokens()) {
String token = tokens.nextToken(); String token = tokens.nextToken();
r.add(new Path(repeat("../",total-current),token,true,0)); r.add(new Path(createBackRef(total - current),token,true,0));
current++; current++;
} }
return r; return r;
} }
private static String repeat(String s,int times) { private static String createBackRef(int times) {
StringBuffer buf = new StringBuffer(s.length()*times); if(times==0) return ".";
StringBuffer buf = new StringBuffer(3*times);
for(int i=0; i<times; i++ ) for(int i=0; i<times; i++ )
buf.append(s); buf.append("../");
return buf.toString(); return buf.toString();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册