hetelek / Velocity

A cross-platform application built using the Qt framework that allows you to browse and edit Xbox 360 files.
GNU General Public License v3.0
162 stars 47 forks source link

Improved temporary file name generation on Windows, and error handling #24

Closed SteffenL closed 11 years ago

SteffenL commented 11 years ago

Opening a file using the path returned by tmpnam() may result in a "permission denied" error on Windows. Now uses _tempnam() on Windows and tmpnam() on other platforms. Tested on Windows 8, using VC++ 2012 and Qt 4.8.1/MinGW 4.4.

Sample project: https://gist.github.com/SteffenL/5303896

Sample output when running build-all.bat:

==================== test-gcc ====================
TMP: C:\Users\Steffen\AppData\Local\Temp

--- Test #1: tmpnam() ---
Temp file path: \s7to.
Permission denied

--- Test #2: _tempnam() ---
Temp file path: C:\Users\Steffen\AppData\Local\Temp\85
OK

==================== test-msvc ====================
TMP: C:\Users\Steffen\AppData\Local\Temp

--- Test #1: tmpnam() ---
Temp file path: \s3h4.
OK

--- Test #2: _tempnam() ---
Temp file path: C:\Users\Steffen\AppData\Local\Temp\85
OK

==================== test-msvc-ide ====================
TMP: C:\Users\Steffen\AppData\Local\Temp

--- Test #1: tmpnam() ---
Temp file path: \s77g.
Permission denied

--- Test #2: _tempnam() ---
Temp file path: C:\Users\Steffen\AppData\Local\Temp\85
OK