(**************************************************************************)
(*                                                                        *)
     Copyright 2012 - 2015 OCamlPro                                        
     Copyright 2012 INRIA                                                
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
   GNU Lesser General Public License version 2.1 , with the special       
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

(** URL parsing and printing, with support for our different backends *)

type version_control = [ `git | `darcs | `hg ]

type backend = [ `http | `rsync | version_control ]

val string_of_backend: backend -> string

(** Tolerates lots of backward compatibility names;
    @raise Failure on unknown protocol *)
val backend_of_string: string -> [> backend]

type t = {
  transport: string; (** the part just before '://' *)
  path: string; (** the part after '://' *)
  hash: string option; (** the optional branch/ref specification,
                           at the end after a '#' *)
  backend: backend; (** the backend that opam should use to handle this
                        url *)
}

(** Same as [of_string], but allows enforcing the expected backend, and may
    otherwise guess version control from the suffix by default (for e.g.
    ). (this should be disabled when parsing from files).
    Note that [handle_suffix] also handles user-name in ssh addresses (e.g.
    "ssh:///...") *)
val parse: ?backend:backend -> ?handle_suffix:bool -> string -> t

include OpamStd.ABSTRACT with type t := t

(** Dummy filler url *)
val empty: t

* Returns the url string without the VC part ( i.e. " git+foo " returns 
     " foo " )
    "foo") *)
val base_url: t -> string

(** The last part of the url path, e.g. [""] or
    ["/"] *)
val basename: t -> string

* Returns the url with all path components but the first one ( the hostname ) 
     dropped , e.g. [ "  " ] becomes [ "  " ]
    dropped, e.g. [""] becomes [""] *)
val root: t -> t

val has_trailing_slash: t -> bool

(** Check if the URL matches an existing local directory, and return it *)
val local_dir: t -> OpamFilename.Dir.t option

(** Check if the URL matches an existing local file, and return it *)
val local_file: t -> OpamFilename.t option

(** If the given url-string has no 'transport://' specification and corresponds
    to an existing local path, check for version-control clues at that path *)
val guess_version_control: string -> [> version_control ] option

module Op: sig

* Appends at the end of an URL path with ' / ' separator . Gets back to the 
       root if the second argument starts with ' / '
      root if the second argument starts with '/' *)
  val ( / ) : t -> string -> t

end

************************************************************************
                                                                        
                                                                        
  All rights reserved. This file is distributed under the terms of the  
  exception on linking described in the file LICENSE.                   
                                                                        
************************************************************************
* URL parsing and printing, with support for our different backends 
* Tolerates lots of backward compatibility names;
    @raise Failure on unknown protocol 
* the part just before '://' 
* the part after '://' 
* the optional branch/ref specification,
                           at the end after a '#' 
* the backend that opam should use to handle this
                        url 
* Same as [of_string], but allows enforcing the expected backend, and may
    otherwise guess version control from the suffix by default (for e.g.
    ). (this should be disabled when parsing from files).
    Note that [handle_suffix] also handles user-name in ssh addresses (e.g.
    "ssh:///...") 
* Dummy filler url 
* The last part of the url path, e.g. [""] or
    ["/"] 
* Check if the URL matches an existing local directory, and return it 
* Check if the URL matches an existing local file, and return it 
* If the given url-string has no 'transport://' specification and corresponds
    to an existing local path, check for version-control clues at that path 
     Copyright 2012 - 2015 OCamlPro                                        
     Copyright 2012 INRIA                                                
   GNU Lesser General Public License version 2.1 , with the special       


type version_control = [ `git | `darcs | `hg ]

type backend = [ `http | `rsync | version_control ]

val string_of_backend: backend -> string

val backend_of_string: string -> [> backend]

type t = {
}

val parse: ?backend:backend -> ?handle_suffix:bool -> string -> t

include OpamStd.ABSTRACT with type t := t

val empty: t

* Returns the url string without the VC part ( i.e. " git+foo " returns 
     " foo " )
    "foo") *)
val base_url: t -> string

val basename: t -> string

* Returns the url with all path components but the first one ( the hostname ) 
     dropped , e.g. [ "  " ] becomes [ "  " ]
    dropped, e.g. [""] becomes [""] *)
val root: t -> t

val has_trailing_slash: t -> bool

val local_dir: t -> OpamFilename.Dir.t option

val local_file: t -> OpamFilename.t option

val guess_version_control: string -> [> version_control ] option

module Op: sig

* Appends at the end of an URL path with ' / ' separator . Gets back to the 
       root if the second argument starts with ' / '
      root if the second argument starts with '/' *)
  val ( / ) : t -> string -> t

end
