Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86240

QDir::exists()当文件路径中含有"..",且若子文件不存在,其上一层目录被判定为不存在的问题,举例"local/../bin",若"bin"不存在,"local"被判定为不存在

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.5.1, 5.9.9
    • Core: I/O
    • None
    • unix
    • Linux/X11

    Description

      在linux系统下,QFile::exists() / QDir::exists() / QFile::open() / QDir::rmdir() 等函数均存在同样的问题,若文件路径含有"..",当子文件不存在,其上一层目录也被判定为不存在,比如"local/../bin",若"bin"不存在,"local"被判定为不存在/不能被打开/不能被删除。

      在windows系统下,这样传递参数是没有问题的。二者区别是在

      QFileSystemEntry::resolveNativeFilePath()函数中,windows下会走

      QFSFileEnginePrivate::longFileName --》 GetFullPathName,将含有../的路径正确处理了。而linux系统下,什么也没有做。

      个人理解,应该在这个函数中,将包含".."的路径使用QDir::cleanPath处理下。

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            dongcy Dong Chunyu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes