From 7f1bdb44f6b23e7f8297b869fa051b1c57bf6546 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Thu, 20 Apr 2023 11:50:27 -0600 Subject: [PATCH] fs: add recursive option to readdir and opendir Adds a naive, linear recursive algorithm for the following methods: readdir, readdirSync, opendir, opendirSync, and the promise based equivalents. Fixes: https://github.com/nodejs/node/issues/34992 PR-URL: https://github.com/nodejs/node/pull/41439 Refs: https://github.com/nodejs/tooling/issues/130 Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Moshe Atlow --- doc/api/fs.md | 35 +++ lib/fs.js | 47 ++++ lib/internal/fs/dir.js | 93 ++++++-- lib/internal/fs/promises.js | 77 ++++++- lib/internal/fs/utils.js | 25 ++- test/sequential/test-fs-opendir-recursive.js | 220 +++++++++++++++++++ test/sequential/test-fs-readdir-recursive.js | 193 ++++++++++++++++ 7 files changed, 659 insertions(+), 31 deletions(-) create mode 100644 test/sequential/test-fs-opendir-recursive.js create mode 100644 test/sequential/test-fs-readdir-recursive.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 8daaf8ee9685ca..b85bd039795834 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1214,6 +1214,9 @@ a colon, Node.js will open a file system stream, as described by + +* {string} + +The base path that this {fs.Dirent} object refers to. + ### Class: `fs.FSWatcher`