You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
414 B
16 lines
414 B
1 month ago
|
import { join, resolve } from 'path';
|
||
|
import { readdirSync, statSync } from 'fs';
|
||
|
|
||
|
export function totalist(dir, callback, pre='') {
|
||
|
dir = resolve('.', dir);
|
||
|
let arr = readdirSync(dir);
|
||
|
let i=0, abs, stats;
|
||
|
for (; i < arr.length; i++) {
|
||
|
abs = join(dir, arr[i]);
|
||
|
stats = statSync(abs);
|
||
|
stats.isDirectory()
|
||
|
? totalist(abs, callback, join(pre, arr[i]))
|
||
|
: callback(join(pre, arr[i]), abs, stats);
|
||
|
}
|
||
|
}
|