Skip to content

[Feature Request]: add "isHiddenFile" property on fs dirent #38809

Description

@kimlimjustin

Is your feature request related to a problem? Please describe.
I found out that using the withFileTypes: true option on fs.readdirSync could return information of whether a file is a directory using the dirent.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 of fs and call it via child_process, which just makes the program laggy and slower (needs about 100-200ms to load information of a directory whereas fs.readdirSync needs about 10-20ms to read a directory).

Describe the solution you'd like
Fs could provide an isHiddenFile or isHidden or 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_HIDDEN of GetFileAttributesA using c++ for the windows, or just by using this /(^|\/)\.[^\/\.]/ regex to implement it for UNIX-like operating system.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions