[Qt-interest] QFile::SetPermissions useless on Windows?

David Ching dc at remove-this.dcsoft.com
Fri Feb 19 03:42:52 CET 2010


"Bartosh Wroblevksy" <bartosh at live.com> wrote in message 
news:BAY135-W200A8E7D13925C7E1335E0D24A0 at phx.gbl...
>

> I looked into the code and I saw that under the hood, on setPermissions, 
> the method _wchmod  is used 
> (http://msdn.microsoft.com/en-us/library/1z319a54(VS.80).aspx).
> This method has no concept of  groups.  You can only have read_permitted 
> and/or write_permitted. Yet Windows does have groups, it has a group 
> "AllUsers".I can't setPermissions on that group when my Qt application 
> runs from an administrator account. Is there something I am not 
> understanding? Was QFile::SetPermissions Was this properly implemented?
>
> Regards,Bartosh


Bartosh, FWIW I use:

#ifdef Q_OS_WIN
    SetFileAttributes(..,);
#endif


and don't use QFile::setPermissions().  My code needs to set the Hidden 
attribute and I couldn't find an API in Qt to do it, probably because on 
Linux/Mac the way to make the file hidden is to insert a '.' at the start of 
the file.  I'm not sure if SetFileAttributes() allows you to change the 
group, but FWIW, there is a pattern of falling back to Windows specific 
functions for file operations that Qt doesn't support.

-- David 




More information about the Qt-interest-old mailing list