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

Constantin Makshin dinosaur-rus at users.sourceforge.net
Mon Jun 22 20:13:59 CEST 2009


"\\?\" prefix is used to extend the maximum path length from 259 to ~32000  
characters. Could you call DeleteFileW(L"\\?\<path>"), where <path> is the  
absolute path to your temporary file with backslashes as path delimiters,  
directly and see what it returns?

On Mon, 22 Jun 2009 21:00:48 +0400, Yevgen Muntyan <muntyan at fastmail.fm>  
wrote:
> 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

-- 
Constantin "Dinosaur" Makshin



More information about the Qt-interest-old mailing list