Changeset 79968 in vbox
- Timestamp:
- Jul 25, 2019 1:28:23 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132399
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r79965 r79968 825 825 AutoCaller mParentCaller; 826 826 }; 827 828 829 830 /** 831 * Converts the Medium device type to the VD type. 832 */ 833 static const char *getVDTypeName(VDTYPE enmType) 834 { 835 switch (enmType) 836 { 837 case VDTYPE_HDD: return "HDD"; 838 case VDTYPE_OPTICAL_DISC: return "DVD"; 839 case VDTYPE_FLOPPY: return "floppy"; 840 case VDTYPE_INVALID: return "invalid"; 841 default: 842 AssertFailedReturn("unknown"); 843 } 844 } 845 846 /** 847 * Converts the Medium device type to the VD type. 848 */ 849 static const char *getDeviceTypeName(DeviceType_T enmType) 850 { 851 switch (enmType) 852 { 853 case DeviceType_HardDisk: return "HDD"; 854 case DeviceType_DVD: return "DVD"; 855 case DeviceType_Floppy: return "floppy"; 856 case DeviceType_Null: return "null"; 857 case DeviceType_Network: return "network"; 858 case DeviceType_USB: return "USB"; 859 case DeviceType_SharedFolder: return "shared folder"; 860 case DeviceType_Graphics3D: return "graphics 3d"; 861 default: 862 AssertFailedReturn("unknown"); 863 } 864 } 865 827 866 828 867 … … 7619 7658 if (isImport) 7620 7659 { 7621 VDTYPE const enmDesiredType = m->devType == DeviceType_Floppy ? VDTYPE_FLOPPY 7622 : m->devType == DeviceType_DVD ? VDTYPE_OPTICAL_DISC 7623 : m->devType == DeviceType_HardDisk ? VDTYPE_HDD : VDTYPE_INVALID; 7660 VDTYPE const enmDesiredType = i_convertDeviceType(); 7624 7661 VDTYPE enmType = VDTYPE_INVALID; 7625 7662 char *backendName = NULL; 7626 7663 7627 int vrc = VINF_SUCCESS;7628 7629 7664 /* is it a file? */ 7630 { 7631 RTFILE file; 7632 vrc = RTFileOpen(&file, locationFull.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 7633 if (RT_SUCCESS(vrc)) 7634 RTFileClose(file); 7635 } 7665 RTFILE hFile; 7666 int vrc = RTFileOpen(&hFile, locationFull.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 7636 7667 if (RT_SUCCESS(vrc)) 7637 7668 { 7669 RTFileClose(hFile); 7638 7670 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 7639 7671 locationFull.c_str(), enmDesiredType, &backendName, &enmType); … … 7656 7688 tr("Permission problem accessing the file for the medium '%s' (%Rrc)"), 7657 7689 locationFull.c_str(), vrc); 7658 elseif (vrc == VERR_FILE_NOT_FOUND || vrc == VERR_PATH_NOT_FOUND)7690 if (vrc == VERR_FILE_NOT_FOUND || vrc == VERR_PATH_NOT_FOUND) 7659 7691 return setErrorBoth(VBOX_E_FILE_ERROR, vrc, 7660 7692 tr("Could not find file for the medium '%s' (%Rrc)"), 7661 7693 locationFull.c_str(), vrc); 7662 elseif (aFormat.isEmpty())7694 if (aFormat.isEmpty()) 7663 7695 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, 7664 7696 tr("Could not get the storage format of the medium '%s' (%Rrc)"), 7665 7697 locationFull.c_str(), vrc); 7666 else 7667 { 7668 HRESULT rc = i_setFormat(aFormat); 7669 /* setFormat() must not fail since we've just used the backend so 7670 * the format object must be there */ 7671 AssertComRCReturnRC(rc); 7672 } 7698 HRESULT rc = i_setFormat(aFormat); 7699 /* setFormat() must not fail since we've just used the backend so 7700 * the format object must be there */ 7701 AssertComRCReturnRC(rc); 7673 7702 } 7674 7703 else if ( enmType == VDTYPE_INVALID … … 7679 7708 * by the backend. 7680 7709 */ 7710 RTStrFree(backendName); 7681 7711 return setError(E_FAIL, 7682 tr("The medium '%s' can't be used as the requested device type "),7683 locationFull.c_str() );7712 tr("The medium '%s' can't be used as the requested device type (%s, detected %s)"), 7713 locationFull.c_str(), getDeviceTypeName(m->devType), getVDTypeName(enmType)); 7684 7714 } 7685 7715 else
Note:
See TracChangeset
for help on using the changeset viewer.