From: Sylvain LE G. <syl...@po...> - 2003-11-14 18:38:33
|
On Fri, Nov 14, 2003 at 04:01:51PM +0900, Nicolas Cannasse wrote: > [...] > > In fact, i have exactly the same module for Unix ( but i need to call it > > SysPath ). > > > > Are you interested in fusionning your module with mine ? > > > > I had also SysUtil which try to implement some common unix function ( > > find, which, mkdir, test... ) in SysUtil. > > > > I am really interested in fusioning your module with mine, because i > > want fileutils ( my module ) to be able to work on every platform. > > I agree. > Such a nice module including a lot of features for working with filesystem > and handling incompatibilites would definitly be useful. > I'm ok for merging, as long as you don't append a reference to the Unix > module : actually Path is manipulating "virtual" paths and then does not > need to rely on the filesystem function. Having some functions in other > module relying on path is ok. > > You can proceed the merge and post it on this list (including a clear MLI > interface), I'm sure there is other people here that might be interested. > > Nicolas Cannasse > > Hello, Well, all the idea i just read from this thread will be included in such a module. For now, it is very simple ( ie very simple algo ). But it works very well for Unix. I want to do Win32SysPath, MacSysPath and UnixSysPath and SysPath which will be a bind to the current platforme SysPath. For this i need an abstraction layer to compute some specific things ( path separator, drive letter et al ). I think the next version will come with a parser/lexer for each OS which will produce something like describe in the thread ( but i prefer type path = Root of string | Component of string | ParentDir | CurrentDir | Empty | Link of string * path... I don't know yet for Link because it is system dependent. I separate the module in two : - SysPath : includes all things which doesn't touch to filesystem ( that is the reason why i don't know if it is interessant to have Link ). - SysUtil : includes all things which touch the filesystem, so you have to be consistent with FS, it is also a try to imitate a lot of Unix command like find, which... For now, it has been tested and it works on Linux ( and the abstract SysPath has been tested with Linux FS syntax ). Here are the prototype : SysPath.mli : (** You cannot pass a base path which is relative *) exception Base_path_relative (** One of the path you have passed is relative and cannot be reduce *) exception Path_relative_unreducable (** All operation as defined in module Filename *) val current_dir_name : string val parent_dir_name : string val concat : string -> string -> string val is_relative : string -> bool val is_implicit : string -> bool val check_suffix : string -> string -> bool val chop_suffix : string -> string -> string val chop_extension : string -> string val basename : string -> string val dirname : string -> string val temp_file : string -> string -> string val open_temp_file : ?mode:open_flag list -> string -> string -> string * out_channel val quote : string -> string (** Take a list of path component and return the string corresponding to this path *) val implode : string list -> string (** Take a string corresponding to a path a return the component of this path *) val explode : string -> string list (** Remove all path component which are relative inside the path For example : /a/../b -> /b/. Path must not be relative *) val reduce : string -> string (** Create an absolute path from a path relative to the base path *) val make_absolute : string -> string -> string (** Create a path which is relative to the base path *) val make_relative : string -> string -> string (** Create an environnement PATH like string from different path *) val make_path : string list -> string (** Return the different component of an environnement PATH like string *) val explode_path : string -> string list SysUtil.mli : (** Pattern you can use to test file *) type test_file = Is_dev_block | Is_dev_char | Is_dir | Exists | Is_file | Is_set_group_ID | Has_sticky_bit | Is_link | Is_pipe | Is_readable | Is_writeable | Size_not_null | Is_socket | Has_set_user_ID | Is_exec | Is_owned_by_user_ID | Is_owned_by_group_ID | Is_newer_than of string * string | Is_older_than of string * string | Has_same_device_and_inode of string * string | And of test_file * test_file | Or of test_file * test_file | Not of test_file | Match of string | True | False val list_dir : string -> string list (** Apply a filtering pattern to a filename *) val filter : test_file -> string list -> string list (** Test the existence of the file... *) val test : test_file -> string -> bool (** Try to find the executable in the PATH. Use environement variable PATH if none is provided *) val which : ?path:string list -> string -> string The first functions of SysPath are simple binding to Filename. In SysUtils i have a reference to Unix ( sorry ). If you have any suggestion... This library is under developpement and has no public release yet. But if some of you are interested, i will speed up the dev in order to do a public release. Kind regard Sylvain LE GALL |