Changeset 102393 in vbox
- Timestamp:
- Nov 30, 2023 12:58:05 PM (12 months ago)
- 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 208 208 } 209 209 210 QString UICustomFileSystemItem::path( bool fRemoveTrailingDelimiters /* = false */) const210 QString UICustomFileSystemItem::path() const 211 211 { 212 212 const QChar delimiter('/'); 213 Q_UNUSED(fRemoveTrailingDelimiters); 213 214 214 const UICustomFileSystemItem *pParent = this; 215 215 QStringList path; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICustomFileSystemModel.h
r102378 r102393 92 92 void setIsOpened(bool flag); 93 93 94 /** Full absolute path of the item. With or without the trailing '/' */ 95 QString path(bool fRemoveTrailingDelimiters = false) const; 94 QString path() const; 96 95 97 96 /** Returns true if this is directory and file object name is ".." */ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r102378 r102393 610 610 { 611 611 QVector<KDirectoryRemoveRecFlag> aFlags(1, KDirectoryRemoveRecFlag_ContentAndDir); 612 m_comGuestSession.DirectoryRemoveRecursive( item->path(), aFlags);612 m_comGuestSession.DirectoryRemoveRecursive(UIPathOperations::removeTrailingDelimiters(item->path()), aFlags); 613 613 } 614 614 else 615 m_comGuestSession.FsObjRemove( item->path());615 m_comGuestSession.FsObjRemove(UIPathOperations::removeTrailingDelimiters(item->path())); 616 616 if (!m_comGuestSession.isOk()) 617 617 { 618 618 emit sigLogOutput(QString(item->path()).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error); 619 619 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 }638 620 } 639 621 } … … 706 688 QVector<QString> aFilters; 707 689 QVector<QString> aFlags; 708 QString strDestinationPath = strDestination;690 QString strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestination); 709 691 710 692 /* Remove empty source paths. Typically happens when up directory is selected: */ … … 726 708 QString strDirectoryFlags("CopyIntoExisting,Recursive,FollowLinks"); 727 709 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]); 731 715 if (enmFileType == KFsObjType_Unknown) 732 emit sigLogOutput(QString("Querying information for host item %1 failed.").arg(s trSource), m_strTableName, FileManagerLogType_Error);716 emit sigLogOutput(QString("Querying information for host item %1 failed.").arg(sourcePaths[i]), m_strTableName, FileManagerLogType_Error); 733 717 /* If the source is an directory, make sure to add the appropriate flag to make copying work 734 718 * into existing directories on the guest. This otherwise would fail (default): */ 735 719 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);740 720 aFlags << strDirectoryFlags; 741 }742 721 else 743 {744 /* Ditto goes for source files, as the destination always is a directory path. */745 strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);746 722 aFlags << strFileFlags; 747 }748 723 } 749 724 … … 796 771 } 797 772 798 QString strDestinationPath = hostDestinationPath;773 QString strDestinationPath = UIPathOperations::addTrailingDelimiters(hostDestinationPath); 799 774 QString strDirectoryFlags("CopyIntoExisting,Recursive,FollowLinks"); 800 775 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]); 803 780 /** @todo Cache this info and use the item directly, which has this info already? */ 804 781 805 782 /* If the source is an directory, make sure to add the appropriate flag to make copying work 806 783 * into existing directories on the guest. This otherwise would fail (default). */ 807 CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(s trSource, true);784 CGuestFsObjInfo fileInfo = m_comGuestSession.FsObjQueryInfo(sourcePaths[i], true); 808 785 if (!m_comGuestSession.isOk()) 809 786 { … … 813 790 814 791 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 not818 * just it's contents. */819 strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);820 792 aFlags << strDirectoryFlags; 821 }822 793 else 823 {824 /* Ditto goes for source files, as the destination always is a directory path. */825 strDestinationPath = UIPathOperations::addTrailingDelimiters(strDestinationPath);826 794 aFlags << strFileFlags; 827 } 795 828 796 } 829 797 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r102378 r102393 83 83 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final; 84 84 virtual void deleteByItem(UICustomFileSystemItem *item) override final; 85 virtual void deleteByPath(const QStringList &pathList) override final;86 85 virtual void goToHomeDirectory() override final; 87 86 virtual bool renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r102378 r102393 284 284 { 285 285 QDir itemToDelete; 286 itemToDelete.remove( item->path());286 itemToDelete.remove(UIPathOperations::removeTrailingDelimiters(item->path())); 287 287 } 288 288 QDir itemToDelete(item->path()); … … 297 297 if (!deleteSuccess) 298 298 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 }320 299 } 321 300 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h
r102378 r102393 63 63 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final; 64 64 virtual void deleteByItem(UICustomFileSystemItem *item) override final; 65 virtual void deleteByPath(const QStringList &pathList) override final;66 65 virtual void goToHomeDirectory() override final; 67 66 virtual bool renameItem(UICustomFileSystemItem *item, const QString &strOldPath) override final; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r102378 r102393 1120 1120 if (!item) 1121 1121 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()); 1126 1123 } 1127 1124 return pathList; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r102378 r102393 213 213 virtual void readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0; 214 214 virtual void deleteByItem(UICustomFileSystemItem *item) = 0; 215 virtual void deleteByPath(const QStringList &pathList) = 0;216 215 virtual void goToHomeDirectory() = 0; 217 216 virtual bool renameItem(UICustomFileSystemItem *item, const QString &strOldPath) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.