factor out check_file function
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org
Acked-by: Amit Kucheria <amit.kucheria@linaro.org>
diff --git a/include/functions.sh b/include/functions.sh
index 6702cb2..bff8e13 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -194,13 +194,20 @@
return 0
}
+check_file() {
+ local file=$1
+ local dir=$2
+
+ check "'$file' exists" "test -f" $dir/$file
+}
+
check_cpufreq_files() {
local dirpath=$CPU_PATH/$1/cpufreq
shift 1
for i in $@; do
- check "$i exists" "test -f" $dirpath/$i || return 1
+ check_file $i $dirpath || return 1
done
return 0
@@ -211,7 +218,7 @@
local dirpath=$CPU_PATH
for i in $@; do
- check "$i exists" "test -f" $dirpath/$i || return 1
+ check_file $i $dirpath || return 1
done
return 0
@@ -223,7 +230,7 @@
shift 1
for i in $@; do
- check "$i exists" "test -f" $dirpath/$i || return 1
+ check_file $i $dirpath || return 1
done
return 0