Advertisement
LockdateforGHS

find db

Jun 13th, 2023
1,841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.90 KB | None | 0 0
  1. // Generated by gA6:09f:@10.09:6g
  2.  
  3. import haxe.io.Path;
  4. import sys.FileSystem;
  5.  
  6. class DatabaseFinder {
  7.     static function main() {
  8.         var path = Path.directory(".");
  9.         findDatabases(path);
  10.     }
  11.  
  12.     static function findDatabases(path: String) {
  13.         var files = FileSystem.readDirectory(path);
  14.         for (file in files) {
  15.             var filePath = Path.join(path, file);
  16.             if (isDatabaseFile(filePath)) {
  17.                 trace("Found database: " + filePath);
  18.             } else if (isDirectory(filePath)) {
  19.                 findDatabases(filePath);
  20.             }
  21.         }
  22.     }
  23.  
  24.     static function isDatabaseFile(filePath: String): Bool {
  25.         return Path.extension(filePath) == "db";
  26.     }
  27.  
  28.     static function isDirectory(filePath: String): Bool {
  29.         var stat = FileSystem.stat(filePath);
  30.         return stat != null && stat.isDirectory();
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement