Salome HOME
Merge GUI developments from BR_GUI
[tools/hxx2salome.git] / CppExamples / COMPO_CXX_SRC / rfind
diff --git a/CppExamples/COMPO_CXX_SRC/rfind b/CppExamples/COMPO_CXX_SRC/rfind
new file mode 100755 (executable)
index 0000000..4d41b44
--- /dev/null
@@ -0,0 +1,46 @@
+#! /bin/sh
+
+#
+# Usage : rfind dir suffix ...
+# 
+# find all files *suffix in dir in a recursive way
+# different of the usual command find ...
+#
+
+if test $# != 2 ; then
+    echo "Usage : $0 dir suffix"
+    exit
+fi
+
+local_find() {
+    # if the first argument is not a directory, returns
+    if test ! -d $1 ; then 
+       # echo "$1 is not a directory"
+       return 
+    fi
+    # dont look in the CVS directories
+    # dont look in the autom4te* directories
+    case "$1" in
+       */CVS) return ;;
+       */autom4te*) return ;;
+       *) ;;
+    esac
+    # for each regular file contained in the directory
+    # test if it's a *"$2" file
+    for i in $1/*
+    do
+       if test -f $i ; then
+           case `basename $i` in 
+               *$2) echo "     "$i ;;
+               *) ;;
+           esac
+       fi
+    done
+    # for each subdirectory of the first argument, proceeds recursively
+    for i in $1/*
+    do
+       local_find $i $2
+    done
+}
+
+local_find $1 $2