http://bugs.winehq.org/show_bug.cgi?id=17875
Summary: GetTempFileName with unique != 0 broken Product: Wine Version: 1.1.18 Platform: PC-x86-64 OS/Version: Linux Status: UNCONFIRMED Severity: major Priority: P1 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: dev_oskar@hotmail.com
GetTempFileName called with a non-zero value for unique will not check if a file could be actually written in the provided path.
Paint Shop Pro 9 (and it seems 8 too) uses the return code to test if it should create several temp directories. So under wine it will always fail if unique is non-zero, GetTempFileName will currently not test anything and won't return zero, so creation of the undo files later will fail because the directory doesn't exists.
As the documentation tells the file isn't created my first patch isn't correct:
... if (unique) { sprintfW( p, formatW, unique ); /* need to check if we can create the file so applications can detect if they can write */ HANDLE handle; handle = CreateFileW( buffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 ); if (handle != INVALID_HANDLE_VALUE) { /* We created it */ CloseHandle( handle ); TRACE("created %s\n", debugstr_w(buffer) ); return unique; } /* Failure */ return 0; } else { /* get a "random" unique number and try to create the file */ ...
It should check the directory if it exists.