VirtualBox

Changeset 35243 in vbox


Ignore:
Timestamp:
Dec 20, 2010 1:37:12 PM (14 years ago)
Author:
vboxsync
Message:

Main/GuestCtrlImpl: allow size 0 when copying a file to the guest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/GuestCtrlImpl.cpp

    r35231 r35243  
    300300                               && !fCompleted)
    301301                        {
    302                             vrc = RTFileRead(fileSource, (uint8_t*)aInputData.raw(), RT_MIN(cbToRead, _1M), &cbRead);
    303                             /*
    304                              * Some other error occured? There might be a chance that RTFileRead
    305                              * could not resolve/map the native error code to an IPRT code, so just
    306                              * print a generic error.
    307                              */
    308                             if (RT_FAILURE(vrc))
     302                            if (!cbToRead)
     303                                cbRead = 0;
     304                            else
    309305                            {
    310                                 rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
    311                                                                      Guest::tr("Could not read from file \"%s\" (%Rrc)"),
    312                                                                      aTask->strSource.c_str(), vrc);
    313                                 break;
     306                                vrc = RTFileRead(fileSource, (uint8_t*)aInputData.raw(),
     307                                                 RT_MIN(cbToRead, _1M), &cbRead);
     308                                /*
     309                                 * Some other error occured? There might be a chance that RTFileRead
     310                                 * could not resolve/map the native error code to an IPRT code, so just
     311                                 * print a generic error.
     312                                 */
     313                                if (RT_FAILURE(vrc))
     314                                {
     315                                    rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     316                                                                         Guest::tr("Could not read from file \"%s\" (%Rrc)"),
     317                                                                         aTask->strSource.c_str(), vrc);
     318                                    break;
     319                                }
    314320                            }
    315321
    316                             /* Resize buffer to reflect amount we just have read. */
    317                             if (cbRead > 0)
    318                                 aInputData.resize(cbRead);
     322                            /* Resize buffer to reflect amount we just have read.
     323                             * Size 0 is allowed! */
     324                            aInputData.resize(cbRead);
    319325
    320326                            ULONG uFlags = ProcessInputFlag_None;
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