'borrow' Tcl's virtual file system

I saw this in an early version of the ‘Year in scripting languages’ that
was sent out today and it sounds like a very good idea to me, perhaps we
should try to ‘borrow’ it:

"The [Tcl]8.4 release includes a number of significant features, including

  • new Virtual File System (VFS) layer that allows (in principle)
    all desired filesystem activity to be diverted away from the
    native operating system and to something else; drivers exist for
    a number of underlying “access methods”, including FTP, HTTP,
    Metakit, WebDAV, etc. "

Seems like something that wouldn’t be too difficult to do with a series of
modules. Any ideas?

BTW: This is just the sort of ‘cross-pollination’ that the ‘year in
scripting languages’ was intended to facilitate.

Phil

···


"Or perhaps the truth is less interesting than the facts?"
Amy Weiss (accusing theregister.co.uk of engaging in ‘tabloid journalism’)
Senior VP, Communications
Recording Industry Association of America

Hi,

···

In message “‘borrow’ Tcl’s virtual file system” on 03/01/09, Phil Tomson ptkwt@shell1.aracnet.com writes:

I saw this in an early version of the ‘Year in scripting languages’ that
was sent out today and it sounds like a very good idea to me, perhaps we
should try to ‘borrow’ it:

"The [Tcl]8.4 release includes a number of significant features, including

  • new Virtual File System (VFS) layer that allows (in principle)
    all desired filesystem activity to be diverted away from the
    native operating system and to something else; drivers exist for
    a number of underlying “access methods”, including FTP, HTTP,
    Metakit, WebDAV, etc. "

Seems like something that wouldn’t be too difficult to do with a series of
modules. Any ideas?

I don’t anything in detail about Tcl’s VFS, but is open-uri in the RAA

http://www.ruby-lang.org/raa/list.rhtml?name=open-uri

something close?

						matz.

Scripsit ille Phil Tomson ptkwt@shell1.aracnet.com:

I saw this in an early version of the ‘Year in scripting languages’ that
was sent out today and it sounds like a very good idea to me, perhaps we
should try to ‘borrow’ it:

"The [Tcl]8.4 release includes a number of significant features, including

  • new Virtual File System (VFS) layer that allows (in principle)
    all desired filesystem activity to be diverted away from the
    native operating system and to something else; drivers exist for
    a number of underlying “access methods”, including FTP, HTTP,
    Metakit, WebDAV, etc. "

Doesn’t that sound like Perl’s TIEHANDLE interface? Ruby shouldn’t need
such a hack because its file handles already are objects and methods of
them are called. Maybe it would be good to reimplement the IO objects
(or has that already been done?) so that any output functions
rely on simple output methods like “output a string” and “output a
character”. This way they can be extended without having to do any
formatting.

Seems like something that wouldn’t be too difficult to do with a series of
modules.

Looks like.

···


Du fingst mit Einem heimlich an,
Bald kommen ihrer mehre dran,
Und wenn dich erst ein Dutzend hat,
So hat dich auch die ganze Stadt.

Not really, matz. I haven’t used it yet myself, but let me try to explain.

The point about VFS is that anything which can open something (like the
tcl equivalent of File#open) now is “VFS” aware, i.e. it treats the local
files under a VFS (virtual file system) layer. There are implementations
to the VFS, offering different access layers to real filesystems, like ext2fs,
msdosfs, ffs, etc. Now the whole point is that it’s easy to write “plugins”
to the VFS, which implement other access methods than to the local filesystem.

That said, imagine following ruby pseudo code:

require ‘vfs’

Vfs.mount(‘type’ => ‘ftp’)
File.open(‘ftp://banzai.net/ayaken.txt’) { |f| … }

Vfs.mount(‘type’ => ‘http’)
File.open(‘http://banzai.net/ayaken.txt’) { |f| … }

Vfs.mount(‘target’ => ‘foo.tar.gz’)
Dir.chdir(‘foo.tar.gz’); Dir.[*] # => lists contents of foo.tar.gz

Vfs.mount(‘target’ => ‘ftp://banzai.net’, ‘target’ => ‘ftp://banzai.net/ayaken.tar.gz’)
Dir.chdir(‘ftp://banzai.net/ayaken.tar.gz’); Dir.[*] # => lists contents of ayaken.tar.gz on banzai.net

The point is that all ‘native’ tcl methods use the VFS, and thus you can easily
have all the ‘native’ methods use any extension.

See also the (I think a bit outdated) Tcl Wiki page which maybe gives you a
better impression of what tclvfs is about:

http://mini.net/tcl/2466

Hope that helped

-Martin

···

On Fri, Jan 10, 2003 at 05:28:02PM +0900, Yukihiro Matsumoto wrote:

[…]
I don’t anything in detail about Tcl’s VFS, but is open-uri in the RAA

http://www.ruby-lang.org/raa/list.rhtml?name=open-uri

something close?

  					matz.

I don’t think so. open-uri (according to the RAA description) is just a
wrapper around net/http and net/ftp. Tcl’s VFS is a proper virtual file
system. The VFS page on the Tcler’s Wiki might be a good place to
start:

http://mini.net/tcl/VFS

The basic idea is that when you tell Tcl that you’re using a VFS, it
secretly redirects all file I/O activity to happen to the VFS and not to
the real FS. An example of how this might “look” from Ruby might be:

require 'vfs'

VFS.open("http://www.ruby-lang.org/")

File.open("/index.html") { |f|
    f.each_line { |line| p line }
}

VFS.close

Looks a lot like open-uri, right? But, can open-uri do this:

require 'vfs'

VFS.open("/tmp/foo.gz")

Dir.mkdir("/blah")      # created inside /tmp/foo.gz!
File.open("/blah/readme.txt", "w+") { |f|
    f.puts "this is some text"
}

VFS.close

Now, Dir.mkdir and File.open silently get redirected to operate on
/tmp/foo.gz instead of the REAL underlying filesystem. So, you
get a whole “virtual” filesystem inside a single file. This makes
packaging apps and distributing them simple (one file contains many
files, that can be read/written at runtime without having to unpack
them).

Sounds a lot like what exerb does at some level …

– Dossy

···

On 2003.01.10, Yukihiro Matsumoto matz@ruby-lang.org wrote:

Hi,

In message “‘borrow’ Tcl’s virtual file system” > on 03/01/09, Phil Tomson ptkwt@shell1.aracnet.com writes:

I saw this in an early version of the ‘Year in scripting languages’ that
was sent out today and it sounds like a very good idea to me, perhaps we
should try to ‘borrow’ it:

"The [Tcl]8.4 release includes a number of significant features, including

  • new Virtual File System (VFS) layer that allows (in principle)
    all desired filesystem activity to be diverted away from the
    native operating system and to something else; drivers exist for
    a number of underlying “access methods”, including FTP, HTTP,
    Metakit, WebDAV, etc. "

Seems like something that wouldn’t be too difficult to do with a series of
modules. Any ideas?

I don’t anything in detail about Tcl’s VFS, but is open-uri in the RAA

http://www.ruby-lang.org/raa/list.rhtml?name=open-uri

something close?


Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)

In article 20030110133201.GM32764@panoptic.com,
Dossy dossy@panoptic.com writes:

Now, Dir.mkdir and File.open silently get redirected to operate on
/tmp/foo.gz instead of the REAL underlying filesystem. So, you
get a whole “virtual” filesystem inside a single file. This makes
packaging apps and distributing them simple (one file contains many
files, that can be read/written at runtime without having to unpack
them).

I think the `redirection’ can be implemented by method dispatch if we
have FileName class. Such redirection is not required to be builtin
because Ruby is object oriented.

Note that open-uri provides URI::HTTP#open and URI::FTP#open.

···


Tanaka Akira

having used tcl in the past, I know what you refer to re: the VFS. I
know this is not an optimal solution, but there is the Objective-C
class NSFileHandle which opens either files or sockets for r/w. I
assume this available thru rubycocoa, just thought Id throw this out
there for mac ppl.

brennan

···

On Friday, January 10, 2003, at 08:32 AM, Dossy wrote:

The basic idea is that when you tell Tcl that you’re using a VFS, it
secretly redirects all file I/O activity to happen to the VFS and not
to
the real FS. An example of how this might “look” from Ruby might be:

there is also a virtual file system project that works at the file system
level. i don’t recall off hand what it was called. it was recently in linux
journal i beleive. from what i read it was coming along nicely and i imagine
will make its way as a standard of distributions after a while. so having a
Ruby level version to this kind of thing may be mute, except that it Might be
cross-platform.

···

On Friday 10 January 2003 03:09 pm, Brennan Leathers wrote:

On Friday, January 10, 2003, at 08:32 AM, Dossy wrote:

The basic idea is that when you tell Tcl that you’re using a VFS, it
secretly redirects all file I/O activity to happen to the VFS and not
to
the real FS. An example of how this might “look” from Ruby might be:

having used tcl in the past, I know what you refer to re: the VFS. I
know this is not an optimal solution, but there is the Objective-C
class NSFileHandle which opens either files or sockets for r/w. I
assume this available thru rubycocoa, just thought Id throw this out
there for mac ppl.

brennan


tom sawyer, aka transami
transami@transami.net

                               .''.
   .''.      .        *''*    :_\/_:     .
  :_\/_:   _\(/_  .:.*_\/_*   : /\ :  .'.:.'.

.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.

Tom Sawyer wrote:

there is also a virtual file system project that works at the file system
level. i don’t recall off hand what it was called. it was recently in linux

That would probably be LUFS:
http://lufs.sourceforge.net/lufs/

For a library based VFS, have a look at libferris:

Ruby interfaces for either of these would kick ass.

Cheers,

Erik.

···

journal i beleive. from what i read it was coming along nicely and i imagine
will make its way as a standard of distributions after a while. so having a
Ruby level version to this kind of thing may be mute, except that it Might be
cross-platform.