VirtualBox

Changeset 4372 in vbox for trunk


Ignore:
Timestamp:
Aug 24, 2007 9:21:51 PM (17 years ago)
Author:
vboxsync
Message:

Finally corrected the RTFileRead, RTFileReadAt, RTFileWrite and RTFileWriteAt APIs to size_t. This was long overdue.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/file.h

    r4071 r4372  
    188188 *                      If NULL an error will be returned for a partial read.
    189189 */
    190 RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, unsigned cbToRead, unsigned *pcbRead);
     190RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead);
    191191
    192192/**
     
    202202 *                      If NULL an error will be returned for a partial read.
    203203 */
    204 RTR3DECL(int)  RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, unsigned cbToRead, unsigned *pcbRead);
     204RTR3DECL(int)  RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
    205205
    206206/**
     
    214214 *                      If NULL an error will be returned for a partial write.
    215215 */
    216 RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, unsigned cbToWrite, unsigned *pcbWritten);
     216RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
    217217
    218218/**
     
    228228 *                      If NULL an error will be returned for a partial write.
    229229 */
    230 RTR3DECL(int)  RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, unsigned cbToWrite, unsigned *pcbWritten);
     230RTR3DECL(int)  RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
    231231
    232232/**
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r4071 r4372  
    247247             */
    248248            char achBuf[4096];
    249             unsigned cbRead = 0;
     249            size_t cbRead = 0;
    250250            rc = RTFileRead(pData->FileDevice, achBuf, sizeof(achBuf), &cbRead);
    251251            if (VBOX_SUCCESS(rc))
     
    318318            /* drain the pipe */
    319319            char ch;
    320             unsigned cbRead;
     320            size_t cbRead;
    321321            RTFileRead(pData->PipeRead, &ch, 1, &cbRead);
    322322        }
     
    369369                /* data waiting, read it. */
    370370                char        achBuf[4096];
    371                 unsigned    cbRead = 0;
     371                size_t      cbRead = 0;
    372372                int rc = RTFileRead(pData->FileDevice, achBuf, RT_MIN(sizeof(achBuf), cbMax), &cbRead);
    373373                if (VBOX_SUCCESS(rc))
  • trunk/src/VBox/Devices/Network/DrvTAPOs2.cpp

    r4071 r4372  
    281281        else
    282282        {
    283             LogFlow(("drvTAPOs2AsyncIoThread: RTFileRead -> %Vrc\n", rc));
     283            LogFlow(("drvTAPOs2AsyncIoThread: DoDevIOCtl -> %Vrc\n", rc));
    284284            if (rc == VERR_INVALID_HANDLE)
    285285                break;
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r4254 r4372  
    441441        {
    442442            /* Get a block of data from the host serial device. */
    443             unsigned cbRead;
     443            size_t cbRead;
    444444            rc = RTFileRead(pData->DeviceFile, abBuffer, sizeof(abBuffer), &cbRead);
    445445            if (VBOX_FAILURE(rc))
  • trunk/src/VBox/Devices/Serial/DrvNamedPipe.cpp

    r4071 r4372  
    140140        if (VBOX_FAILURE(rc))
    141141        {
    142             Log(("drvNamedPipeRead: RTFileRead returned %Vrc fShutdown=%d\n", rc, pData->fShutdown));
     142            Log(("drvNamedPipeRead: FileRead returned %Vrc fShutdown=%d\n", rc, pData->fShutdown));
    143143            if (    !pData->fShutdown
    144144                &&  (   rc == VERR_EOF
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r4071 r4372  
    18441844        }
    18451845
    1846         /*size_t*/unsigned cbRead;
     1846        size_t cbRead;
    18471847        rc = RTFileReadAt(pImage->File, 0, pImage->pDescData,
    18481848                          pImage->cbDescAlloc, &cbRead);
  • trunk/src/VBox/Devices/Storage/testcase/vditool.cpp

    r4355 r4372  
    127127                    while (off < cbFile)
    128128                    {
    129                         unsigned cbRead = 0;
     129                        size_t cbRead = 0;
    130130                        rc = RTFileRead(File, pvBuf, VDIDiskGetBufferSize(pVdi), &cbRead);
    131131                        if (VBOX_FAILURE(rc) || !cbRead)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r4370 r4372  
    24822482                    while (off < cbFile)
    24832483                    {
    2484                         unsigned cbRead = 0;
     2484                        size_t cbRead = 0;
    24852485                        rc = RTFileRead(File, pvBuf, VDIDiskGetBufferSize(pVdi), &cbRead);
    24862486                        if (VBOX_FAILURE(rc) || !cbRead)
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r4071 r4372  
    10351035{
    10361036    SHFLFILEHANDLE *pHandle = (SHFLFILEHANDLE *)vbsfQueryHandle(Handle, SHFL_HF_TYPE_FILE);
    1037     unsigned count = 0;
     1037    size_t count = 0;
    10381038    int rc;
    10391039
     
    10581058
    10591059    rc = RTFileRead(pHandle->file.Handle, pBuffer, *pcbBuffer, &count);
    1060     *pcbBuffer = count;
     1060    *pcbBuffer = (uint32_t)count;
    10611061    Log(("RTFileRead returned %Vrc bytes read %x\n", rc, count));
    10621062    return rc;
     
    10661066{
    10671067    SHFLFILEHANDLE *pHandle = (SHFLFILEHANDLE *)vbsfQueryHandle(Handle, SHFL_HF_TYPE_FILE);
    1068     unsigned count = 0;
     1068    size_t count = 0;
    10691069    int rc;
    10701070
     
    10781078
    10791079    if (*pcbBuffer == 0)
    1080         return VINF_SUCCESS; /* @todo correct? */
     1080        return VINF_SUCCESS; /** @todo correct? */
    10811081
    10821082    rc = RTFileSeek(pHandle->file.Handle, offset, RTFILE_SEEK_BEGIN, NULL);
     
    10881088
    10891089    rc = RTFileWrite(pHandle->file.Handle, pBuffer, *pcbBuffer, &count);
    1090     *pcbBuffer = count;
     1090    *pcbBuffer = (uint32_t)count;
    10911091    Log(("RTFileWrite returned %Vrc bytes written %x\n", rc, count));
    10921092    return rc;
  • trunk/src/VBox/Main/xml/cfgldr.cpp

    r4337 r4372  
    593593
    594594    // read from the file
    595     unsigned cbRead = 0;
     595    size_t cbRead = 0;
    596596    rc = RTFileRead (m_hFileHandle, toFill, maxToRead, &cbRead);
    597597    AssertRC (rc);
     
    603603    AssertRC (rc);
    604604
    605     return cbRead;
     605    return (unsigned int)cbRead;
    606606}
    607607
  • trunk/src/VBox/Runtime/fileio.cpp

    r4071 r4372  
    154154 *                      If NULL an error will be returned for a partial read.
    155155 */
    156 RTR3DECL(int)  RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, unsigned cbToRead, unsigned *pcbRead)
     156RTR3DECL(int)  RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    157157{
    158158    int rc = RTFileSeek(File, off, RTFILE_SEEK_BEGIN, NULL);
     
    175175 *                      If NULL an error will be returned for a partial write.
    176176 */
    177 RTR3DECL(int)  RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, unsigned cbToWrite, unsigned *pcbWritten)
     177RTR3DECL(int)  RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
    178178{
    179179    int rc = RTFileSeek(File, off, RTFILE_SEEK_BEGIN, NULL);
  • trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp

    r4071 r4372  
    254254
    255255
    256 RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, unsigned cbToRead, unsigned *pcbRead)
     256RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    257257{
    258258    if (cbToRead <= 0)
     
    278278                    if (cbReadPart == 0)
    279279                        return VERR_EOF;
    280                     else
    281                         return RTErrConvertFromErrno(errno);
     280                    return RTErrConvertFromErrno(errno);
    282281                }
    283282                cbRead += cbReadPart;
     
    291290
    292291
    293 RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, unsigned cbToWrite, unsigned *pcbWritten)
     292RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
    294293{
    295294    if (cbToWrite <= 0)
  • trunk/src/VBox/Runtime/r3/win32/fileio-win32.cpp

    r4071 r4372  
    284284
    285285
    286 RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, unsigned cbToRead, unsigned *pcbRead)
     286RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    287287{
    288288    if (cbToRead <= 0)
     
    314314
    315315
    316 RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, unsigned cbToWrite, unsigned *pcbWritten)
     316RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
    317317{
    318318    if (cbToWrite <= 0)
  • trunk/src/VBox/Runtime/testcase/tstFile.cpp

    r4071 r4372  
    7575        }
    7676        static const char szTestBuf[] = "Sausages and bacon for breakfast again!";
    77         unsigned cbWritten = 0;
     77        size_t cbWritten = 0;
    7878        while (cbWritten < sizeof(szTestBuf))
    7979        {
    80             unsigned cbWrittenPart;
     80            size_t cbWrittenPart;
    8181            rc = RTFileWrite(File, &szTestBuf[cbWritten], sizeof(szTestBuf) - cbWritten, &cbWrittenPart);
    8282            if (RT_FAILURE(rc))
     
    101101            {
    102102                char        szReadBuf[sizeof(szTestBuf)];
    103                 unsigned    cbRead = 0;
     103                size_t      cbRead = 0;
    104104                while (cbRead < sizeof(szTestBuf))
    105105                {
    106                     unsigned cbReadPart;
     106                    size_t cbReadPart;
    107107                    rc = RTFileRead(File, &szReadBuf[cbRead], sizeof(szTestBuf) - cbRead, &cbReadPart);
    108108                    if (RT_FAILURE(rc))
     
    147147            else
    148148            {
    149                 unsigned cbWritten = 0;
     149                size_t cbWritten = 0;
    150150                while (cbWritten < sizeof(szTestBuf))
    151151                {
    152                     unsigned cbWrittenPart;
     152                    size_t cbWrittenPart;
    153153                    rc = RTFileWrite(File, &szTestBuf[cbWritten], sizeof(szTestBuf) - cbWritten, &cbWrittenPart);
    154154                    if (RT_FAILURE(rc))
     
    172172                    {
    173173                        char        szReadBuf[sizeof(szTestBuf)];
    174                         unsigned    cbRead = 0;
     174                        size_t      cbRead = 0;
    175175                        while (cbRead < sizeof(szTestBuf))
    176176                        {
    177                             unsigned cbReadPart;
     177                            size_t cbReadPart;
    178178                            rc = RTFileRead(File, &szReadBuf[cbRead], sizeof(szTestBuf) - cbRead, &cbReadPart);
    179179                            if (RT_FAILURE(rc))
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r4206 r4372  
    284284
    285285            /* read a page from the file */
    286             unsigned cbRead = 0;
     286            size_t cbRead = 0;
    287287            uint8_t au8Page[PAGE_SIZE * 16];
    288288            rc = RTFileRead(File, &au8Page, sizeof(au8Page), &cbRead);
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