ozeigermann 2004/04/21 01:27:10
Modified: webdavclient/commandline/src/java/org/apache/webdav/cmd
Client.g Client.java
Log:
Applied patch by Thomas Bernert to address issue #28499
Revision Changes Path
1.5 +18 -11
jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.g
Index: Client.g
===================================================================
RCS file:
/home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.g,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Client.g 1 Apr 2004 08:40:24 -0000 1.4
+++ Client.g 21 Apr 2004 08:27:10 -0000 1.5
@@ -440,7 +440,7 @@
exception
catch [RecognitionException ex]
{
- printUsage("lls");
+ printUsage("lls");
}
ls
@@ -1131,12 +1131,18 @@
: '-' (CHARS)+
;
-// TODO: make the flexible string like STRING:
-// '"' (~('"'|'\n'|'\r'))* '"' | (~(' '|'\n'|'\r'))+
+
+
+// Backslashes are accepted by CHARS,
+// but STRING replace them into slashes !!
STRING
- : CHARS (CHARS | '-')*
- | '"'! ( ~'"' )* '"'!
-// | '"'! ( options {greedy=false;} : . )* '"'!
+ : ( CHARS (CHARS | '-')*
+ | '"'! ( ~'"' )* '"'!
+ )
+ { String txt = $getText;
+ txt = txt.replace('\\', '/');
+ $setText(txt);
+ }
;
protected
@@ -1155,6 +1161,7 @@
| ')'
| '!'
| '+'
+ | '\\'
;
QNAME
1.12 +47 -29
jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java
Index: Client.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Client.java 19 Apr 2004 13:39:17 -0000 1.11
+++ Client.java 21 Apr 2004 08:27:10 -0000 1.12
@@ -491,27 +491,40 @@
out.println("Warning: Not found the path");
}
}
+
+ private File getFileByPath(String path) {
+
+ if (path != null) {
+ // set a new file if '\' or '/' at the begin of path
+ // or ':' at the 2nd position of path exists.
+ // if not: take the old parent entry of file and add a '/' to path.
+ return(path.startsWith("/") ||
+ path.startsWith("\\") ||
+ ((path.length() > 1) && (path.charAt(1) == ':')) ) ?
+ new File(path) :
+ new File(dir, "/"+path);
+ } else {
+ return dir;
+ }
+
+ }
+
void lcd(String path)
{
- try
- {
- out.println("lcd " + path);
- File anotherDir = (path.startsWith("/") ||
- path.startsWith("\\")) ? new File(path) :
- new File(dir.getCanonicalPath(), path);
-
- if (anotherDir.isDirectory()) {
- dir = anotherDir;
- } else {
- out.println("Warning: Not found the path");
- }
- }
- catch (IOException ex)
- {
- out.println("Warning: Not found the path");
+ File anotherDir = getFileByPath(path);
+
+ if (anotherDir.isDirectory()) {
+ dir = anotherDir;
+ } else {
+ out.println("Warning: path not found!");
}
+
+ updatePrompt(getPath());
+
}
+
+
void lls(String options, String path)
{
@@ -519,11 +532,13 @@
char option = 'F';
if ((options!=null) && (options.indexOf('l') > 0))
option = 'l';
+
+ File temp = getFileByPath(path);
+
- File temp = (path != null) ? new File(dir, path) : dir;
- if (!temp.exists()) {
- out.println("Warning: Not found the path");
- return;
+ if (!temp.exists() || !temp.isDirectory()) {
+ out.println("Warning: path not found!");
+ return;
}
String[] list = temp.list();
@@ -603,6 +618,7 @@
try {
String cdPath = checkUri(path + "/");
webdavResource.setPath(cdPath);
+
if (webdavResource.exists()) {
if (webdavResource.isCollection()) {
setPath(webdavResource.getPath());
@@ -617,14 +633,14 @@
}
catch (Exception ex) {
handleException(ex);
-
try {
- webdavResource.setPath(currentPath);
+ webdavResource.setPath(currentPath);
} catch (Exception e) {
- handleException(ex);
+ handleException(e);
}
+
}
-
+
updatePrompt(getPath());
}
@@ -1435,8 +1451,10 @@
{
StringBuffer buff = new StringBuffer();
try {
- buff.append("[" + httpURL.getHost().toUpperCase() + "] ");
- buff.append(path);
+ buff.append("[" + httpURL.getHost().toUpperCase() + ":" );
+ buff.append(path+ "] ");
+ buff.append(dir.getCanonicalPath());
+
} catch (Exception e) {
buff.append("[ Slide ]");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]