--- mcore-src/trunk/mcore-tools/daemon/include/daemon.global.class 2012/08/13 09:42:10 2007 +++ mcore-src/trunk/mcore-tools/daemon/include/daemon.global.class 2012/08/13 09:43:26 2008 @@ -392,3 +392,52 @@ eecho "Path '${path}' does not exist. MROOT not set." fi } + +list_files_in_directory() +{ + local i + local retval + local path + local opts + local type + + # basic getops + for i in $* + do + case $1 in + -mindepth) shift; opts+=" -mindepth $1" ;; + -maxdepth) shift; opts+=" -maxdepth $1" ;; + -type) shift; type="$1" ;; + '') continue ;; + *) path="$1" ;; + esac + shift + done + + if [[ -z ${path} ]] + then + eecho "No path given." + return 1 + fi + + if [[ ! -d ${path} ]] + then + eecho "Directory '${path}' does not exist." + return 1 + fi + + # default to files + [[ -z ${type} ]] && type=f + + for i in $(find ${path} ${opts} -type ${type} | sort) + do + if [[ -z ${retval} ]] + then + retval="$(basename ${i})" + else + retval="${retval} $(basename ${i})" + fi + done + + rvecho "${retval}" +}