diff options
author | nOOb3167 <nOOb3167@gmail.com> | 2018-06-13 13:22:17 +0200 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2018-06-13 13:22:17 +0200 |
commit | 10634f0443c478ff08daf80388198931befaa95c (patch) | |
tree | 4eda5ba613af51ede1d8eb89b2fc73d9867dbd9d /builtin/mainmenu | |
parent | 18f1ede64f1f155fcdb7b8d0a016b8dbe9cd7522 (diff) | |
download | minetest-10634f0443c478ff08daf80388198931befaa95c.tar.gz minetest-10634f0443c478ff08daf80388198931befaa95c.tar.bz2 minetest-10634f0443c478ff08daf80388198931befaa95c.zip |
Make os.tempfolder work correctly for MinGW & MSVC (#7443)
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/common.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index cd4903f56..cc61fe0ad 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -171,6 +171,23 @@ os.tempfolder = function() local filetocheck = os.tmpname() os.remove(filetocheck) + -- https://blogs.msdn.microsoft.com/vcblog/2014/06/18/c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/ + -- The C runtime (CRT) function called by os.tmpname is tmpnam. + -- Microsofts tmpnam implementation in older CRT / MSVC releases is defective. + -- tmpnam return values starting with a backslash characterize this behavior. + -- https://sourceforge.net/p/mingw-w64/bugs/555/ + -- MinGW tmpnam implementation is forwarded to the CRT directly. + -- https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/ + -- MinGW links to an older CRT release (msvcrt.dll). + -- Due to legal concerns MinGW will never use a newer CRT. + -- + -- Make use of TEMP to compose the temporary filename if an old + -- style tmpnam return value is detected. + if filetocheck:sub(1, 1) == "\\" then + local tempfolder = os.getenv("TEMP") + return tempfolder .. filetocheck + end + local randname = "MTTempModFolder_" .. math.random(0,10000) local backstring = filetocheck:reverse() return filetocheck:sub(0, filetocheck:len() - backstring:find(DIR_DELIM) + 1) .. |