// Copyright (c) Huawei Technologies Co., Ltd. 2022-2024. All rights reserved.
//
// this file licensed under the Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
// PURPOSE.
// See the Mulan PSL v2 for more details.
module.exports = (function () {
  const fs = require('fs');
  const path = require('path');

  function travel(dir, callback) {
    fs.readdirSync(dir).forEach(file => {
      const pathname = path.join(dir, file);
      if (fs.statSync(pathname).isDirectory()) {
        travel(pathname, callback);
      } else {
        // 这里可以添加对文件的处理逻辑
        callback(pathname);
      }
    });
  }

  return { travel };
})();