From: Sylvain LE G. <syl...@po...> - 2004-07-23 23:38:59
|
Hello, On Sat, Jul 24, 2004 at 02:01:29AM +0300, Jere Sanisalo wrote: > On Fri, Jul 23, 2004 at 10:09:32PM +0200, Nicolas Cannasse wrote: > >The Unzip module is now part of ExtLib ! > >You can deflate your TGZ and ZIP with pure OCaml code only ! > >Enjoy, > > Cool, thanks! > > I've still to see your code in the CVS (does sourceforge always have a delay > after commit for the changes to show up?) but a few questions. So you have > unzip, how about a zip? It's always handy to pack stuff as well. > > And how far does the current module go? Can it unpack whole zip files with > several files in them? > > Which brings me to another curiosity I've been having. After looking at the > ocaml core library I was missing abstract files (so I could implement my > own, given an interface). Well, Extlib has that and great. But how about an > abstract filesystem? Something along the lines of: > --- > class base_filesys : > object > method exists : string -> bool > method size : string -> int > > method chdir : string -> unit > method cwd : unit -> string > end > > class ['a] i_filesys : > object > inherit base_filesys > > method open_in : string -> 'a > end > > class ['a] o_filesys : > object > inherit base_filesys > > method delete : string -> unit > > method open_out : string -> 'a > end > > class ['a,'b] io_filesys : > object > inherit ['a] i_filesys > inherit ['b] o_filesys > end > --- > That way you could do easy wrappings for filesystems. Useful things like: > - Use a ZIP as a filesystem (input only if you please) > - Use remote filesystem > - Implement sandboxing (filesystem inside a filesystem, like prevent the > application accidentally accessing some part outside the given directory) > Well, i currently maintain a library which is called ocaml-fileutils. It implements most operation you describe for real filesystem ( size = du, exists = test Exist, cwd = pwd, delete = rm , in other word, take a look a the GNU fileutils ). I was think of implementing a tar module for navigating tar archives, and to give a model to expand it to anything else... However, i don't use object oriented design ( i don't like this kind of design )... If you are interested in generating a tar navigator, please go ahead, the library is made for extension ( if you want to extend, you will need to use the module typing of the FileUtil module ). Kind regard Sylvain Le Gall ps : http://www.carva.org/sylvain.le-gall/ocaml-fileutils.html |