]> git.lyx.org Git - features.git/commitdiff
When using CREATE_NEW, CreateFile fails if the file already exists.
authorEnrico Forestieri <forenr@lyx.org>
Tue, 23 Feb 2010 16:22:27 +0000 (16:22 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 23 Feb 2010 16:22:27 +0000 (16:22 +0000)
I intended that, but was forgetting to account for it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33545 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/os_win32.cpp

index 87899a838bbc4fac24945246f3e4bac8f67beda3..60c5915d09c67aa101a2a595d83c36798e7160e0 100644 (file)
@@ -287,7 +287,8 @@ static QString const get_short_path(QString const & long_path, file_access how)
                HANDLE h = CreateFileW((wchar_t *) long_path.utf16(),
                                GENERIC_WRITE, 0, NULL, CREATE_NEW,
                                FILE_ATTRIBUTE_NORMAL, NULL);
-               if (h == INVALID_HANDLE_VALUE)
+               if (h == INVALID_HANDLE_VALUE
+                   && GetLastError() != ERROR_FILE_EXISTS)
                        return long_path;
                CloseHandle(h);
        }