VirtualBox

Changeset 102393 in vbox


Ignore:
Timestamp:
Nov 30, 2023 12:58:05 PM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10561. More fixes for copying and deleting file objects.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.cpp

    r102379 r102393  
    208208}
    209209
    210 QString UICustomFileSystemItem::path(bool fRemoveTrailingDelimiters /* = false */) const
     210QString UICustomFileSystemItem::path() const
    211211{
    212212    const QChar delimiter('/');
    213     Q_UNUSED(fRemoveTrailingDelimiters);
     213
    214214    const UICustomFileSystemItem *pParent = this;
    215215    QStringList path;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h

    r102378 r102393  
    9292    void setIsOpened(bool flag);
    9393
    94     /** Full absolute path of the item. With or without the trailing '/' */
    95     QString  path(bool fRemoveTrailingDelimiters = false) const;
     94    QString  path() const;
    9695
    9796    /** Returns true if this is directory and file object name is ".." */
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r102378 r102393  
    610610    {
    611611        QVector<KDirectoryRemoveRecFlag> aFlags(1, KDirectoryRemoveRecFlag_ContentAndDir);
    612         m_comGuestSession.DirectoryRemoveRecursive(item->path(), aFlags);
     612        m_comGuestSession.DirectoryRemoveRecursive(UIPathOperations::removeTrailingDelimiters(item->path()), aFlags);
    613613    }
    614614    else
    615         m_comGuestSession.FsObjRemove(item->path());
     615        m_comGuestSession.FsObjRemove(UIPathOperations::removeTrailingDelimiters(item->path()));
    616616    if (!m_comGuestSession.isOk())
    617617    {
    618618        emit sigLogOutput(QString(item->path()).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
    619619        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    620     }
    621 }
    622 
    623 void UIFileManagerGuestTable::deleteByPath(const QStringList &pathList)
    624 {
    625     foreach (const QString &strPath, pathList)
    626     {
    627         CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(strPath, true);
    628         KFsObjType eType = fileType(fileInfo);
    629         if (eType == KFsObjType_File || eType == KFsObjType_Symlink)
    630         {
    631               m_comGuestSession.FsObjRemove(strPath);
    632         }
    633         else if (eType == KFsObjType_Directory)
    634         {
    635             QVector<KDirectoryRemoveRecFlag> aFlags(1, KDirectoryRemoveRecFlag_ContentAndDir);
    636             m_comGuestSession.DirectoryRemoveRecursive(strPath, aFlags);
    637         }
    638620    }
    639621}
     
    706688    QVector<QString> aFilters;
    707689    QVector<QString> aFlags;
    708     QString strDestinationPath = strDestination;
     690    QString strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestination);
    709691
    710692    /* Remove empty source paths. Typically happens when up directory is selected: */
     
    726708    QString strDirectoryFlags("CopyIntoExisting,Recursive,FollowLinks");
    727709    QString strFileFlags("FollowLinks");
    728     foreach (const QString &strSource, sourcePaths)
    729     {
    730         KFsObjType enmFileType = UIFileManagerHostTable::fileType(strSource);
     710
     711    for (int i = 0; i < sourcePaths.size(); ++i)
     712    {
     713        sourcePaths[i] = UIPathOperations::removeTrailingDelimiters(sourcePaths[i]);
     714        KFsObjType enmFileType = UIFileManagerHostTable::fileType(sourcePaths[i]);
    731715        if (enmFileType == KFsObjType_Unknown)
    732             emit sigLogOutput(QString("Querying information for host item %1 failed.").arg(strSource), m_strTableName, FileManagerLogType_Error);
     716            emit sigLogOutput(QString("Querying information for host item %1 failed.").arg(sourcePaths[i]), m_strTableName, FileManagerLogType_Error);
    733717        /* If the source is an directory, make sure to add the appropriate flag to make copying work
    734718         * into existing directories on the guest. This otherwise would fail (default): */
    735719        else if (enmFileType == KFsObjType_Directory)
    736         {
    737             /* Make sure that if the source is a directory, that we append a trailing delimiter to it,
    738              * so that it gets copied *into* the destination directory as a whole, and not just it's contents. */
    739             strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);
    740720            aFlags << strDirectoryFlags;
    741         }
    742721        else
    743         {
    744             /* Ditto goes for source files, as the destination always is a directory path. */
    745             strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);
    746722            aFlags << strFileFlags;
    747         }
    748723    }
    749724
     
    796771    }
    797772
    798     QString strDestinationPath = hostDestinationPath;
     773    QString strDestinationPath = UIPathOperations::addTrailingDelimiters(hostDestinationPath);
    799774    QString strDirectoryFlags("CopyIntoExisting,Recursive,FollowLinks");
    800775    QString strFileFlags;
    801     foreach (const QString &strSource, sourcePaths)
    802     {
     776    //foreach (const QString &strSource, sourcePaths)
     777    for (int i = 0; i < sourcePaths.size(); ++i)
     778    {
     779        sourcePaths[i] = UIPathOperations::removeTrailingDelimiters(sourcePaths[i]);
    803780        /** @todo Cache this info and use the item directly, which has this info already? */
    804781
    805782        /* If the source is an directory, make sure to add the appropriate flag to make copying work
    806783         * into existing directories on the guest. This otherwise would fail (default). */
    807         CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(strSource, true);
     784        CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(sourcePaths[i], true);
    808785        if (!m_comGuestSession.isOk())
    809786        {
     
    813790
    814791        if (fileType(fileInfo) == KFsObjType_Directory)
    815         {
    816             /* Make sure that if the source is a directory, that we append a trailing delimiter to the destination,
    817              * so that the source directory gets copied *into* the destination directory as a whole, and not
    818              * just it's contents. */
    819             strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);
    820792            aFlags << strDirectoryFlags;
    821         }
    822793        else
    823         {
    824             /* Ditto goes for source files, as the destination always is a directory path. */
    825             strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);
    826794            aFlags << strFileFlags;
    827         }
     795
    828796    }
    829797
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r102378 r102393  
    8383    virtual void    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    8484    virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
    85     virtual void    deleteByPath(const QStringList &pathList) override final;
    8685    virtual void    goToHomeDirectory() override final;
    8786    virtual bool    renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r102378 r102393  
    284284    {
    285285        QDir itemToDelete;
    286         itemToDelete.remove(item->path());
     286        itemToDelete.remove(UIPathOperations::removeTrailingDelimiters(item->path()));
    287287    }
    288288    QDir itemToDelete(item->path());
     
    297297    if (!deleteSuccess)
    298298        emit sigLogOutput(QString(item->path()).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
    299 }
    300 
    301 void UIFileManagerHostTable::deleteByPath(const QStringList &pathList)
    302 {
    303     foreach (const QString &strPath, pathList)
    304     {
    305         bool deleteSuccess = true;
    306         KFsObjType eType = fileType(QFileInfo(strPath));
    307         if (eType == KFsObjType_File || eType == KFsObjType_Symlink)
    308         {
    309             deleteSuccess = QDir().remove(strPath);
    310         }
    311         else if (eType == KFsObjType_Directory)
    312         {
    313             QDir itemToDelete(strPath);
    314             itemToDelete.setFilter(QDir::NoDotAndDotDot);
    315             deleteSuccess = itemToDelete.removeRecursively();
    316         }
    317         if (!deleteSuccess)
    318             emit sigLogOutput(QString(strPath).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
    319     }
    320299}
    321300
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h

    r102378 r102393  
    6363    virtual void    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    6464    virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
    65     virtual void    deleteByPath(const QStringList &pathList) override final;
    6665    virtual void    goToHomeDirectory() override final;
    6766    virtual bool    renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r102378 r102393  
    11201120        if (!item)
    11211121            continue;
    1122 
    1123         /* Make sure to remove any trailing delimiters for directory paths here (e.g. "C:\foo\bar\" -> "C:\foo\bar"),
    1124          * as we want to copy entire directories, not only its contents (see Guest Control SDK docs). */
    1125         pathList.push_back(item->path(true /* fRemoveTrailingDelimiters */));
     1122        pathList.push_back(item->path());
    11261123    }
    11271124    return pathList;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r102378 r102393  
    213213    virtual void     readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0;
    214214    virtual void     deleteByItem(UICustomFileSystemItem *item) = 0;
    215     virtual void     deleteByPath(const QStringList &pathList) = 0;
    216215    virtual void     goToHomeDirectory() = 0;
    217216    virtual bool     renameItem(UICustomFileSystemItem *item, const QString &strOldPath) = 0;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette