Changeset 72067 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 30, 2018 10:27:37 AM (7 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r72053 r72067 11145 11145 11146 11146 <enum 11147 name="GuestCopyFlag"11148 uuid="84d6430f-dfe6-4415-a26d-3cdde1c3205a"11149 >11150 <desc>11151 Flags for use when copying elements from or to the guest, see11152 <link to="IGuestSession::copyFromGuest"/> and11153 <link to="IGuestSession::copyToGuest"/>.11154 </desc>11155 11156 <const name="NoReplace" value="0">11157 <desc>Do not replace any destination object.</desc>11158 </const>11159 <const name="Replace" value="1">11160 <desc>This will attempt to replace any destination object other except11161 directories. (The default is to fail if the destination exists.)</desc>11162 </const>11163 <const name="CopyIntoExisting" value="2">11164 <desc>Allow copying into an existing destination directory.</desc>11165 </const>11166 <const name="Recursive" value="4">11167 <desc>Copies directories recursively.</desc>11168 </const>11169 <const name="FollowSymlinks" value="8">11170 <desc>Follows (and handles) symbolic links.</desc>11171 </const>11172 </enum>11173 11174 <enum11175 11147 name="ProcessCreateFlag" 11176 11148 uuid="C544CD2B-F02D-4886-9901-71C523DB8DC5" … … 11898 11870 <interface 11899 11871 name="IGuestSession" extends="$unknown" 11900 uuid=" a71fcf9a-a45e-440a-886a-5b4c664195ef"11872 uuid="9880f6e3-c4c1-4031-8ec2-28ee088370e4" 11901 11873 wsmap="managed" 11902 11874 reservedMethods="8" reservedAttributes="8" … … 12074 12046 </param> 12075 12047 <param name="filters" type="wstring" dir="in" safearray="yes"> 12076 <desc>Array of filters corresponding to the sources. This uses the12048 <desc>Array of source filters. This uses the 12077 12049 DOS/NT style wildcard characters '?' and '*'.</desc> 12078 12050 </param> 12079 12051 <param name="types" type="FsObjType" dir="in" safearray="yes"> 12080 <desc>Array of <link to="FsObjType"/> types which define the type of 12081 source entries.</desc> 12082 </param> 12083 <param name="flags" type="GuestCopyFlag" dir="in" safearray="yes"> 12084 <desc>Array of <link to="GuestCopyFlag"/> flags corresponding to the 12085 sources.</desc> 12052 <desc>Array of source <link to="FsObjType"/> types.</desc> 12053 </param> 12054 <param name="flags" type="wstring" dir="in" safearray="yes"> 12055 <desc>Array of comma-separated list of source flags. 12056 12057 The following flags are available for directory sources: 12058 12059 <table> 12060 <tr> 12061 <td>CopyIntoExisting</td> 12062 <td>Allow copying into an existing destination directory.</td> 12063 </tr> 12064 </table> 12065 12066 The following flags are available for file sources: 12067 12068 <table> 12069 <tr> 12070 <td>NoReplace</td> 12071 <td>Do not replace any destination object.</td> 12072 </tr> 12073 <tr> 12074 <td>FollowLinks</td> 12075 <td>Follows (and handles) (symbolic) links.</td> 12076 </tr> 12077 <tr> 12078 <td>Update</td> 12079 <td>Only copy when the source file is newer than the destination 12080 file or when the destination file is missing.</td> 12081 </tr> 12082 </table> 12083 12084 </desc> 12086 12085 </param> 12087 12086 <param name="destination" type="wstring" dir="in"> … … 12105 12104 </param> 12106 12105 <param name="filters" type="wstring" dir="in" safearray="yes"> 12107 <desc>Array of filters corresponding to the sources. This uses the12106 <desc>Array of source filters. This uses the 12108 12107 DOS/NT style wildcard characters '?' and '*'.</desc> 12109 12108 </param> 12110 12109 <param name="types" type="FsObjType" dir="in" safearray="yes"> 12111 <desc>Array of <link to="FsObjType"/> types which define the type of 12112 source entries.</desc> 12113 </param> 12114 <param name="flags" type="GuestCopyFlag" dir="in" safearray="yes"> 12115 <desc>Array of <link to="GuestCopyFlag"/> flags corresponding to the 12116 sources.</desc> 12110 <desc>Array of source <link to="FsObjType"/> types.</desc> 12111 </param> 12112 <param name="flags" type="wstring" dir="in" safearray="yes"> 12113 <desc>Array of comma-separated list of source flags. 12114 12115 The following flags are available for directory sources: 12116 12117 <table> 12118 <tr> 12119 <td>CopyIntoExisting</td> 12120 <td>Allow copying into an existing destination directory.</td> 12121 </tr> 12122 </table> 12123 12124 The following flags are available for file sources: 12125 12126 <table> 12127 <tr> 12128 <td>NoReplace</td> 12129 <td>Do not replace any destination object.</td> 12130 </tr> 12131 <tr> 12132 <td>FollowLinks</td> 12133 <td>Follows (and handles) (symbolic) links.</td> 12134 </tr> 12135 <tr> 12136 <td>Update</td> 12137 <td>Only copy when the source file is newer than the destination 12138 file or when the destination file is missing.</td> 12139 </tr> 12140 </table> 12141 12142 </desc> 12117 12143 </param> 12118 12144 <param name="destination" type="wstring" dir="in"> -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r72001 r72067 84 84 const std::vector<com::Utf8Str> &aFilters, 85 85 const std::vector<FsObjType_T> &aTypes, 86 const std::vector< GuestCopyFlag_T> &aFlags,86 const std::vector<com::Utf8Str> &aFlags, 87 87 const com::Utf8Str &aDestination, 88 88 ComPtr<IProgress> &aProgress); … … 90 90 const std::vector<com::Utf8Str> &aFilters, 91 91 const std::vector<FsObjType_T> &aTypes, 92 const std::vector< GuestCopyFlag_T> &aFlags,92 const std::vector<com::Utf8Str> &aFlags, 93 93 const com::Utf8Str &aDestination, 94 94 ComPtr<IProgress> &aProgress); … … 267 267 ComPtr<IProgress> &pProgress); 268 268 int i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc); 269 static int i_directoryCopyFlagFromStr(const com::Utf8Str &strFlags, DirectoryCopyFlag_T *pfFlags); 269 270 inline bool i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir); 270 271 int i_directoryUnregister(GuestDirectory *pDirectory); … … 276 277 int i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 277 278 int i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 279 static int i_fileCopyFlagFromStr(const com::Utf8Str &strFlags, FileCopyFlag_T *pfFlags); 278 280 inline bool i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile); 279 281 int i_fileUnregister(GuestFile *pFile); -
trunk/src/VBox/Main/include/GuestSessionImplTasks.h
r72045 r72067 42 42 struct GuestSessionFsSourceSpec 43 43 { 44 GuestSessionFsSourceSpec() 45 : enmType(FsObjType_Unknown) 46 , enmPathStyle(PathStyle_Unknown) 47 , fDryRun(false) 48 , fFollowSymlinks(false) { } 49 44 50 Utf8Str strSource; 45 51 Utf8Str strFilter; -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r72045 r72067 748 748 return setError(E_INVALIDARG, tr("No destination specified")); 749 749 750 GuestSessionFsSourceSet::const_iterator itSource = SourceSet.begin();751 while (itSource != SourceSet.end())752 {753 if (itSource->enmType == FsObjType_Directory)754 {755 if (itSource->Type.Dir.fCopyFlags)756 {757 if (!(itSource->Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting))758 return setError(E_INVALIDARG, tr("Invalid / not (yet) implemented directory copy flags specified"));759 }760 }761 else if (itSource->enmType == FsObjType_File)762 {763 if (itSource->Type.File.fCopyFlags)764 {765 if ( !(itSource->Type.File.fCopyFlags & FileCopyFlag_NoReplace)766 && !(itSource->Type.File.fCopyFlags & FileCopyFlag_FollowLinks)767 && !(itSource->Type.File.fCopyFlags & FileCopyFlag_Update))768 {769 return setError(E_NOTIMPL, tr("Invalid / not (yet) implemented file copy flag(s) specified"));770 }771 }772 }773 else774 return setError(E_NOTIMPL, tr("Source type %RU32 not implemented"), itSource->enmType);775 776 itSource++;777 }778 779 750 try 780 751 { … … 849 820 return setError(E_INVALIDARG, tr("No destination specified")); 850 821 851 GuestSessionFsSourceSet::const_iterator itSource = SourceSet.begin();852 while (itSource != SourceSet.end())853 {854 if (itSource->enmType == FsObjType_Directory)855 {856 if (itSource->Type.Dir.fCopyFlags)857 {858 if (!(itSource->Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting))859 return setError(E_INVALIDARG, tr("Invalid / not (yet) implemented directory copy flags specified"));860 }861 }862 else if (itSource->enmType == FsObjType_File)863 {864 if (itSource->Type.File.fCopyFlags)865 {866 if ( !(itSource->Type.File.fCopyFlags & FileCopyFlag_NoReplace)867 && !(itSource->Type.File.fCopyFlags & FileCopyFlag_FollowLinks)868 && !(itSource->Type.File.fCopyFlags & FileCopyFlag_Update))869 {870 return setError(E_NOTIMPL, tr("Invalid / not (yet) implemented file copy flag(s) specified"));871 }872 }873 }874 else875 return setError(E_NOTIMPL, tr("Source type %RU32 not implemented"), itSource->enmType);876 877 itSource++;878 }879 880 822 try 881 823 { … … 924 866 LogFlowFunc(("Returning %Rhrc\n", hrc)); 925 867 return hrc; 868 } 869 870 /** 871 * Validates and extracts directory copy flags from a comma-separated string. 872 * 873 * @return VBox status code. 874 * @param strFlags String to extract flags from. 875 * @param pfFlags Where to store the extracted (and validated) flags. 876 */ 877 /* static */ 878 int GuestSession::i_directoryCopyFlagFromStr(const com::Utf8Str &strFlags, DirectoryCopyFlag_T *pfFlags) 879 { 880 DirectoryCopyFlag_T fFlags = DirectoryCopyFlag_None; 881 882 /* Validate and set flags. */ 883 if (strFlags.isEmpty()) 884 { 885 *pfFlags = fFlags; 886 return VINF_SUCCESS; 887 } 888 889 const char *pcszNext = strFlags.c_str(); 890 while (*pcszNext != '\0') 891 { 892 Utf8Str strFlag; 893 const char *pcszComma = RTStrStr(pcszNext, ","); 894 if (!pcszComma) 895 strFlag = pcszNext; 896 else 897 strFlag = Utf8Str(pcszNext, pcszComma - pcszNext); 898 899 const char *pcszEqual = RTStrStr(strFlag.c_str(), "="); 900 if ( pcszEqual 901 && pcszEqual != strFlag.c_str()) 902 { 903 Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str()); 904 Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1)); 905 RT_NOREF(strKey, strValue); /* We don't have any key=value pairs yet. */ 906 } 907 else 908 { 909 if (strFlag == "CopyIntoExisting") 910 fFlags |= DirectoryCopyFlag_CopyIntoExisting; 911 else 912 return VERR_INVALID_PARAMETER; 913 } 914 915 if (!pcszComma) 916 pcszNext += strFlag.length(); 917 else 918 pcszNext += strFlag.length() + 1; 919 } 920 921 if (pfFlags) 922 *pfFlags = fFlags; 923 924 return VINF_SUCCESS; 926 925 } 927 926 … … 1344 1343 LogFlowFuncLeaveRC(rc); 1345 1344 return rc; 1345 } 1346 1347 /** 1348 * Validates and extracts file copy flags from a comma-separated string. 1349 * 1350 * @return VBox status code. 1351 * @param strFlags String to extract flags from. 1352 * @param pfFlags Where to store the extracted (and validated) flags. 1353 */ 1354 /* static */ 1355 int GuestSession::i_fileCopyFlagFromStr(const com::Utf8Str &strFlags, FileCopyFlag_T *pfFlags) 1356 { 1357 FileCopyFlag_T fFlags = FileCopyFlag_None; 1358 1359 /* Validate and set flags. */ 1360 if (strFlags.isEmpty()) 1361 { 1362 *pfFlags = fFlags; 1363 return VINF_SUCCESS; 1364 } 1365 1366 const char *pcszNext = strFlags.c_str(); 1367 while (*pcszNext != '\0') 1368 { 1369 Utf8Str strFlag; 1370 const char *pcszComma = RTStrStr(pcszNext, ","); 1371 if (!pcszComma) 1372 strFlag = pcszNext; 1373 else 1374 strFlag = Utf8Str(pcszNext, pcszComma - pcszNext); 1375 1376 const char *pcszEqual = RTStrStr(strFlag.c_str(), "="); 1377 if ( pcszEqual 1378 && pcszEqual != strFlag.c_str()) 1379 { 1380 Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str()); 1381 Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1)); 1382 RT_NOREF(strKey, strValue); /* We don't have any key=value pairs yet. */ 1383 } 1384 else 1385 { 1386 if (strFlag == "NoReplace") 1387 fFlags |= FileCopyFlag_NoReplace; 1388 else if (strFlag == "FollowLinks") 1389 fFlags |= FileCopyFlag_FollowLinks; 1390 else if (strFlag == "Update") 1391 fFlags |= FileCopyFlag_Update; 1392 else 1393 return VERR_INVALID_PARAMETER; 1394 } 1395 1396 if (!pcszComma) 1397 pcszNext += strFlag.length(); 1398 else 1399 pcszNext += strFlag.length() + 1; 1400 } 1401 1402 if (pfFlags) 1403 *pfFlags = fFlags; 1404 1405 return VINF_SUCCESS; 1346 1406 } 1347 1407 … … 2851 2911 2852 2912 HRESULT GuestSession::copyFromGuest(const std::vector<com::Utf8Str> &aSources, const std::vector<com::Utf8Str> &aFilters, 2853 const std::vector<FsObjType_T> &aTypes, const std::vector< GuestCopyFlag_T> &aFlags,2913 const std::vector<FsObjType_T> &aTypes, const std::vector<com::Utf8Str> &aFlags, 2854 2914 const com::Utf8Str &aDestination, ComPtr<IProgress> &aProgress) 2855 2915 { … … 2867 2927 GuestSessionFsSourceSet SourceSet; 2868 2928 2869 std::vector<com::Utf8Str>::const_iterator itSource 2870 std::vector<com::Utf8Str>::const_iterator itFilter 2871 std::vector<FsObjType_T>::const_iterator itType= aTypes.begin();2872 std::vector< GuestCopyFlag_T>::const_iterator itFlag= aFlags.begin();2929 std::vector<com::Utf8Str>::const_iterator itSource = aSources.begin(); 2930 std::vector<com::Utf8Str>::const_iterator itFilter = aFilters.begin(); 2931 std::vector<FsObjType_T>::const_iterator itType = aTypes.begin(); 2932 std::vector<com::Utf8Str>::const_iterator itFlags = aFlags.begin(); 2873 2933 2874 2934 while (itSource != aSources.end()) … … 2880 2940 source.enmPathStyle = i_getPathStyle(); 2881 2941 2882 if (*itType == FsObjType_Directory) 2883 { 2884 source.Type.Dir.fCopyFlags = (DirectoryCopyFlag_T)*itFlag; 2942 if (source.enmType == FsObjType_Directory) 2943 { 2944 int rc2 = GuestSession::i_directoryCopyFlagFromStr(*itFlags, &source.Type.Dir.fCopyFlags); 2945 if (RT_FAILURE(rc2)) 2946 return setError(E_INVALIDARG, tr("Invalid / not (yet) implemented directory copy flags specified")); 2947 2885 2948 source.Type.Dir.fRecursive = true; /* Implicit. */ 2886 2949 } 2950 else if (source.enmType == FsObjType_File) 2951 { 2952 int rc2 = GuestSession::i_fileCopyFlagFromStr(*itFlags, &source.Type.File.fCopyFlags); 2953 if (RT_FAILURE(rc2)) 2954 return setError(E_NOTIMPL, tr("Invalid / not (yet) implemented file copy flag(s) specified")); 2955 } 2887 2956 else 2888 { 2889 source.Type.File.fCopyFlags = (FileCopyFlag_T)*itFlag; 2890 } 2957 return setError(E_INVALIDARG, tr("Source type %d invalid / not supported"), source.enmType); 2891 2958 2892 2959 SourceSet.push_back(source); … … 2895 2962 ++itFilter; 2896 2963 ++itType; 2897 ++itFlag ;2964 ++itFlags; 2898 2965 } 2899 2966 … … 2902 2969 2903 2970 HRESULT GuestSession::copyToGuest(const std::vector<com::Utf8Str> &aSources, const std::vector<com::Utf8Str> &aFilters, 2904 const std::vector<FsObjType_T> &aTypes, const std::vector< GuestCopyFlag_T> &aFlags,2971 const std::vector<FsObjType_T> &aTypes, const std::vector<com::Utf8Str> &aFlags, 2905 2972 const com::Utf8Str &aDestination, ComPtr<IProgress> &aProgress) 2906 2973 { … … 2918 2985 GuestSessionFsSourceSet SourceSet; 2919 2986 2920 std::vector<com::Utf8Str>::const_iterator itSource 2921 std::vector<com::Utf8Str>::const_iterator itFilter 2922 std::vector<FsObjType_T>::const_iterator itType= aTypes.begin();2923 std::vector< GuestCopyFlag_T>::const_iterator itFlag= aFlags.begin();2987 std::vector<com::Utf8Str>::const_iterator itSource = aSources.begin(); 2988 std::vector<com::Utf8Str>::const_iterator itFilter = aFilters.begin(); 2989 std::vector<FsObjType_T>::const_iterator itType = aTypes.begin(); 2990 std::vector<com::Utf8Str>::const_iterator itFlags = aFlags.begin(); 2924 2991 2925 2992 while (itSource != aSources.end()) 2926 2993 { 2927 2928 2994 GuestSessionFsSourceSpec source; 2929 2995 source.strSource = *itSource; … … 2932 2998 source.enmPathStyle = i_getPathStyle(); 2933 2999 2934 if (*itType == FsObjType_Directory) 2935 { 2936 source.Type.Dir.fCopyFlags = (DirectoryCopyFlag_T)*itFlag; 3000 if (source.enmType == FsObjType_Directory) 3001 { 3002 int rc2 = GuestSession::i_directoryCopyFlagFromStr(*itFlags, &source.Type.Dir.fCopyFlags); 3003 if (RT_FAILURE(rc2)) 3004 return setError(E_INVALIDARG, tr("Invalid / not (yet) implemented directory copy flags specified")); 3005 2937 3006 source.Type.Dir.fRecursive = true; /* Implicit. */ 2938 3007 } 3008 else if (source.enmType == FsObjType_File) 3009 { 3010 int rc2 = GuestSession::i_fileCopyFlagFromStr(*itFlags, &source.Type.File.fCopyFlags); 3011 if (RT_FAILURE(rc2)) 3012 return setError(E_NOTIMPL, tr("Invalid / not (yet) implemented file copy flag(s) specified")); 3013 } 2939 3014 else 2940 source.Type.File.fCopyFlags = (FileCopyFlag_T)*itFlag;3015 return setError(E_INVALIDARG, tr("Source type %d invalid / not supported"), source.enmType); 2941 3016 2942 3017 SourceSet.push_back(source); … … 2945 3020 ++itFilter; 2946 3021 ++itType; 2947 ++itFlag ;3022 ++itFlags; 2948 3023 } 2949 3024
Note:
See TracChangeset
for help on using the changeset viewer.