dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.56k forks source link

Need a property that can check whether a File or Directory is hidden. #53763

Open SooChang-Lee opened 11 months ago

SooChang-Lee commented 11 months ago

I am developing a cross-platform (android, ios, windows, macos, linux) file explorer with flutter.

When showing the file list, hidden files must be shown or hidden depending on the user's selection.

OS's other than windows allow files and folders starting with dot to be identified as hidden files, but windows does not.

The FileSystemEntity, File, and Directory classes do not provide an isHidden property.

I tried using the code below in Windows, but it works differently than expected on USB storage or network volumes. bool isHidden = (stat.mode & 0x02) != 0;

We need a property that can check whether a File or Directory is hidden.

macOS

Windows10

brianquinlan commented 10 months ago

Can you use the GetFileAttributes function in package:win32 to get this information?

SooChang-Lee commented 10 months ago

@brianquinlan hello. I found out about the win32 package this time.

If I run the GetFileAttributes function using this package, can I get the information I need?

how can I run the GetFileAttributes function from my dart code? I couldn't find any example code...

SooChang-Lee commented 10 months ago

@brianquinlan I succeeded in extracting the FILE_ATTRIBUTE_READONLY attribute using the GetFileAttributes function and was able to check whether the file or directory was hidden.

I think these functions should be provided through dart's File API.

cbenhagen commented 10 months ago

@brianquinlan on macOS checking for a leading dot is not enough. st_flags should also be checked for UF_HIDDEN.