VFS Questions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

VFS Questions

Mark Fortner
I've been working on some Swing components that would use VFS to handle
basic file operations, and I have a few questions about the API.

   1. I seem to recall a swing package with components such as a
      FileChooser that had been created a while back, but I don't see
      them in the HEAD.  Have they been removed for some reason?
   2. The FileObject doesn't seem to support for some of the methods
      that the java.io.File object has such as length(), isFile(),
      isDirectory(), getLastModified().  Are there any plans to add
      these methods?  I found the rather obscure FileType approach to
      handling (isFile and isDirectory) rather cumbersome and it would
      be nice to have these methods in the FileObject.
   3. What is FileContentInfo?  There are a number of different types of
      files that support different metadata.  Is this meant as a
      universal interface to allow the user to grab that information?
      If so, are there any examples where this is used?  It would be
      very useful to have, at a minimum, basic support for EXIF
      metadata, MP3 metadata, PDF metadata and Office file metadata.
   4. I'd like to be able to rename a file.  But I don't see a very
      straightforward way of doing it.  There's a move method, and a
      canBeRenamedTo method, but nothing that explicitly allows me to
      rename the file and that takes a string.  This might be added to
      FileUtil if you want to keep the current API the same.
   5. There doesn't seem to be an easy way to "select" a file.  For
      example, if you are creating a table model and you want to display
      a checkbox to indicate that the file is selected, there isn't a
      method like "isSelected" to determine if the file is currently
      selected.

Mark Fortner

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Valerio
Hi Mark

2006/1/2, Mark Fortner <[hidden email]>:
>
>
>    4. I'd like to be able to rename a file.  But I don't see a very
>       straightforward way of doing it.  There's a move method, and a
>       canBeRenamedTo method, but nothing that explicitly allows me to
>       rename the file and that takes a string.  This might be added to
>       FileUtil if you want to keep the current API the same.


my 2 cents:

    // File (or directory) with old name
    File file = new File(*"oldname"*);

    // File (or directory) with new name
    File file2 = new File(*"newname"*);

    // Rename file (or directory)
    boolean success = file.renameTo(file2);
    if (!success) {
        // File was not successfully renamed
    }

hope it helps.

cheers,
valerio

   5. There doesn't seem to be an easy way to "select" a file.  For

>       example, if you are creating a table model and you want to display
>       a checkbox to indicate that the file is selected, there isn't a
>       method like "isSelected" to determine if the file is currently
>       selected.
>
> Mark Fortner
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
To Iterate is Human, to Recurse, Divine
James O. Coplien, Bell Labs
Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Mark Fortner
Valerio,
Thanks for the input, however, I'm trying to use the VFS library to
handle the file operations.  This would allow me to rename files sitting
on NFS volumes, or WebDAV volumes.  The example you gave me was for the
java.io.File object which would only work for local files.

Thanks anyway,

Mark

Valerio Schiavoni wrote:

>Hi Mark
>
>2006/1/2, Mark Fortner <[hidden email]>:
>  
>
>>   4. I'd like to be able to rename a file.  But I don't see a very
>>      straightforward way of doing it.  There's a move method, and a
>>      canBeRenamedTo method, but nothing that explicitly allows me to
>>      rename the file and that takes a string.  This might be added to
>>      FileUtil if you want to keep the current API the same.
>>    
>>
>
>
>my 2 cents:
>
>    // File (or directory) with old name
>    File file = new File(*"oldname"*);
>
>    // File (or directory) with new name
>    File file2 = new File(*"newname"*);
>
>    // Rename file (or directory)
>    boolean success = file.renameTo(file2);
>    if (!success) {
>        // File was not successfully renamed
>    }
>
>hope it helps.
>
>cheers,
>valerio
>
>   5. There doesn't seem to be an easy way to "select" a file.  For
>  
>
>>      example, if you are creating a table model and you want to display
>>      a checkbox to indicate that the file is selected, there isn't a
>>      method like "isSelected" to determine if the file is currently
>>      selected.
>>
>>Mark Fortner
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>>    
>>
>
>
>--
>To Iterate is Human, to Recurse, Divine
>James O. Coplien, Bell Labs
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

anton huber-2
In reply to this post by Mark Fortner
Hi Mark!

   ad 2.:
      length() -> fileObject.getContent().getSize()
      isFile() -> fileObject.getType()==FileType.FILE
      isDirectory() -> fileObject.getType()==FileType.FOLDER
      getLastModified() -> fileObject.getContent().getLastModifiedTime()

   ad 4.: rename:
            long lastModTime =
sourceFileObject.getContent().getLastModifiedTime();
            if (!sourceFileObject.canRenameTo(targetFileObject)){ // other
device
                targetFileObject.copyFrom(sourceFileObject,
Selectors.SELECT_SELF);
                sourceFileObject.delete(Selectors.SELECT_SELF);
             } else { // same device
                sourceFileObject.moveTo(targetFileObject);
            }
            targetFileObject.getContent().setLastModifiedTime(lastModTime);

   ad 5.: Is this realy a matter of VFS ?


Hope it helps.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Mark Fortner
Anton,
Thanks for the examples.

As for point #5.  IMO VFS shouldn't be relegated to the server.  In
reality there are a limited number of use cases where I would want to
use VFS on a server.  But I can think of plenty of reasons to want a
better file management API on the desktop.  Being able to indicate that
a file is selected is an essential part of that.

If there's another way of indicating a file is selected, please let me know.

Thanks again,

Mark

anton huber wrote:

> Hi Mark!
>
>   ad 2.:
>      length() -> fileObject.getContent().getSize()
>      isFile() -> fileObject.getType()==FileType.FILE
>      isDirectory() -> fileObject.getType()==FileType.FOLDER
>      getLastModified() -> fileObject.getContent().getLastModifiedTime()
>
>   ad 4.: rename:
>            long lastModTime =
> sourceFileObject.getContent().getLastModifiedTime();
>            if (!sourceFileObject.canRenameTo(targetFileObject)){ //
> other device
>                targetFileObject.copyFrom(sourceFileObject,
> Selectors.SELECT_SELF);
>                sourceFileObject.delete(Selectors.SELECT_SELF);
>             } else { // same device
>                sourceFileObject.moveTo(targetFileObject);
>            }
>            
> targetFileObject.getContent().setLastModifiedTime(lastModTime);
>
>   ad 5.: Is this realy a matter of VFS ?
>
>
> Hope it helps.
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Robert Enyedi
Mark,

The concept of file selection is specific to the application that works with
files. Just like file coloring attributes and font are. For instance, what
file selection information do you think that a command line application
needs? I think that none. So why have it in the API first of all?

Please note that VFS is just a library that provides a file abstraction
layer to transparently handle various kinds of file systems. That's all what
it does. And it does it well...

Regards,
Robert

On 1/3/06, Mark Fortner <[hidden email]> wrote:

>
> Anton,
> Thanks for the examples.
>
> As for point #5.  IMO VFS shouldn't be relegated to the server.  In
> reality there are a limited number of use cases where I would want to
> use VFS on a server.  But I can think of plenty of reasons to want a
> better file management API on the desktop.  Being able to indicate that
> a file is selected is an essential part of that.
>
> If there's another way of indicating a file is selected, please let me
> know.
>
> Thanks again,
>
> Mark
>
> anton huber wrote:
>
> > Hi Mark!
> >
> >   ad 2.:
> >      length() -> fileObject.getContent().getSize()
> >      isFile() -> fileObject.getType()==FileType.FILE
> >      isDirectory() -> fileObject.getType()==FileType.FOLDER
> >      getLastModified() -> fileObject.getContent().getLastModifiedTime()
> >
> >   ad 4.: rename:
> >            long lastModTime =
> > sourceFileObject.getContent().getLastModifiedTime();
> >            if (!sourceFileObject.canRenameTo(targetFileObject)){ //
> > other device
> >                targetFileObject.copyFrom(sourceFileObject,
> > Selectors.SELECT_SELF);
> >                sourceFileObject.delete(Selectors.SELECT_SELF);
> >             } else { // same device
> >                sourceFileObject.moveTo(targetFileObject);
> >            }
> >
> > targetFileObject.getContent().setLastModifiedTime(lastModTime);
> >
> >   ad 5.: Is this realy a matter of VFS ?
> >
> >
> > Hope it helps.
> >
> > _________________________________________________________________
> > FREE pop-up blocking with the new MSN Toolbar - get it now!
> > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Marc Palmer Local
In reply to this post by anton huber-2

On 2 Jan 2006, at 21:59, anton huber wrote:

> Hi Mark!
>
>   ad 2.:
>      length() -> fileObject.getContent().getSize()
>      isFile() -> fileObject.getType()==FileType.FILE
>      isDirectory() -> fileObject.getType()==FileType.FOLDER
>      getLastModified() -> fileObject.getContent
> ().getLastModifiedTime()
>

Note that the latter will not work if you get a URL from the  
fileObject and it is a local file system as in this example.

i.e.

URL u = fileObject.getUrl();
long lastmod = u.openConnection().getLastModified()

... lastmod is always zero. This has been raised as a bugzilla issue.

~ ~ ~
Marc Palmer ([hidden email])
Consultant/Analyst
AnyWare Ltd.
http://www.anyware.co.uk/


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Mario Ivankovits
In reply to this post by anton huber-2
Hi!

I am back from vacation now, so lets start ...

>   ad 4.: rename:
>            long lastModTime =
> sourceFileObject.getContent().getLastModifiedTime();
>            if (!sourceFileObject.canRenameTo(targetFileObject)){ //
> other device
>                targetFileObject.copyFrom(sourceFileObject,
> Selectors.SELECT_SELF);
>                sourceFileObject.delete(Selectors.SELECT_SELF);
>             } else { // same device
>                sourceFileObject.moveTo(targetFileObject);
>            }
>            
> targetFileObject.getContent().setLastModifiedTime(lastModTime);
Its sufficient to call moveTo in either case, moveTo will already handle
the different filesystem case and get/set the lastModifiedTime if
supported by the filesystem.

So:
sourceFileObject.moveTo(targetFileObject);

do the job.


Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: VFS Questions

Mario Ivankovits
In reply to this post by Mark Fortner
Hi!
>   1. I seem to recall a swing package with components such as a
>      FileChooser that had been created a while back, but I don't see
>      them in the HEAD.  Have they been removed for some reason?
I am not aware that we have had such a package in the past.
>   3. What is FileContentInfo?  There are a number of different types of
>      files that support different metadata.
Where possible this is to get informations about the file content like
contentType and contentEncoding.
Depending on the filesystem they will be determined using the file
extension (contentType) or the content-type header in case of http.
>      If so, are there any examples where this is used?  It would be
>      very useful to have, at a minimum, basic support for EXIF
>      metadata, MP3 metadata, PDF metadata and Office file metadata.
This is what the new "services" (or whatever name it will have) tries to
address. It will be possible to lookup the all possible services for a
given file.


---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]