let dirname path = 
    match List.rev path with
      hd :: tl ->
      List.rev tl
    | [] ->
      raise FilePathEmpty