Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline devices in windows mess up places #204

Open
jvannugteren opened this issue Dec 9, 2024 · 2 comments
Open

Offline devices in windows mess up places #204

jvannugteren opened this issue Dec 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jvannugteren
Copy link

When a device is not available in windows, for example a network drive is offline, it still shows up in filedialog places. But when the user tries to open the non-existing drive weird things happen. The path reverts to the default, but the files shown are likely from the first bookmark. I think the way to avoid this all together is by modifying the following function:

std::vector<IGFD::PathDisplayedName> GetDevicesList() override {
        std::vector<IGFD::PathDisplayedName> res;
#ifdef _IGFD_WIN_
        const DWORD mydrives = 2048;
        char lpBuffer[2048];
#define mini(a, b) (((a) < (b)) ? (a) : (b))
        const DWORD countChars = mini(GetLogicalDriveStringsA(mydrives, lpBuffer), 2047);
#undef mini
        if (countChars > 0U && countChars < 2049U) {
            std::string var = std::string(lpBuffer, (size_t)countChars);
            IGFD::Utils::ReplaceString(var, "\\", "");
            auto arr = IGFD::Utils::SplitStringToVector(var, '\0', false);
            wchar_t szVolumeName[2048];
            IGFD::PathDisplayedName path_name;
            for (auto& a : arr) {
                path_name.first = a;
                path_name.second.clear();
                // std::wstring wpath = IGFD::Utils::UTF8Decode(a);

                std::wstring wpath = IGFD::Utils::UTF8Decode(a) + L"\\"; // otherwise can't even find C drive
                if (GetVolumeInformationW(wpath.c_str(), szVolumeName, 2048, NULL, NULL, NULL, NULL, 0)) {
                    path_name.second = IGFD::Utils::UTF8Encode(szVolumeName);
                    res.push_back(path_name);
                }
            }
        }
#endif  // _IGFD_WIN_
        return res;
    }

When GetVolumeInformationW fails, for example because the drive is not available, it will not add the path to the list. Also I ran into an issue where the C drive did not show up due to a missing \ somehow. The only problem left is now that if the drive goes offline after the filedialog instance has been created. Not sure how to fix this.

@aiekick aiekick added the bug Something isn't working label Dec 10, 2024
@aiekick
Copy link
Owner

aiekick commented Dec 10, 2024

Hello, thanks for this issue.

indeed i noticed it by the past, but im fully busy at this moment.

and i need to integrate the imgui test engine first for full testing IGFD.

Many times i corrected an issue case, and discovered than other issue was comming back..

if you want help for that, you are welcome

@jvannugteren
Copy link
Author

Hi, totally understand. This one I fixed for myself already using a custom filesystem (hint for other running into this). Maybe leave the issue for when you find time to get to it? I'm also thinking of adding the imgui test engine to my code. I'll have a go at it there first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants