@@ -146,35 +146,15 @@ end
146146
147147---- ----------------------------------------------------------------------------
148148os .tempfolder = function ()
149- if core .settings :get (" TMPFolder" ) then
150- return core .settings :get (" TMPFolder" ) .. DIR_DELIM .. " MT_" .. math.random (0 ,10000 )
151- end
152-
153- local filetocheck = os.tmpname ()
154- os.remove (filetocheck )
155-
156- -- luacheck: ignore
157- -- https://blogs.msdn.microsoft.com/vcblog/2014/06/18/c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
158- -- The C runtime (CRT) function called by os.tmpname is tmpnam.
159- -- Microsofts tmpnam implementation in older CRT / MSVC releases is defective.
160- -- tmpnam return values starting with a backslash characterize this behavior.
161- -- https://sourceforge.net/p/mingw-w64/bugs/555/
162- -- MinGW tmpnam implementation is forwarded to the CRT directly.
163- -- https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/
164- -- MinGW links to an older CRT release (msvcrt.dll).
165- -- Due to legal concerns MinGW will never use a newer CRT.
166- --
167- -- Make use of TEMP to compose the temporary filename if an old
168- -- style tmpnam return value is detected.
169- if filetocheck :sub (1 , 1 ) == " \\ " then
170- local tempfolder = os.getenv (" TEMP" )
171- return tempfolder .. filetocheck
172- end
149+ local temp = core .get_temp_path ()
150+ return temp .. DIR_DELIM .. " MT_" .. math.random (0 , 10000 )
151+ end
173152
174- local randname = " MTTempModFolder_" .. math.random (0 ,10000 )
175- local backstring = filetocheck :reverse ()
176- return filetocheck :sub (0 , filetocheck :len () - backstring :find (DIR_DELIM ) + 1 ) ..
177- randname
153+ ---- ----------------------------------------------------------------------------
154+ os .tmpname = function ()
155+ local path = os .tempfolder ()
156+ io.open (path , " w" ):close ()
157+ return path
178158end
179159
180160---- ----------------------------------------------------------------------------
0 commit comments