camlspotter avatar camlspotter committed 494b82b

removed Unix.find, replaced by Unix.Find.find

Comments (0)

Files changed (3)

 - Added (*>)
 - Unix.{file, mkdtemp, with_dtemp} added
 - Unix.mkdir is overridden
-- Added Unix.Find with poly record interface
+* Renamed Unix.find to Added Unix.Find.find with poly record interface
 
 2.1.2
 ------------
   let compare : t -> t -> int = compare
 end)
 
+module Find = struct
 
-type path = 
-    { dir : string;
-      base : string;
-      path : string; (* dir / name *)
-      stat : [ `Ok of stats | `Error of exn ];
-      depth : int;
-    }
-
-let path ~depth ~dir base =
-  let path = match Filename.concat dir base with
-    | "./." -> "."
-    | s -> s
-  in
-  { dir = dir;
-    base = base;
-    path = path;
-    depth = depth; 
-    stat = try `Ok (stat path) with e -> `Error e;
-  }
-
-
-let kind path =
-  match path.stat with
-  | `Error _exn -> None
-  | `Ok stat -> Some stat.st_kind
-
-
-let is_dir path = kind path = Some S_DIR
-let is_reg path = kind path = Some S_REG
-
-let dev_inode path =
-  match path.stat with
-  | `Ok stat -> Some (stat.st_dev, stat.st_ino)
-  | `Error _ -> None
-
-exception Prune
-
-let prune () = raise Prune
-
-let find ~f fnames =
-
-  (* visited cache *)
-  let visited = ref Inodes.empty in
-  let if_not_visited_then path ~f = match dev_inode path with
-    | None -> ()
-    | Some inode ->
-        if Inodes.mem inode !visited then ()
-        else begin
-          visited := Inodes.add inode !visited;
-          f path
-        end
-  in
-
-  let rec find_dir pth =
-    try 
-      f pth;
-      let subdirs =
-        folddir pth.path ~init:[] ~f:(fun dirs -> function
-          | "." | ".." -> dirs
-          | name -> 
-      	let pth = path ~depth:(pth.depth + 1) ~dir:pth.path name in
-      	if try is_dir pth with _ -> false then pth::dirs
-      	else begin find_non_dir pth; dirs end)
-      in
-      List.iter (if_not_visited_then ~f:find_dir) subdirs
-    with
-    | Prune -> ()
-
-  and find_non_dir path = try f path with Prune -> ()
-    (* Even if path is a dangling symlink, f path is called *)
-  in
-
-  List.iter (fun fname ->
-    let path = 
-      path ~depth: 0 ~dir:(Filename.dirname fname) (Filename.basename fname)
-    in
-    if is_dir path then find_dir path
-    else find_non_dir path) fnames
-
-
-module Find = struct
+  exception Prune
 
   class type path = object
     method base : string
 open Unix
 
-type path = 
-    { dir : string;
-      base : string;
-      path : string; (* dir / name *)
-      stat : [ `Ok of stats | `Error of exn ];
-      depth : int;
-    }
-(** for [find]. Deprecated. *)
-
-val find : f:(path -> unit) -> string list -> unit
-(** Deprecated. Use [Find.find]. *)
-
-val prune : unit -> 'exn
-(** for [find]. Deprecated. *)
-
-val is_dir : path -> bool
-(** for [find]. Deprecated. *)
-val is_reg : path -> bool
-(** for [find]. Deprecated. *)
-
 module Find : sig
 
   class type path = object
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.