xref: /aosp_15_r20/tools/aadevtools/validation/get_file_dir.sh (revision b32fbb6340ee6fe4a25d7b39d84085c084465677)
1*b32fbb63SXin Li#!/bin/bash
2*b32fbb63SXin Li
3*b32fbb63SXin Li# Copyright (C) 2021 The Android Open Source Project
4*b32fbb63SXin Li#
5*b32fbb63SXin Li# Licensed under the Apache License, Version 2.0 (the "License");
6*b32fbb63SXin Li# you may not use this file except in compliance with the License.
7*b32fbb63SXin Li# You may obtain a copy of the License at
8*b32fbb63SXin Li#
9*b32fbb63SXin Li#      http://www.apache.org/licenses/LICENSE-2.0
10*b32fbb63SXin Li#
11*b32fbb63SXin Li# Unless required by applicable law or agreed to in writing, software
12*b32fbb63SXin Li# distributed under the License is distributed on an "AS IS" BASIS,
13*b32fbb63SXin Li# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*b32fbb63SXin Li# See the License for the specific language governing permissions and
15*b32fbb63SXin Li# limitations under the License.
16*b32fbb63SXin Li
17*b32fbb63SXin Li# Get a dictionary of all the file_extension files in a directory, e.g.
18*b32fbb63SXin Li# declare -a aDic="$(.\get_file_dir.sh directory file_extension)"
19*b32fbb63SXin Lideclare -A aDic
20*b32fbb63SXin Li
21*b32fbb63SXin Lidir=$1
22*b32fbb63SXin Liext=$2
23*b32fbb63SXin Liif [[ -d ${dir} ]]; then
24*b32fbb63SXin Li  cd ${dir} && fList=$(find "${dir}" -name "*.${ext}")
25*b32fbb63SXin Li
26*b32fbb63SXin Li  echo '( \'
27*b32fbb63SXin Li  for f in ${fList}; do
28*b32fbb63SXin Li    fileName=${f##*/}
29*b32fbb63SXin Li    echo "[${fileName}]=\"$f\" \\"
30*b32fbb63SXin Li  done
31*b32fbb63SXin Li  echo ')'
32*b32fbb63SXin Lifi
33