You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/03/25 20:12:31 UTC
svn commit: r159046 [2/2] - in jakarta/commons/sandbox/vfs/trunk:
src/java/org/apache/commons/vfs/ src/java/org/apache/commons/vfs/impl/
src/java/org/apache/commons/vfs/provider/
src/java/org/apache/commons/vfs/provider/compressed/
src/java/org/apache/commons/vfs/provider/ftp/
src/java/org/apache/commons/vfs/provider/http/
src/java/org/apache/commons/vfs/provider/jar/
src/java/org/apache/commons/vfs/provider/local/
src/java/org/apache/commons/vfs/provider/sftp/
src/java/org/apache/commons/vfs/provider/smb/
src/java/org/apache/commons/vfs/provider/tar/
src/java/org/apache/commons/vfs/provider/temp/
src/java/org/apache/commons/vfs/provider/url/
src/java/org/apache/commons/vfs/provider/webdav/
src/java/org/apache/commons/vfs/provider/zip/
src/test/org/apache/commons/vfs/provider/smb/test/
src/test/org/apache/commons/vfs/provider/test/
src/test/org/apache/commons/vfs/test/ xdocs/
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -26,6 +26,17 @@
public class GenericFileNameParser
extends LocalFileNameParser
{
+ private static final GenericFileNameParser INSTANCE = new GenericFileNameParser();
+
+ /**
+ * retrieve a instance to this parser
+ * @return the parser
+ */
+ public static GenericFileNameParser getInstance()
+ {
+ return INSTANCE;
+ }
+
/**
* Pops the root prefix off a URI, which has had the scheme removed.
*/
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java Fri Mar 25 11:12:17 2005
@@ -21,6 +21,7 @@
import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.RandomAccessContent;
import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.util.RandomAccessMode;
import java.io.File;
@@ -48,10 +49,10 @@
*/
protected LocalFile(final LocalFileSystem fileSystem,
final String fileName,
- final FileName name)
+ final FileName name) throws FileSystemException
{
super(name, fileSystem);
- this.fileName = fileName;
+ this.fileName = UriParser.decode(fileName);
}
/**
@@ -102,7 +103,7 @@
protected String[] doListChildren()
throws Exception
{
- return file.list();
+ return UriParser.encode(file.list());
}
/**
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.AbstractFileName;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.FileNameParser;
/**
* A local file URI.
@@ -40,37 +41,6 @@
}
/**
- * Parses an absolute file URI.
- *
- * @todo Make parser a static field
- */
- public static LocalFileName parseUri(final String uri, final boolean uriEncoded,
- final LocalFileNameParser parser)
- throws FileSystemException
- {
- final StringBuffer name = new StringBuffer();
-
- // Extract the scheme
- final String scheme = UriParser.extractScheme(uri, name);
-
- // Remove encoding, and adjust the separators
- if (uriEncoded)
- {
- UriParser.decode(name, 0, name.length());
- }
- UriParser.fixSeparators(name);
-
- // Extract the root prefix
- final String rootFile = parser.extractRootPrefix(uri, name);
-
- // Normalise the path
- UriParser.normalisePath(name);
- final String path = name.toString();
-
- return new LocalFileName(scheme, rootFile, path);
- }
-
- /**
* Returns the root file for this file.
*/
public String getRootFile()
@@ -81,7 +51,7 @@
/**
* Factory method for creating name instances.
*/
- protected FileName createName(final String path)
+ public FileName createName(final String path)
{
return new LocalFileName(getScheme(), rootFile, path);
}
@@ -94,5 +64,5 @@
buffer.append(getScheme());
buffer.append("://");
buffer.append(rootFile);
- }
+ }
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -15,8 +15,11 @@
*/
package org.apache.commons.vfs.provider.local;
+import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.AbstractFileNameParser;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.VfsComponentContext;
/**
* A name parser.
@@ -24,7 +27,7 @@
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision$ $Date$
*/
-public abstract class LocalFileNameParser
+public abstract class LocalFileNameParser extends AbstractFileNameParser
{
/**
* Determines if a name is an absolute file name.
@@ -52,4 +55,29 @@
final StringBuffer name)
throws FileSystemException;
+
+ public FileName parseUri(final VfsComponentContext context, final String filename) throws FileSystemException
+ {
+ final StringBuffer name = new StringBuffer();
+
+ // Extract the scheme
+ String scheme = UriParser.extractScheme(filename, name);
+ if (scheme == null)
+ {
+ scheme = "file";
+ }
+
+ // Remove encoding, and adjust the separators
+ UriParser.canonicalizePath(name, 0, name.length(), this);
+ UriParser.fixSeparators(name);
+
+ // Extract the root prefix
+ final String rootFile = extractRootPrefix(filename, name);
+
+ // Normalise the path
+ UriParser.normalisePath(name);
+ final String path = name.toString();
+
+ return new LocalFileName(scheme, rootFile, path);
+ }
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java Fri Mar 25 11:12:17 2005
@@ -19,7 +19,9 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSelector;
import org.apache.commons.vfs.FileSystem;
+import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.AbstractFileSystem;
+import org.apache.commons.vfs.provider.UriParser;
import java.io.File;
import java.io.FilePermission;
@@ -47,10 +49,11 @@
/**
* Creates a file object.
*/
- protected FileObject createFile(final FileName name)
+ protected FileObject createFile(final FileName name) throws FileSystemException
{
// Create the file
- final String fileName = rootFile + name.getPath();
+ String fileName = rootFile + name.getPath();
+ fileName = fileName;
return new LocalFile(this, fileName, name);
}
Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.sftp;
+
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+import org.apache.commons.vfs.provider.ftp.FtpFileNameParser;
+import org.apache.commons.vfs.provider.http.HttpFileNameParser;
+import org.apache.commons.vfs.provider.webdav.WebdavFileNameParser;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class SftpFileNameParser extends URLFileNameParser
+{
+ private final static SftpFileNameParser INSTANCE = new SftpFileNameParser();
+
+ public SftpFileNameParser()
+ {
+ super(22);
+ }
+
+ public boolean encodeCharacter(char ch)
+ {
+ return super.encodeCharacter(ch) || ch < ' ';
+ }
+
+ public static FileNameParser getInstance()
+ {
+ return INSTANCE;
+ }
+}
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java Fri Mar 25 11:12:17 2005
@@ -48,9 +48,9 @@
Capability.READ_CONTENT,
Capability.URI,
Capability.WRITE_CONTENT,
- Capability.GET_LAST_MODIFIED
- // wait for jsch release
- // Capability.SET_LAST_MODIFIED_FILE
+ Capability.GET_LAST_MODIFIED,
+ Capability.SET_LAST_MODIFIED_FILE
+// Capability.RANDOM_ACCESS_READ
}));
public final static String ATTR_USER_INFO = "UI";
@@ -60,6 +60,7 @@
public SftpFileProvider()
{
super();
+ setFileNameParser(SftpFileNameParser.getInstance());
}
/**
@@ -109,14 +110,6 @@
*/
public void init() throws FileSystemException
{
- }
-
- /**
- * Parses an absolute URI.
- */
- protected FileName parseUri(final String uri) throws FileSystemException
- {
- return GenericFileName.parseUri(uri, 22);
}
public FileSystemConfigBuilder getConfigBuilder()
Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.sftp;
+
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.AbstractRandomAccessContent;
+import org.apache.commons.vfs.util.RandomAccessMode;
+
+import java.io.DataInputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+class SftpRandomAccessContent extends AbstractRandomAccessContent
+{
+ private final SftpFileObject fileObject;
+
+ protected long filePointer = 0;
+ private DataInputStream dis = null;
+ private InputStream mis = null;
+
+ SftpRandomAccessContent(final SftpFileObject fileObject, RandomAccessMode mode)
+ {
+ super(mode);
+
+ this.fileObject = fileObject;
+ // fileSystem = (FtpFileSystem) this.fileObject.getFileSystem();
+ }
+
+ public long getFilePointer() throws IOException
+ {
+ return filePointer;
+ }
+
+ public void seek(long pos) throws IOException
+ {
+ if (pos == filePointer)
+ {
+ // no change
+ return;
+ }
+
+ if (pos < 0)
+ {
+ throw new FileSystemException("vfs.provider/random-access-invalid-position.error",
+ new Object[]
+ {
+ new Long(pos)
+ });
+ }
+ if (dis != null)
+ {
+ close();
+ }
+
+ filePointer = pos;
+ }
+
+ private void createStream() throws IOException
+ {
+ if (dis != null)
+ {
+ return;
+ }
+
+ // FtpClient client = fileSystem.getClient();
+ mis = fileObject.getInputStream(filePointer);
+ dis = new DataInputStream(new FilterInputStream(mis)
+ {
+ public int read() throws IOException
+ {
+ int ret = super.read();
+ if (ret > -1)
+ {
+ filePointer++;
+ }
+ return ret;
+ }
+
+ public int read(byte b[]) throws IOException
+ {
+ int ret = super.read(b);
+ if (ret > -1)
+ {
+ filePointer+=ret;
+ }
+ return ret;
+ }
+
+ public int read(byte b[], int off, int len) throws IOException
+ {
+ int ret = super.read(b, off, len);
+ if (ret > -1)
+ {
+ filePointer+=ret;
+ }
+ return ret;
+ }
+
+ public void close() throws IOException
+ {
+ SftpRandomAccessContent.this.close();
+ }
+ });
+ }
+
+
+ public void close() throws IOException
+ {
+ if (dis != null)
+ {
+ // mis.abort();
+ mis.close();
+
+ // this is to avoid recursive close
+ DataInputStream oldDis = dis;
+ dis = null;
+ oldDis.close();
+ mis = null;
+ }
+ }
+
+ public long length() throws IOException
+ {
+ return fileObject.getContent().getSize();
+ }
+
+ public byte readByte() throws IOException
+ {
+ createStream();
+ byte data = dis.readByte();
+ return data;
+ }
+
+ public char readChar() throws IOException
+ {
+ createStream();
+ char data = dis.readChar();
+ return data;
+ }
+
+ public double readDouble() throws IOException
+ {
+ createStream();
+ double data = dis.readDouble();
+ return data;
+ }
+
+ public float readFloat() throws IOException
+ {
+ createStream();
+ float data = dis.readFloat();
+ return data;
+ }
+
+ public int readInt() throws IOException
+ {
+ createStream();
+ int data = dis.readInt();
+ return data;
+ }
+
+ public int readUnsignedByte() throws IOException
+ {
+ createStream();
+ int data = dis.readUnsignedByte();
+ return data;
+ }
+
+ public int readUnsignedShort() throws IOException
+ {
+ createStream();
+ int data = dis.readUnsignedShort();
+ return data;
+ }
+
+ public long readLong() throws IOException
+ {
+ createStream();
+ long data = dis.readLong();
+ return data;
+ }
+
+ public short readShort() throws IOException
+ {
+ createStream();
+ short data = dis.readShort();
+ return data;
+ }
+
+ public boolean readBoolean() throws IOException
+ {
+ createStream();
+ boolean data = dis.readBoolean();
+ return data;
+ }
+
+ public int skipBytes(int n) throws IOException
+ {
+ createStream();
+ int data = dis.skipBytes(n);
+ return data;
+ }
+
+ public void readFully(byte b[]) throws IOException
+ {
+ createStream();
+ dis.readFully(b);
+ }
+
+ public void readFully(byte b[], int off, int len) throws IOException
+ {
+ createStream();
+ dis.readFully(b, off, len);
+ }
+
+ public String readUTF() throws IOException
+ {
+ createStream();
+ String data = dis.readUTF();
+ return data;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ createStream();
+ return dis;
+ }
+}
\ No newline at end of file
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,8 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.GenericFileName;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.AbstractFileProvider;
+import org.apache.commons.vfs.provider.FileNameParser;
/**
* An SMB URI. Adds a share name to the generic URI.
@@ -33,7 +35,7 @@
private final String share;
- private SmbFileName(final String scheme,
+ protected SmbFileName(final String scheme,
final String hostName,
final int port,
final String userName,
@@ -46,42 +48,6 @@
}
/**
- * Parses an SMB URI.
- */
- public static SmbFileName parseUri(final String uri)
- throws FileSystemException
- {
- final StringBuffer name = new StringBuffer();
-
- // Extract the scheme and authority parts
- final Authority auth = extractToPath(uri, name);
-
- // Decode and adjust separators
- UriParser.decode(name, 0, name.length());
- UriParser.fixSeparators(name);
-
- // Extract the share
- final String share = UriParser.extractFirstElement(name);
- if (share == null || share.length() == 0)
- {
- throw new FileSystemException("vfs.provider.smb/missing-share-name.error", uri);
- }
-
- // Normalise the path. Do this after extracting the share name,
- // to deal with things like smb://hostname/share/..
- UriParser.normalisePath(name);
- final String path = name.toString();
-
- return new SmbFileName(auth.scheme,
- auth.hostName,
- auth.port,
- auth.userName,
- auth.password,
- share,
- path);
- }
-
- /**
* Returns the share name.
*/
public String getShare()
@@ -102,7 +68,7 @@
/**
* Factory method for creating name instances.
*/
- protected FileName createName(final String path)
+ public FileName createName(final String path)
{
return new SmbFileName(getScheme(),
getHostName(),
Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.smb;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.VfsComponentContext;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class SmbFileNameParser extends URLFileNameParser
+{
+ private final static SmbFileNameParser INSTANCE = new SmbFileNameParser();
+
+ public SmbFileNameParser()
+ {
+ super(139);
+ }
+
+ public static FileNameParser getInstance()
+ {
+ return INSTANCE;
+ }
+
+ public FileName parseUri(final VfsComponentContext context, final String filename) throws FileSystemException
+ {
+ final StringBuffer name = new StringBuffer();
+
+ // Extract the scheme and authority parts
+ final Authority auth = extractToPath(filename, name);
+
+ // Decode and adjust separators
+ UriParser.canonicalizePath(name, 0, name.length(), this);
+ UriParser.fixSeparators(name);
+
+ // Extract the share
+ final String share = UriParser.extractFirstElement(name);
+ if (share == null || share.length() == 0)
+ {
+ throw new FileSystemException("vfs.provider.smb/missing-share-name.error", filename);
+ }
+
+ // Normalise the path. Do this after extracting the share name,
+ // to deal with things like smb://hostname/share/..
+ UriParser.normalisePath(name);
+ final String path = name.toString();
+
+ return new SmbFileName(auth.scheme,
+ auth.hostName,
+ auth.port,
+ auth.userName,
+ auth.password,
+ share,
+ path);
+ }
+}
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java Fri Mar 25 11:12:17 2005
@@ -25,6 +25,7 @@
import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.RandomAccessContent;
import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.util.RandomAccessMode;
import java.io.InputStream;
@@ -45,10 +46,10 @@
private SmbFile file;
protected SmbFileObject(final FileName name,
- final SmbFileSystem fileSystem)
+ final SmbFileSystem fileSystem) throws FileSystemException
{
super(name, fileSystem);
- this.fileName = name.getURI();
+ this.fileName = UriParser.decode(name.getURI());
}
/**
@@ -113,7 +114,7 @@
*/
protected String[] doListChildren() throws Exception
{
- return file.list();
+ return UriParser.encode(file.list());
}
/**
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java Fri Mar 25 11:12:17 2005
@@ -56,15 +56,7 @@
public SmbFileProvider()
{
super();
- }
-
- /**
- * Parses a URI.
- */
- protected FileName parseUri(final String uri)
- throws FileSystemException
- {
- return SmbFileName.parseUri(uri);
+ setFileNameParser(SmbFileNameParser.getInstance());
}
/**
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystem.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.AbstractFileSystem;
import java.util.Collection;
@@ -41,7 +42,7 @@
/**
* Creates a file object.
*/
- protected FileObject createFile(final FileName name)
+ protected FileObject createFile(final FileName name) throws FileSystemException
{
return new SmbFileObject(name, this);
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileName.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.LayeredFileName;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.FileNameParser;
/**
* A parser for Tar file names.
@@ -28,10 +29,8 @@
*/
public class TarFileName extends LayeredFileName
{
- private static final char[] TAR_URL_RESERVED_CHARS = {'!'};
-
public TarFileName(final String scheme,
- final String tarFileUri,
+ final FileName tarFileUri,
final String path)
{
super(scheme, tarFileUri, path);
@@ -42,67 +41,20 @@
*/
protected void appendRootUri(final StringBuffer buffer)
{
+ /*
buffer.append(getScheme());
buffer.append(":");
- UriParser.appendEncoded(buffer, getOuterUri(), TAR_URL_RESERVED_CHARS);
+ UriParser.appendEncoded(buffer, getOuterName().getURI(), TAR_URL_RESERVED_CHARS);
buffer.append("!");
+ */
}
/**
* Factory method for creating name instances.
*/
- protected FileName createName(final String path)
- {
- return new TarFileName(getScheme(), getOuterUri(), path);
- }
-
- /**
- * Parses a Tar URI.
- */
- public static TarFileName parseUri(final String uri)
- throws FileSystemException
+ public FileName createName(final String path)
{
- final StringBuffer name = new StringBuffer();
-
- // Extract the scheme
- final String scheme = UriParser.extractScheme(uri, name);
-
- // Extract the Tar file URI
- final String tarUri = extractTarName(name);
-
- // Decode and normalise the path
- UriParser.decode(name, 0, name.length());
- UriParser.normalisePath(name);
- final String path = name.toString();
-
- return new TarFileName(scheme, tarUri, path);
+ return null;
}
- /**
- * Pops the root prefix off a URI, which has had the scheme removed.
- */
- private static String extractTarName(final StringBuffer uri)
- throws FileSystemException
- {
- // Looking for <name>!<abspath>
- int maxlen = uri.length();
- int pos = 0;
- for (; pos < maxlen && uri.charAt(pos) != '!'; pos++)
- {
- }
-
- // Extract the name
- String prefix = uri.substring(0, pos);
- if (pos < maxlen)
- {
- uri.delete(0, pos + 1);
- }
- else
- {
- uri.setLength(0);
- }
-
- // Decode the name
- return UriParser.decode(prefix);
- }
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileObject.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileObject.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileObject.java Fri Mar 25 11:12:17 2005
@@ -76,7 +76,7 @@
/**
* Attaches a child
*/
- public void attachChild(FileName childName)
+ protected void attachChild(FileName childName)
{
children.add(childName.getBaseName());
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java Fri Mar 25 11:12:17 2005
@@ -23,6 +23,8 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
import org.apache.commons.vfs.provider.FileProvider;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.LayeredFileName;
import java.util.Arrays;
import java.util.Collection;
@@ -51,17 +53,6 @@
}
/**
- * Parses an absolute URI.
- *
- * @param uri The URI to parse.
- */
- protected FileName parseUri(final String uri)
- throws FileSystemException
- {
- return TarFileName.parseUri(uri);
- }
-
- /**
* Creates a layered file system. This method is called if the file system
* is not cached.
*
@@ -75,7 +66,7 @@
throws FileSystemException
{
final FileName rootName =
- new TarFileName(scheme, file.getName().getURI(), FileName.ROOT_PATH);
+ new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
return new TarFileSystem(rootName, file, fileSystemOptions);
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileSystem.java Fri Mar 25 11:12:17 2005
@@ -28,6 +28,7 @@
import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.AbstractFileSystem;
import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.provider.bzip2.Bzip2FileObject;
import java.io.File;
@@ -86,7 +87,7 @@
TarEntry entry;
while ((entry = getTarFile().getNextEntry()) != null)
{
- FileName name = getRootName().resolveName(entry.getName());
+ FileName name = getFileSystemManager().resolveName(getRootName(), UriParser.encode(entry.getName()));
// Create the file
TarFileObject fileObj;
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java Fri Mar 25 11:12:17 2005
@@ -93,7 +93,6 @@
// Parse the name
final StringBuffer buffer = new StringBuffer(uri);
final String scheme = UriParser.extractScheme(uri, buffer);
- UriParser.decode(buffer, 0, buffer.length());
UriParser.normalisePath(buffer);
final String path = buffer.toString();
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,8 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.LayeredFileName;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.AbstractFileProvider;
+import org.apache.commons.vfs.provider.FileNameParser;
/**
* A parser for Zip file names.
@@ -29,7 +31,7 @@
public class UrlFileName extends LayeredFileName
{
public UrlFileName(final String scheme,
- final String zipFileUri,
+ final FileName zipFileUri,
final String path)
{
super(scheme, zipFileUri, path);
@@ -43,21 +45,22 @@
buffer.append(getScheme());
buffer.append(":");
// buffer.append("!");
- UriParser.appendEncoded(buffer, getOuterUri(), null);
+ buffer.append(getOuterName().getURI());
}
/**
* Factory method for creating name instances.
*/
- protected FileName createName(final String path)
+ public FileName createName(final String path)
{
- return new UrlFileName(getScheme(), getOuterUri(), path);
+ return new UrlFileName(getScheme(), getOuterName(), path);
}
/**
* Parses a Zip URI.
*/
- public static UrlFileName parseUri(final String uri)
+ /*
+ public static UrlFileName parseUri(final FileNameParser fileNameParser, final String uri)
throws FileSystemException
{
final StringBuffer name = new StringBuffer();
@@ -66,19 +69,23 @@
final String scheme = UriParser.extractScheme(uri, name);
// Extract the Zip file URI
- final String zipUri = extractZipName(name);
+ final String zipUriName = extractZipName(name);
+ FileName zipUri = parseUri(fileNameParser, zipUriName);
// Decode and normalise the path
UriParser.decode(name, 0, name.length());
+ UriParser.canonicalizePath(name, 0, name.length(), fileNameParser);
UriParser.normalisePath(name);
final String path = name.toString();
return new UrlFileName(scheme, zipUri, path);
}
+ */
/**
* Pops the root prefix off a URI, which has had the scheme removed.
*/
+ /*
private static String extractZipName(final StringBuffer uri)
throws FileSystemException
{
@@ -105,5 +112,5 @@
// Decode the name
return UriParser.decode(prefix);
*/
- }
+ // }
}
Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.webdav;
+
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class WebdavFileNameParser extends URLFileNameParser
+{
+ private final static WebdavFileNameParser INSTANCE = new WebdavFileNameParser();
+
+ public WebdavFileNameParser()
+ {
+ super(80);
+ }
+
+ public boolean encodeCharacter(char ch)
+ {
+ return super.encodeCharacter(ch) || ch < ' ';
+ }
+
+ public static FileNameParser getInstance()
+ {
+ return INSTANCE;
+ }
+}
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java Fri Mar 25 11:12:17 2005
@@ -24,6 +24,7 @@
import org.apache.commons.vfs.NameScope;
import org.apache.commons.vfs.provider.AbstractFileObject;
import org.apache.commons.vfs.provider.GenericFileName;
+import org.apache.commons.vfs.provider.UriParser;
import org.apache.commons.vfs.util.MonitorOutputStream;
import org.apache.webdav.lib.BaseProperty;
import org.apache.webdav.lib.WebdavResource;
@@ -97,7 +98,9 @@
if (resource == null)
{
final GenericFileName name = (GenericFileName) getName();
- HttpURL url = new HttpURL(name.getUserName(), name.getPassword(), name.getHostName(), name.getPort(), name.getPath());
+ // HttpURL url = new HttpURL(name.getHostName(), name.getPort(), name.getPath());
+ HttpURL url = new HttpURL(name.getUserName(), name.getPassword(), name.getHostName(), name.getPort(), name.getPathDecoded());
+ url.setEscapedPath(name.getPath());
resource = new WebdavResource(fileSystem.getClient())
{
};
@@ -132,7 +135,7 @@
}
// handle the (maybe) redirected url
redirectionResolved = true;
- resource.getHttpURL().setPath(optionsMethod.getPath());
+ resource.getHttpURL().setEscapedPath(optionsMethod.getPath());
setAllowedMethods(optionsMethod.getAllowedMethods());
boolean exists = false;
@@ -284,7 +287,16 @@
{
WebdavResource dav = children[i];
- WebdavFileObject fo = (WebdavFileObject) getFileSystem().resolveFile(getName().resolveName(dav.getName(), NameScope.CHILD));
+ /*
+ WebdavFileObject fo = (WebdavFileObject) getFileSystem().resolveFile(
+ getName().resolveName(
+ UriParser.encode(dav.getName()), NameScope.CHILD));
+ */
+ WebdavFileObject fo = (WebdavFileObject) getFileSystem().resolveFile(
+ getFileSystem().getFileSystemManager().resolveName(
+ getName(),
+ UriParser.encode(dav.getName()),
+ NameScope.CHILD));
fo.setDavResource(dav, false);
vfs[i] = fo;
@@ -299,7 +311,7 @@
protected void doCreateFolder() throws Exception
{
// Adjust resource path
- resource.getHttpURL().setPath(getName().getPath() + '/');
+ resource.getHttpURL().setEscapedPath(getName().getPath() + '/');
final boolean ok = resource.mkcolMethod();
if (!ok)
{
@@ -315,7 +327,7 @@
*/
protected void doDelete() throws Exception
{
- final boolean ok = resource.deleteMethod(getName().getPath() /*url.getPath()*/);
+ final boolean ok = resource.deleteMethod(getName().getPathDecoded() /*url.getPath()*/);
if (!ok)
{
throw new FileSystemException("vfs.provider.webdav/delete-file.error", resource.getStatusMessage());
@@ -390,7 +402,7 @@
final ByteArrayOutputStream outstr = (ByteArrayOutputStream) out;
// Adjust the resource path (this file object may have been a folder)
- resource.getHttpURL().setPath(getName().getPath());
+ resource.getHttpURL().setEscapedPath(getName().getPath());
final boolean ok = resource.putMethod(outstr.toByteArray());
if (!ok)
{
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java Fri Mar 25 11:12:17 2005
@@ -54,15 +54,8 @@
public WebdavFileProvider()
{
super();
- }
- /**
- * Parses an abolute URI.
- */
- protected FileName parseUri(final String uri)
- throws FileSystemException
- {
- return GenericFileName.parseUri(uri, 80);
+ setFileNameParser(WebdavFileNameParser.getInstance());
}
/**
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.LayeredFileName;
import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.FileNameParser;
/**
* A parser for Zip file names.
@@ -32,7 +33,7 @@
private static final char[] ZIP_URL_RESERVED_CHARS = {'!'};
public ZipFileName(final String scheme,
- final String zipFileUri,
+ final FileName zipFileUri,
final String path)
{
super(scheme, zipFileUri, path);
@@ -45,65 +46,15 @@
{
buffer.append(getScheme());
buffer.append(":");
- UriParser.appendEncoded(buffer, getOuterUri(), ZIP_URL_RESERVED_CHARS);
+ buffer.append(getOuterName().getURI());
buffer.append("!");
}
/**
* Factory method for creating name instances.
*/
- protected FileName createName(final String path)
+ public FileName createName(final String path)
{
- return new ZipFileName(getScheme(), getOuterUri(), path);
- }
-
- /**
- * Parses a Zip URI.
- */
- public static ZipFileName parseUri(final String uri)
- throws FileSystemException
- {
- final StringBuffer name = new StringBuffer();
-
- // Extract the scheme
- final String scheme = UriParser.extractScheme(uri, name);
-
- // Extract the Zip file URI
- final String zipUri = extractZipName(name);
-
- // Decode and normalise the path
- UriParser.decode(name, 0, name.length());
- UriParser.normalisePath(name);
- final String path = name.toString();
-
- return new ZipFileName(scheme, zipUri, path);
- }
-
- /**
- * Pops the root prefix off a URI, which has had the scheme removed.
- */
- private static String extractZipName(final StringBuffer uri)
- throws FileSystemException
- {
- // Looking for <name>!<abspath>
- int maxlen = uri.length();
- int pos = 0;
- for (; pos < maxlen && uri.charAt(pos) != '!'; pos++)
- {
- }
-
- // Extract the name
- String prefix = uri.substring(0, pos);
- if (pos < maxlen)
- {
- uri.delete(0, pos + 1);
- }
- else
- {
- uri.setLength(0);
- }
-
- // Decode the name
- return UriParser.decode(prefix);
+ return new ZipFileName(getScheme(), getOuterName(), path);
}
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java Fri Mar 25 11:12:17 2005
@@ -23,6 +23,8 @@
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
import org.apache.commons.vfs.provider.FileProvider;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.LayeredFileName;
import java.util.Arrays;
import java.util.Collection;
@@ -55,17 +57,6 @@
}
/**
- * Parses an absolute URI.
- *
- * @param uri The URI to parse.
- */
- protected FileName parseUri(final String uri)
- throws FileSystemException
- {
- return ZipFileName.parseUri(uri);
- }
-
- /**
* Creates a layered file system. This method is called if the file system
* is not cached.
*
@@ -79,7 +70,7 @@
throws FileSystemException
{
final FileName rootName =
- new ZipFileName(scheme, file.getName().getURI(), FileName.ROOT_PATH);
+ new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
return new ZipFileSystem(rootName, file, fileSystemOptions);
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java Fri Mar 25 11:12:17 2005
@@ -26,6 +26,7 @@
import org.apache.commons.vfs.VfsLog;
import org.apache.commons.vfs.provider.AbstractFileSystem;
import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
import java.io.File;
import java.io.IOException;
@@ -82,7 +83,7 @@
while (entries.hasMoreElements())
{
ZipEntry entry = (ZipEntry) entries.nextElement();
- FileName name = getRootName().resolveName(entry.getName());
+ FileName name = getFileSystemManager().resolveName(getRootName(), UriParser.encode(entry.getName()));
// Create the file
ZipFileObject fileObj;
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/smb/test/FileNameTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/smb/test/FileNameTestCase.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/smb/test/FileNameTestCase.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/smb/test/FileNameTestCase.java Fri Mar 25 11:12:17 2005
@@ -18,6 +18,7 @@
import org.apache.commons.AbstractVfsTestCase;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.smb.SmbFileName;
+import org.apache.commons.vfs.provider.smb.SmbFileNameParser;
/**
* Some additional SMB file name test cases.
@@ -34,7 +35,7 @@
public void testParseUri() throws Exception
{
// Simple name
- SmbFileName name = SmbFileName.parseUri("smb://hostname/share/file");
+ SmbFileName name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://hostname/share/file");
assertEquals("smb", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -47,7 +48,7 @@
assertEquals("smb://hostname/share/file", name.getURI());
// Name with port
- name = SmbFileName.parseUri("smb://hostname:9090/share/file");
+ name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://hostname:9090/share/file");
assertEquals("smb", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -59,7 +60,7 @@
assertEquals("smb://hostname:9090/share/file", name.getURI());
// Name with no path
- name = SmbFileName.parseUri("smb://hostname/share");
+ name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://hostname/share");
assertEquals("smb", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -71,7 +72,7 @@
assertEquals("smb://hostname/share/", name.getURI());
// Name with username
- name = SmbFileName.parseUri("smb://user@hostname/share/file");
+ name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://user@hostname/share/file");
assertEquals("smb", name.getScheme());
assertEquals("user", name.getUserName());
assertNull(name.getPassword());
@@ -83,7 +84,7 @@
assertEquals("smb://user@hostname/share/file", name.getURI());
// Name with extension
- name = SmbFileName.parseUri("smb://user@hostname/share/file.txt");
+ name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://user@hostname/share/file.txt");
assertEquals("smb", name.getScheme());
assertEquals("user", name.getUserName());
assertNull(name.getPassword());
@@ -97,7 +98,7 @@
assertEquals("smb://user@hostname/share/file.txt", name.getURI());
// Name look likes extension, but isnt
- name = SmbFileName.parseUri("smb://user@hostname/share/.bashrc");
+ name = (SmbFileName) SmbFileNameParser.getInstance().parseUri(null, "smb://user@hostname/share/.bashrc");
assertEquals("smb", name.getScheme());
assertEquals("user", name.getUserName());
assertNull(name.getPassword());
@@ -148,7 +149,7 @@
{
try
{
- SmbFileName.parseUri(uri);
+ SmbFileNameParser.getInstance().parseUri(null, uri);
fail();
}
catch (final FileSystemException e)
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/test/GenericFileNameTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/test/GenericFileNameTestCase.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/test/GenericFileNameTestCase.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/test/GenericFileNameTestCase.java Fri Mar 25 11:12:17 2005
@@ -18,6 +18,8 @@
import org.apache.commons.AbstractVfsTestCase;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.provider.GenericFileName;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+import org.apache.commons.vfs.provider.local.GenericFileNameParser;
/**
* Some GenericFileName test cases.
@@ -33,8 +35,9 @@
*/
public void testParseUri() throws Exception
{
+ URLFileNameParser urlParser = new URLFileNameParser(21);
// Simple name
- GenericFileName name = GenericFileName.parseUri("ftp://hostname/file", 21);
+ GenericFileName name = (GenericFileName) urlParser.parseUri(null, "ftp://hostname/file");
assertEquals("ftp", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -46,7 +49,7 @@
assertEquals("ftp://hostname/file", name.getURI());
// Name with port
- name = GenericFileName.parseUri("ftp://hostname:9090/file", 21);
+ name = (GenericFileName) urlParser.parseUri(null, "ftp://hostname:9090/file");
assertEquals("ftp", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -57,7 +60,7 @@
assertEquals("ftp://hostname:9090/file", name.getURI());
// Name with no path
- name = GenericFileName.parseUri("ftp://hostname", 21);
+ name = (GenericFileName) urlParser.parseUri(null, "ftp://hostname");
assertEquals("ftp", name.getScheme());
assertNull(name.getUserName());
assertNull(name.getPassword());
@@ -68,7 +71,7 @@
assertEquals("ftp://hostname/", name.getURI());
// Name with username
- name = GenericFileName.parseUri("ftp://user@hostname/file", 21);
+ name = (GenericFileName) urlParser.parseUri(null, "ftp://user@hostname/file");
assertEquals("ftp", name.getScheme());
assertEquals("user", name.getUserName());
assertNull(name.getPassword());
@@ -79,7 +82,7 @@
assertEquals("ftp://user@hostname/file", name.getURI());
// Name with username and password
- name = GenericFileName.parseUri("ftp://user:password@hostname/file", 21);
+ name = (GenericFileName) urlParser.parseUri(null, "ftp://user:password@hostname/file");
assertEquals("ftp", name.getScheme());
assertEquals("user", name.getUserName());
assertEquals("password", name.getPassword());
@@ -90,7 +93,7 @@
assertEquals("ftp://user:password@hostname/file", name.getURI());
// Encoded username and password
- name = GenericFileName.parseUri("ftp://%75ser%3A:%40@hostname", 21);
+ name = (GenericFileName) urlParser.parseUri(null, "ftp://%75ser%3A:%40@hostname");
assertEquals("ftp", name.getScheme());
assertEquals("user:", name.getUserName());
assertEquals("@", name.getPassword());
@@ -133,7 +136,7 @@
{
try
{
- GenericFileName.parseUri(uri, 21);
+ GenericFileNameParser.getInstance().parseUri(null, uri);
fail();
}
catch (final FileSystemException e)
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java Fri Mar 25 11:12:17 2005
@@ -256,6 +256,7 @@
// Build the expected structure
final FileInfo base = new FileInfo(getReadFolder().getName().getBaseName(), FileType.FOLDER);
base.addFile("file1.txt", FILE1_CONTENT);
+ base.addFile("file%25.txt", FILE1_CONTENT);
base.addFile("empty.txt", "");
base.addFolder("emptydir");
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java Fri Mar 25 11:12:17 2005
@@ -235,7 +235,7 @@
{
if (tempDir.exists())
{
- assertTrue(assertMsg, tempDir.isDirectory() && tempDir.list().length == 0);
+ assertTrue(assertMsg + " (" + tempDir.getAbsolutePath() + ")", tempDir.isDirectory() && tempDir.list().length == 0);
}
}
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ContentTests.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ContentTests.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ContentTests.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ContentTests.java Fri Mar 25 11:12:17 2005
@@ -56,7 +56,7 @@
final FileInfo fileInfo = (FileInfo) iterator.next();
final FileObject child = folder.resolveFile(fileInfo.baseName, NameScope.CHILD);
- assertTrue(child.exists());
+ assertTrue(child.getName().toString(), child.exists());
if (fileInfo.type == FileType.FILE)
{
assertSameContent(fileInfo.content, child);
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/NamingTests.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/NamingTests.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/NamingTests.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/NamingTests.java Fri Mar 25 11:12:17 2005
@@ -69,23 +69,23 @@
// Encode "some file"
FileObject file = getManager().resolveFile("%73%6f%6d%65%20%66%69%6c%65");
- assertEquals(path + "/some file", file.getName().getPath());
+ assertEquals(path + "/some file", file.getName().getPathDecoded());
// Encode "."
file = getManager().resolveFile("%2e");
- assertEquals(path, file.getName().getPath());
+ assertEquals(path + "/.", file.getName().getPathDecoded());
// Encode '%'
file = getManager().resolveFile("a%25");
- assertEquals(path + "/a%", file.getName().getPath());
+ assertEquals(path + "/a%", file.getName().getPathDecoded());
// Encode /
file = getManager().resolveFile("dir%2fchild");
- assertEquals(path + "/dir/child", file.getName().getPath());
+ assertEquals(path + "/dir/child", file.getName().getPathDecoded());
// Encode \
file = getManager().resolveFile("dir%5cchild");
- assertEquals(path + "/dir/child", file.getName().getPath());
+ assertEquals(path + "/dir\\child", file.getName().getPathDecoded());
// Use "%" literal
try
@@ -146,7 +146,7 @@
{
final FileName baseName = getReadFolder().getName();
final String basePath = baseName.getPath();
- final FileName name = baseName.resolveName("some-child", NameScope.CHILD);
+ final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD);
// Test path is absolute
assertTrue("is absolute", basePath.startsWith("/"));
@@ -216,17 +216,17 @@
throws Exception
{
// Try the supplied name
- FileName name = baseName.resolveName(relName, scope);
+ FileName name = getManager().resolveName(baseName, relName, scope);
assertEquals(expectedPath, name.getPath());
// Replace the separators
relName.replace('\\', '/');
- name = baseName.resolveName(relName, scope);
+ name = getManager().resolveName(baseName, relName, scope);
assertEquals(expectedPath, name.getPath());
// And again
relName.replace('/', '\\');
- name = baseName.resolveName(relName, scope);
+ name = getManager().resolveName(baseName, relName, scope);
assertEquals(expectedPath, name.getPath());
}
@@ -341,7 +341,7 @@
checkAbsoluteNames(name);
// Test against some unknown file
- name = name.resolveName("a/b/unknown");
+ name = getManager().resolveName(name, "a/b/unknown");
checkAbsoluteNames(name);
}
@@ -377,7 +377,7 @@
{
try
{
- name.resolveName(relName, scope);
+ getManager().resolveName(name, relName, scope);
fail("expected failure");
}
catch (FileSystemException e)
@@ -394,7 +394,7 @@
final FileName baseName = getReadFolder().getName();
String path = "/test1/test2";
- FileName name = baseName.resolveName(path);
+ FileName name = getManager().resolveName(baseName, path);
assertEquals(path, name.getPath());
// Try child and descendent names
@@ -425,7 +425,7 @@
// Test against root
path = "/";
- name = baseName.resolveName(path);
+ name = getManager().resolveName(baseName, path);
assertEquals(path, name.getPath());
// Try child and descendent names (against root)
@@ -443,7 +443,7 @@
final String relPath)
throws Exception
{
- final FileName expectedName = baseName.resolveName(relPath);
+ final FileName expectedName = getManager().resolveName(baseName, relPath);
// Convert to relative path, and check
final String actualRelPath = baseName.getRelativeName(expectedName);
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java Fri Mar 25 11:12:17 2005
@@ -117,6 +117,17 @@
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
+ // Create direct child of the test folder - special name
+ file = scratchFolder.resolveFile("file1%25.txt");
+ assertTrue(!file.exists());
+ file.createFile();
+ assertTrue(file.exists());
+ assertSame(FileType.FILE, file.getType());
+ assertEquals(0, file.getContent().getSize());
+ assertFalse(file.isHidden());
+ assertTrue(file.isReadable());
+ assertTrue(file.isWriteable());
+
// Create a descendant, where the intermediate folders don't exist
file = scratchFolder.resolveFile("dir1/dir1/file1.txt");
assertTrue(!file.exists());
@@ -195,12 +206,19 @@
// Set-up the test structure
FileObject folder = createScratchFolder();
folder.resolveFile("file1.txt").createFile();
+ folder.resolveFile("file%25.txt").createFile();
folder.resolveFile("emptydir").createFolder();
folder.resolveFile("dir1/file1.txt").createFile();
folder.resolveFile("dir1/dir2/file2.txt").createFile();
// Delete a file
FileObject file = folder.resolveFile("file1.txt");
+ assertTrue(file.exists());
+ file.delete(Selectors.SELECT_ALL);
+ assertTrue(!file.exists());
+
+ // Delete a special name file
+ file = folder.resolveFile("file%25.txt");
assertTrue(file.exists());
file.delete(Selectors.SELECT_ALL);
assertTrue(!file.exists());
Modified: jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/UrlTests.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/UrlTests.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/UrlTests.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/UrlTests.java Fri Mar 25 11:12:17 2005
@@ -17,10 +17,12 @@
import org.apache.commons.vfs.Capability;
import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.MalformedURLException;
/**
* URL test cases for providers.
@@ -54,7 +56,15 @@
assertEquals(file.getName().getURI(), url.toExternalForm());
- final URL parentURL = new URL(url, "..");
+ final URL parentURL;
+ try
+ {
+ parentURL = new URL(url, "..");
+ }
+ catch (MalformedURLException e)
+ {
+ throw e;
+ }
assertEquals(file.getParent().getURL(), parentURL);
final URL rootURL = new URL(url, "/");
Modified: jakarta/commons/sandbox/vfs/trunk/xdocs/filesystems.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/xdocs/filesystems.xml?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/xdocs/filesystems.xml (original)
+++ jakarta/commons/sandbox/vfs/trunk/xdocs/filesystems.xml Fri Mar 25 11:12:17 2005
@@ -40,6 +40,25 @@
</ul>
</section>
+ <section name="Naming">
+
+ <p>All filenames are treated as URIs. One of the consequences of this is you have to encode the '%'
+ character using <code>%25</code>. <br />
+ Depending on the filesystem additional characters are encoded if needet. This is done automatically, but
+ might be reflected in the filename.
+ </p>
+
+ <p>
+ <b>Examples</b>
+ </p>
+ <ul>
+ <li>
+ <code>file:///somedir/some%25file.txt</code>
+ </li>
+ </ul>
+
+ </section>
+
<section name="Local Files">
<p>Provides access to the files on the local physical file system.</p>
@@ -112,13 +131,9 @@
<p>
Where
<code>zip-file-uri</code> refers to a file of any
- supported type, including other zip files. Note that any
- ! characters in
- <code>
- <i>zip-file-uri</i>
- </code> must be escaped
- using
- <code>%21</code>.
+ supported type, including other zip files. Note: if you would like
+ to use the ! as normal character it must be escaped
+ using <code>%21</code>.
</p>
<p>
@@ -132,7 +147,10 @@
<code>zip:http://somehost/downloads/somefile.zip</code>
</li>
<li>
- <code>jar:zip:outer.zip%21/nested.jar!/somedir</code>
+ <code>jar:zip:outer.zip!/nested.jar!/somedir</code>
+ </li>
+ <li>
+ <code>jar:zip:outer.zip!/nested.jar!/some%21dir</code>
</li>
</ul>
Modified: jakarta/commons/sandbox/vfs/trunk/xdocs/index.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/xdocs/index.xml?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/xdocs/index.xml (original)
+++ jakarta/commons/sandbox/vfs/trunk/xdocs/index.xml Fri Mar 25 11:12:17 2005
@@ -45,6 +45,19 @@
</ul>
</section>
+
+ <section name="News">
+ <p>2005-03 - imario@apache.org: The filename parsing and api has changed.
+ <ul>
+ <li>Now it is needet to encode the '%' sign using '%25'</li>
+ <li>It is no longer needet to encode the '!' sign when using nested archives (tar, jar, ...).<br />
+ Now you <u>can</u> encode it if you would like to use it in your filename</li>
+ <li>It is no longer needet to double-encode the filename when using layered names. <code>tar:tar:file:///</code></li>
+ <li>Depending on the filesystem special characters in your filename could automatically be encoded</li>
+ <li><code>FileName.resolveName(...)</code> has been moved to <code>FileSystemManager.resolveName(...)</code></li>
+ </ul>
+ </p>
+ </section>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org