## path-utilities.pkg
# Compiled by:
#
src/lib/std/standard.lib# Various higher-level pathname and searching utilities.
### "There is no royal road which leads to geometry."
###
### -- Euclid (c 323-283 BCE)
package path_utilities
: (weak) Path_Utilities # Path_Utilities is from
src/lib/src/path-utilities.api{
package p = winix__premicrothread::path; # winix__premicrothread is from
src/lib/std/winix--premicrothread.pkg package f = winix__premicrothread::file;
fun exists_file prior path_list file_name
=
iter path_list
where
fun check s
=
if (prior s ) THE s;
else NULL; fi;
fun iter []
=>
NULL;
iter (p ! r)
=>
case (check (p::make_path_from_dir_and_file { dir=>p, file=>file_name } ))
NULL => iter r;
result => result;
esac;
end;
end;
fun all_files prior path_list file_name
=
iter (path_list, [])
where
fun check s
=
if (prior s ) THE s;
else NULL; fi;
fun iter ([], l)
=>
reverse l;
iter (p ! r, l)
=>
case (check (p::make_path_from_dir_and_file { dir=>p, file=>file_name } ))
NULL => iter (r, l);
THE s => iter (r, s ! l);
esac;
end;
end;
fun file_exists s
=
f::access (s, []);
file_file = exists_file file_exists;
find_files = all_files file_exists;
};
## COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.