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

WinRT: Refactor I/O to fully support items

    XMLWordPrintable

Details

    • Task
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.6.0
    • Core: I/O
    • None
    • WinRT, Windows Phone, Windows 10, Win10IoTCore

    Description

      The problem:
      Right now we use the win32 API for file access, which some (if not many) modifications to work properly on WinRT.
      The auto tests are fully functional right now.
      However, with the Win32 API one is not able to access any file outside the sandbox. You have to use IStorage* WinRT
      classes for that. This requires to reimplement the fileengine inside Qt Core.

      Approach:
      There is already a file engine in the platform plugin which we use for file dialog handling. A native file dialog
      always returns a IStorage*.
      However, we need to have a consistent approach for filepaths. We could come up with alternative approaches
      (eg [Pictures]/foo.jpg or /Pictures/foo.jpg or Pictures://foo.jpg)). Doing this would cause incompatibilities with existing
      applications and cause problems for users upgrading in case they stored absolute paths in settings or such.
      Hence try to keep the user facing paths consistent (C:/Users/foo/...) and internally switch to the WinRT API when actually
      doing work.

      Details:

      Conversion old -> new:

      File: C:\foo\... -> IStorageFileStatics::GetFileFromPathAsync()
      Folder: C:\foo -> IStorageFolderStatics::GetFolderFromPathAsync()

      Conversion new -> old:

      Folder:
      inline QString pathForStorageFolder(const ComPtr<IStorageFolder> &folder)

      { QString result; ComPtr<IStorageItem> storageItem; if (FAILED(folder.As(&storageItem))) return QString(); HString path; if (FAILED(storageItem->get_Path(path.GetAddressOf()))) return QString(); result = convertCharArray(path.GetRawBuffer(nullptr)); return result; }

      File: Probably same via StorageItem conversion

      QFileSystemEngine:

      • use the one from platform plugin

      QStandardPaths:

      • Not possible to get eg. StandardLocation::MoviesLocation as this is IStorageFolder, which then again can hold
        multiple directories. (C:\Users\foo\Movies and C:\OneDrive\Movies). Current approach is to iterate subfolders,
        get their path (as in above new->old) and take the directory up.

      QFileSystemIterator:

      • Folders IStorageFolder::GetFoldersAsyncOverloadDefaultOptionsStartAndCount()
      • Files IStorageFolder::GetFilesAsyncOverloadDefaultOptionsStartAndCount()
      • Maybe just IStorageFolder::GetItemsAsyncOverloadDefaultStartAndCount() and have each item check for its type via .As()

      Use Cases:

      • Create file in current directory
      • Query current directory and receive IStorageFolder
      • Use IStorageFolder::createFileAsync()
      • Create file with absolute path
      • Split path into segments
      • Check for longest "known" IStorageFolder X. Create hashmap during runtime
      • From X iterate to subdirectories and create file
      • Create folder
      • Similar to file, but create folder in the end IStorageFolder::CreateFolderAsync()

      Attachments

        Issue Links

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

          Activity

            People

              owolff Oliver Wolff
              mkalinow Maurice Kalinowski
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes