| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Program Files (x86)/Windows Kits/10/Source/10.0.19041.0/ucrt/stdio/ |
Upload File : |
//
// rewind.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Defines rewind(), which rewinds a stream.
//
#include <corecrt_internal_stdio.h>
// Rewinds a stream back to the beginning, if the stream supports seeking. The
// stream is flushed and errors are cleared before the rewind.
extern "C" void __cdecl rewind(FILE* const public_stream)
{
__crt_stdio_stream const stream(public_stream);
_VALIDATE_RETURN_VOID(stream.valid(), EINVAL);
int const fh = _fileno(stream.public_stream());
_lock_file(stream.public_stream());
__try
{
// Flush the streeam, reset the error state, and seek back to the
// beginning:
__acrt_stdio_flush_nolock(stream.public_stream());
// If the stream is opened in update mode and is currently in use for reading,
// the buffer must be abandoned to ensure consistency when transitioning from
// reading to writing.
// __acrt_stdio_flush_nolock will not reset the buffer when _IOWRITE flag
// is not set.
__acrt_stdio_reset_buffer(stream);
stream.unset_flags(_IOERROR | _IOEOF);
_osfile_safe(fh) &= ~(FEOFLAG);
if (stream.has_all_of(_IOUPDATE))
stream.unset_flags(_IOREAD | _IOWRITE);
if (_lseek(fh, 0, 0) == -1)
stream.set_flags(_IOERROR);
}
__finally
{
_unlock_file(stream.public_stream());
}
}