From 942abf1a3ba60a60207a213dbeb383904f97e47d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 13 Aug 2009 17:30:02 +0200 Subject: fixing return values _wchmod on Windows CE _wchmod returns 0 on success and -1 on error. Our Windows CE implementation did it wrong. Thanks to Konstantin Ritt for spotting this! Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 2 +- src/corelib/kernel/qfunctions_wince.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 3394a00..ba93a94 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1706,7 +1706,7 @@ bool QFSFileEngine::setPermissions(uint perms) #if !defined(Q_OS_WINCE) ret = ::_wchmod((wchar_t*)d->filePath.utf16(), mode) == 0; #else - ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode); + ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode) == 0; #endif return ret; } diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 2b5d4fe..77f680a 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -292,13 +292,14 @@ bool qt_wince__chmod(const char *file, int mode) bool qt_wince__wchmod(const wchar_t *file, int mode) { + BOOL success = FALSE; // ### Does not work properly, what about just adding one property? if(mode&_S_IWRITE) { - return SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); + success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) { - return SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); + success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); } - return false; + return success ? 0 : -1; } HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile) -- cgit v0.12