Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /smlnj-lib/trunk/Util/path-util.sml
ViewVC logotype

View of /smlnj-lib/trunk/Util/path-util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2144 - (download) (annotate)
Thu Nov 2 16:23:11 2006 UTC (12 years, 10 months ago) by blume
File size: 953 byte(s)
moved smlnj-lib to toplevel
(* path-util.sml
 *
 * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
 *
 * Various higher-level pathname and searching utilities.
 *)

structure PathUtil : PATH_UTIL =
  struct

    structure P = OS.Path
    structure F = OS.FileSys

    fun existsFile pred pathList fileName = let
	  fun chk s = if (pred s) then SOME s else NONE
	  fun iter [] = NONE
	    | iter (p::r) = (case chk(P.joinDirFile{dir=p, file=fileName})
		 of NONE => iter r
		  | res => res
		(* end case *))
	  in
	    iter pathList
	  end
    fun allFiles pred pathList fileName = let
	  fun chk s = if (pred s) then SOME s else NONE
	  fun iter ([], l) = rev l
	    | iter (p::r, l) = (case chk(P.joinDirFile{dir=p, file=fileName})
		 of NONE => iter(r, l)
		  | (SOME s) => iter(r, s::l)
		(* end case *))
	  in
	    iter (pathList, [])
	  end

    fun fileExists s = F.access(s, [])

    val findFile  = existsFile fileExists
    val findFiles = allFiles fileExists

  end;


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0