From 6fadeb414e76a1229c2c86b625a4d71ff06f6c60 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 17 Feb 2017 15:09:51 +0100 Subject: [PATCH] add `CCIO.File.walk_l` --- src/core/CCIO.ml | 8 ++++++++ src/core/CCIO.mli | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/core/CCIO.ml b/src/core/CCIO.ml index b9c2e2d4..f48cd127 100644 --- a/src/core/CCIO.ml +++ b/src/core/CCIO.ml @@ -320,6 +320,14 @@ module File = struct ) *) + let walk_l d = + let l = ref [] in + let g = walk d in + let rec aux () = match g() with + | None -> !l + | Some x -> l := x :: !l; aux () + in aux () + type walk_item = [`File | `Dir] * t let read_dir ?(recurse=false) d = diff --git a/src/core/CCIO.mli b/src/core/CCIO.mli index 6319fb25..6d424df6 100644 --- a/src/core/CCIO.mli +++ b/src/core/CCIO.mli @@ -202,6 +202,11 @@ module File : sig symlinks, etc.) @raise Sys_error in case of error (e.g. permission denied) during iteration *) + val walk_l : t -> walk_item list + (** Same as {!walk} but returns a list (therefore it's eager and might + take some time on large directories) + @since NEXT_RELEASE *) + val show_walk_item : walk_item -> string val with_temp :