INNER CODE UNIT · JavaScript
walkFiles
agent-sh/agentsys · lib/binary/index.js:364
function walkFiles(dir) {
const out = [];
const stack = [dir];
while (stack.length > 0) {
const cur = stack.pop();
const st = fs.lstatSync(cur);
if (st.isSymbolicLink()) {
throw new Error('Refusing to follow symlink produced by extractor: ' + cur);
}
if (st.isDirectory()) {
const names = fs.readdirSync(cur);
for (let i = 0; i < names.length; i++) {
stack.push(path.join(cur, names[i]));
}
} else if (st.isFile()) {
out.push(cur);
}
}