VirtualBox

Ignore:
Timestamp:
Jun 30, 2009 1:09:19 AM (15 years ago)
Author:
vboxsync
Message:

IPRT: Fixed RTStrmClearError so that it clears the error on the stream as well. Added RTStrmRewind. (Needed for #3897.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/stream.cpp

    r20823 r21045  
    299299    if (pStream && pStream->u32Magic == RTSTREAM_MAGIC)
    300300    {
     301        clearerr(pStream->pFile);
    301302        ASMAtomicXchgS32(&pStream->i32Error, VINF_SUCCESS);
    302303        rc = VINF_SUCCESS;
     
    307308        rc = VERR_INVALID_PARAMETER;
    308309    }
     310    return rc;
     311}
     312
     313
     314/**
     315 * Rewinds the stream.
     316 *
     317 * Stream errors will be reset on success.
     318 *
     319 * @returns IPRT status code.
     320 *
     321 * @param   pStream         The stream.
     322 *
     323 * @remarks Not all streams are rewindable and that behavior is currently
     324 *          undefined for those.
     325 */
     326RTR3DECL(int) RTStrmRewind(PRTSTREAM pStream)
     327{
     328    AssertPtrReturn(pStream, VERR_INVALID_HANDLE);
     329    AssertReturn(pStream->u32Magic == RTSTREAM_MAGIC, VERR_INVALID_HANDLE);
     330
     331    int rc;
     332    clearerr(pStream->pFile);
     333    errno = 0;
     334    if (!fseek(pStream->pFile, 0, SEEK_SET))
     335    {
     336        ASMAtomicXchgS32(&pStream->i32Error, VINF_SUCCESS);
     337        rc = VINF_SUCCESS;
     338    }
     339    else
     340    {
     341        rc = RTErrConvertFromErrno(errno);
     342        ASMAtomicXchgS32(&pStream->i32Error, rc);
     343    }
     344
    309345    return rc;
    310346}
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