Hi Gary,
While it is true that FTP is typically thought of as a streaming rather than
random access file system, VFS does support random access reading. This is
confirmed of course by the list of capabilities and code. I have a hacked
version which supports random writing and does so using the following
strategy.
- all read
- if outputstream present flush and closeand clear
- continue with reading byte(s)
- seek
- if outputstream present flush and closeand clear
- perform seek.
- // input and output streams are clear(nulled) and will be recreated
by the next read / write
- write methods
- if outputstream is absent connect to server and restart at file
pointer position
- write byte(s).
While it appears to work, i thought there might have been some deeper
reasoning behinid the lack of inbuilt support in FtpFileProvider. After all
that the same strategy is used for reading as i have described for writing.
My code is however a mess as i have only implemented writing for some
RandomAccessContent.
If anyone is interested id be happy to share.
On Jul 20, 2011, at 0:45, "Miroslav Pokorny" <[email protected]>
> wrote:
>
> > Hiho
> >
> > I was just playing with Apache Commons VFS (thanks guys) and noticed that
> >> Ftp FileSystem< does not support random access writing as confirmed by
> > examining the capabilities.
> >
> > [LIST_CHILDREN, URI, GET_LAST_MODIFIED, RENAME, APPEND_CONTENT, DELETE,
> > GET_TYPE, RANDOM_ACCESS_READ, READ_CONTENT, WRITE_CONTENT, CREATE]
> >
> > It does however support random accesss reading and im just wondering is
> > there a particular reason why writing is not supported ?
> >
>
> Hello,
>
> The reason is probably as simple as the protocol is not a natural match for
> the feature. With FTP you stream the whole file up or down, not a random
> piece.
>
> Gary
>
> > tya
> >
> > mP
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
mP