[Qt-interest] QFile::remove() fails on Windows Vista

Yevgen Muntyan muntyan at fastmail.fm
Mon Jun 22 19:00:48 CEST 2009


Yevgen Muntyan wrote:
> Hey,
>
> I have a problem with QFile::rename: it fails when it tries to remove the 
> temporary file it uses, because DeleteFileW() fails inside 
> QFSFileEngine::remove(). My code is roughly the following:
>
> QFile source(":/gap/ggap.g");
> source.copy("C:/Users/muntyan/AppData/Local/Temp/ggap-000025cb/ggap.g")
>
> The copy() call here fails. 
> "C:/Users/muntyan/AppData/Local/Temp/ggap-000025cb" directory is created 
> with QDir::mkdir(), and I do have permissions to delete files from it, and I 
> can delete files from it in explorer. The temporary files qt_temp.XXXXXX are 
> not read-only, so DeleteFile() isn't supposed to fail. But it does!
>   

I found out that Qt calls DeleteFile() on some funny long version of the 
filename, namely it passes
the following string to DeleteFile:

\\?\c:\Users\muntyan\AppData\Local\Temp\ggap-00002d22\qt_temp.Za5308

it prepends \\?\ in QFSFileEnginePrivate::longFileName(). DeleteFile() 
doesn't fail if I call it on
the filename without that prefix. Ideas?

Thanks,
Yevgen




More information about the Qt-interest-old mailing list