You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christoph Spielmann <sp...@gmail.com> on 2006/04/26 14:24:16 UTC
[VFS] questions
HI everybody!
I have been playing around with VFS for a few days now because i have to
do a presentation about the jakarta commons projects on Friday in a
open-source software class i'm attending.
The prof said that we should concentrate on actual programming examples
so i tried to create a simple VFS-Program but i don't seem to be able to...
If i understood the sense of a VFS correctly i *should* be able to do
this with commons VFS:
1. I create a FileSystemManager-Object:
this.defFSManager=new DefaultFileSystemManager();
this.defFSManager.addProvider("file", new DefaultLocalFileProvider());
this.defFSManager.addProvider("zip", new ZipFileProvider());
this.defFSManager.addProvider("tar", new TarFileProvider());
this.defFSManager.addProvider("http",new HttpFileProvider());
this.defFSManager.init();
(i tried it with this.defFSManager=VFS.getManager(); too but that
didn't change a thing...)
2. I create a VirtualFileSystem-Object:
this.virtFS=(VirtualFileSystem)this.defFSManager.createVirtualFileSystem("vfs://").getFileSystem();
3. I add a junction ("mount" a filesystem (a zip-file) if i understood
it correctly in terms of commons-vfs):
File zipFile = new File("/mnt/downloads/gimp-2.2.8-i586-setup.zip");
FileObject zipFileObject = this.defFSManager.toFileObject(zipFile);
this.virtFS.addJunction("/"+zipFile.getName(),this.defFSManager.resolveFile("zip:"+
zipFileObject+"!/"));
So far everything works as expected and i should have the following
Virtual File System (again if i am correct maybe i completely
misunderstood VFS):
vfs://
+--gimp-2.2.8-i586-setup.zip/
But now i'm out of ideas:
I wanted to write a method that accepts a FileObject as Parameter,
prints out the Filename) and then gets the children of the
FileObject-Parameter (if it has any) and calls the method again
recursively (so i would like to traverse my vfs-tree) but no matter what
i do i can't get the children of the root of my virtual filesystem. I
always get the following Exception:
org.apache.commons.vfs.FileSystemException: Could not list the contents
of folder "vfs:///". But that has to be possible somehow???!?
I would appreciate any idea how to get the children of the vfs-root!
Regards,
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [VFS] questions
Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Christoph!
> I
> always get the following Exception:
> org.apache.commons.vfs.FileSystemException: Could not list the contents
> of folder "vfs:///". But that has to be possible somehow???!?
>
It looks like the "virtual file system" part of VFS isnt widely used and
the test coverage in this area need some "enhancements ;-) ".
If fixed some problems with it now and now your use case show work (again).
I tested it with the following code:
FileObject foVfs =
VFS.getManager().createVirtualFileSystem("vfs://");
VirtualFileSystem fsVfs = (VirtualFileSystem) foVfs.getFileSystem();
FileObject foTar =
VFS.getManager().resolveFile("tar:file:/home/im/tmp/log4j.tar!/");
fsVfs.addJunction("mytar", foTar);
list(foVfs);
Please try the next nightly or svn head.
Thanks!
Ciao,
Mario
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org