Utils.ts 825 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Path = require("path");
  2. import * as fse from 'fs-extra';
  3. export class Utils {
  4. static findAllFile(filter: Function): Array<string> {
  5. let _mapDir = (path: string, fileList: Array<string>) => {
  6. let state = fse.statSync(path);
  7. if (state.isDirectory()) {
  8. let files = fse.readdirSync(path);
  9. for (let file of files) {
  10. _mapDir(Path.join(path, file), fileList);
  11. }
  12. }
  13. else {
  14. if (filter(path)) {
  15. fileList.push(path);
  16. }
  17. // let ext = Path.extname(path);
  18. // if (ext == '.prefab' || ext == '.scene') {
  19. // fileList.push(path);
  20. // }
  21. }
  22. }
  23. let rootPath = Path.join(Editor.Project.path, 'assets');
  24. let fileList: Array<string> = [];
  25. _mapDir(rootPath, fileList);
  26. return fileList;
  27. }
  28. }