Lwjgl3: Tiny File Dialog not returning file(s) paths for files larger than 2GB

Created on 23 Feb 2021  路  5Comments  路  Source: LWJGL/lwjgl3

Environment

  • LWJGL version: 3.2.3
  • LWJGL build #: 13
  • Java version: AdoptOpenJDK build 1.8.0_282-b08
  • Platform: Windows
  • Module: tinyfd

Description

The tinyfd_openFileDialog returns null upon file selection (both single and multiple) if the selected file(s) size is larger than 2GB. In case of multi-file selection only the files smaller than ~2GB will be included in the results. Can anyone else confirm if this is happening? I'm running Windows 10 64bit 20H2 fully patched.

Bug 3rd party

Most helpful comment

I contacted Guillaume Vareille, the author of tinyfd, and he was able to deploy a fix (which I tested and is working) in the latest version (3.8.7), I'll be waiting for LWJGL 3.2.4, luckily I'm not in a rush to have support for very large files right now.

I'm not sure how much the APIs have changed since the version currently in the master branch, but he told me he hasn't changed the APIs in a long time.

All 5 comments

I can reproduce this. Looks like tinyfd uses fopen to verify that the selected files are valid, which fails on 2GB+ files.

Thanks for looking into it, have you by any chance checked if they have become aware of the issue and already fixed it in their more recent versions?

Yes, the latest version still uses fopen.

Btw, you could try switching to Native File Dialog, its file open dialog doesn't have this issue.

Found the issue, fclose is actually not even involved with the check since by default the build is UTF8 now. He uses stat.h to retrieve data with _wstat into an instance of _stat. Tried replacing both the struct and the function call to their _stat64 and _wstat64 variants and it worked without an issue. I guess I'll drop the author a message and see if such change makes sense moving forward and does not break compatibility with some old versions of windows.

static int fileExists(char const * aFilePathAndName)
{
        struct _stat lInfo;
        wchar_t * lTmpWChar;
        int lStatRet;
        FILE * lIn;

        if (!aFilePathAndName || !strlen(aFilePathAndName))
        {
                return 0;
        }

        if (tinyfd_winUtf8)
        {
            lTmpWChar = tinyfd_utf8to16(aFilePathAndName);
            lStatRet = _wstat(lTmpWChar, &lInfo);
            if (lStatRet != 0)
                    return 0;
            else if (lInfo.st_mode & _S_IFREG)
                    return 1;
            else
                    return 0;
        }
        else
        {
                lIn = fopen(aFilePathAndName, "r");
                if (!lIn)
                {
                        return 0;
                }
                fclose(lIn);
                return 1;
        }
}

I contacted Guillaume Vareille, the author of tinyfd, and he was able to deploy a fix (which I tested and is working) in the latest version (3.8.7), I'll be waiting for LWJGL 3.2.4, luckily I'm not in a rush to have support for very large files right now.

I'm not sure how much the APIs have changed since the version currently in the master branch, but he told me he hasn't changed the APIs in a long time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baileysostek picture baileysostek  路  4Comments

ChrisTrenkamp picture ChrisTrenkamp  路  6Comments

erikmartinessanches picture erikmartinessanches  路  3Comments

kurtzmarc picture kurtzmarc  路  7Comments

voidburn picture voidburn  路  4Comments