refactor some file gathering routines to be used by ocaml dependency goal