sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
16.72k stars 389 forks source link

Some strange links on Windows #1883

Closed Linya0o closed 2 weeks ago

Linya0o commented 2 weeks ago

yazi --debug output

Yazi
    Version: 0.3.3 (7c445ce 2024-09-04)
    Debug  : false
    OS     : windows-x86_64 (windows)

Ya
    Version: 0.3.3 (7c445ce 2024-09-04)

Emulator
    Emulator.via_env: ("", "")
    Emulator.via_csi: Ok(Unknown([]))
    Emulator.detect : Microsoft

Adapter
    Adapter.matches: Sixel

Desktop
    XDG_SESSION_TYPE           : None
    WAYLAND_DISPLAY            : None
    DISPLAY                    : None
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : None
    EDITOR             : None
    VISUAL             : None
    YAZI_FILE_ONE      : Some("C:\\Program Files\\Git\\usr\\bin\\file.exe")
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "code %*", block: false, orphan: true, desc: "code", for_: None, spread: true })
    block  : Some(Opener { run: "code -w %*", block: true, orphan: false, desc: "code (block)", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : program not found
    ZELLIJ_SESSION_NAME: None
    Zellij version     : program not found

Dependencies
    file             : 5.45
    ueberzugpp       : program not found
    ffmpegthumbnailer: program not found
    magick           : program not found
    fzf              : 0.56.0
    fd               : 10.2.0
    rg               : 14.1.1
    chafa            : program not found
    zoxide           : program not found
    7z               : program not found
    7zz              : program not found
    jq               : 1.7.1

--------------------------------------------------

Please describe the problem you're trying to solve

image

I found out that these links are protected operating system files on Windows.

Would you be willing to contribute this feature?

Describe the solution you'd like

I think these files should not be displayed. Generally, I will not modify or view these links. Windows also does not allow this.

Additional context

No response

Validations

sxyazi commented 2 weeks ago

Is there a simple way to detect these kinds of files? Like, hidden files in Windows have a special 2 set for them:

https://github.com/sxyazi/yazi/blob/565f9cc898b4f9e121a58476547c571be9f7f0f6/yazi-shared/src/fs/cha.rs#L153-L159

https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants

Linya0o commented 2 weeks ago

I don't know rust and the API of OS files. I simply asked chatgpt, and this is the code suggestion it gave. I hope it can help you.

#[cfg(windows)]
    {
        use std::os::windows::fs::MetadataExt;

        // Check if the file is a hidden link and skip it if it is.
        if meta.file_attributes() & 2 != 0 { // 2 corresponds to FILE_ATTRIBUTE_HIDDEN
            if meta.is_symlink() {
                // Skip the hidden link
                return Self::dummy(); // or return a default value, depending on your use case
            }
            attached |= ChaKind::HIDDEN;
        }
    }
sxyazi commented 2 weeks ago

Sorry, I can't accept that because symlinks and hidden files are two different concepts.

Treating symlinks as hidden files would mess with the logic of hidden files. If Windows doesn't provide an extra flag to indicate that a file should be hidden, then it can't be considered a hidden file.

Closing as not doable