commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bakary Dialaya DJIBA" <dial...@gmail.com>
Subject Re: [ understand VFS ]
Date Wed, 24 Sep 2008 08:15:24 GMT
 It works well.
Thanks.

On Wed, Sep 24, 2008 at 2:10 AM, James Carman <james@carmanconsulting.com>wrote:

> I wouldn't do any downcasting if you want it to be generic.  Use the
> FileObject API:
>
> FileObject rootDir = manager.resolveFile("sch:/");
> FileObject userFolder = rootDir.resolveFile(userName);
> userFolder.createFolder();
> FileObject userFile = userFolder.resolveFile("MyFile.txt");
> userFile.createFile();
>
> To get stuff into this "user file", you can use:
>
> File localFile = ...;
> FileObject localFileObject = manager.toFileObject(localFile);
> FileUtil.copyContent(localFileObject,userFile);
>
> On Tue, Sep 23, 2008 at 3:37 PM, Bakary Dialaya DJIBA <dialaya@gmail.com>
> wrote:
> > Hi,
> >
> > Given a FileSystem *fs* (extends abstractFS) and a FileObject *fo
> *(extends
> > AbstractFO), how can I attach the fo to the fs?
> >
> > It's a silly question. I am trying to create a provider that I'll add to
> > the default manager (of VFS). The provider is added successfully but I
> > cannot make a link between *fs* and *fo*.
> >
> > To do this I write the code below:
> >
> > DefaultFileSystemManager manager new DefaultFileSystemManager();
> > MyProvider provider = new MyProvider();
> > FileSystemOptions fileSystemOptions = new FileSystemOptions();
> >
> > manager.addProvider("sch", provider);
> > manager.init();
> >
> > CustomFileObject fo = (CustomFileObject)manager.resolveFile("sch:/");
> >
> > CustomFileName fn = new CustomFileName("sch",
> "userName",FileType.FOLDER);
> >
> > CustomFileSystem fs = new CustomFileSystem(fn,fileSystemOptions);
> > fs.attach(fo);
> > System.out.println(fo.isAttached()); // return false
> > fo.doAttach();
> > System.out.println(fo.isAttached()); // return false
> >
> >
> > My second problème is that I don't know how to set my root file system.
> And
> > also fo.getParent() throw a null pointer exception.
> >
> > Someone can tell me how to do this:
> >
> > FS
> >  |__FileObject1 ...
> >  |
> >  |__FileObject2 ...
> >
> > or give me a tutorial to understand VFS API.
> >
> > Thanks & Regards.
> >
> >
> > --
> > Bakary,
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
Bakary,

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message