GetTempFileName fails if directory with suggested name exists
Original Reporter info from Mantis: piula3 @piula
-
Reporter name:
Original Reporter info from Mantis: piula3 @piula
- Reporter name:
Description:
GetTempFileName only checks for FileExists. When a directory with the same name, e.g. 'TMP00000.tmp' exists, this file name is returned, but it cannot be used.
Steps to reproduce:
- Create directory '%TEMP%\TMP00000.tmp'
- Call GetTempFileName
It returns '%TEMP%\TMP00000.tmp', but it should be '%TEMP%\TMP00001.tmp'
Additional information:
OS is Windows 8.1 64 bit edition.
To fix, apply this change to file rtl\objpas\sysutils\osutil.inc:
approx. in line 248:
change
Until not FileExists(Result);
to
Until not FileExists(Result) and not DirectoryExists(Result);
Mantis conversion info:
- Mantis ID: 38772
- Version: 3.2.0
- Fixed in version: 3.3.1
- Fixed in revision: 49225 (#fe78829b)
- Target version: 3.2.2