-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
[Feature Request]: add "isHiddenFile" property on fs dirent #38809
Copy link
Copy link
Closed
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Is your feature request related to a problem? Please describe.
I found out that using the
withFileTypes: trueoption onfs.readdirSynccould return information of whether a file is a directory using thedirent.isDirectory()property, but there's no option to check whether a file is a hidden file. I googled and found out that I can check if a file is hidden in Unix simply by a file name pattern, but, not in windows. As a result, I have to code using c++ and make my own version offsand call it viachild_process, which just makes the program laggy and slower (needs about 100-200ms to load information of a directory whereasfs.readdirSyncneeds about 10-20ms to read a directory).Describe the solution you'd like
Fs could provide an
isHiddenFileorisHiddenor whatever property that just gives information of whether a file/folder is hidden in the system.Additional Information
For whoever needs a way to filter hidden file, you can do this by using
FILE_ATTRIBUTE_HIDDENofGetFileAttributesAusing c++ for the windows, or just by using this/(^|\/)\.[^\/\.]/regex to implement it for UNIX-like operating system.