mirror of
https://github.com/reactos/reactos.git
synced 2025-06-29 19:41:22 +00:00
[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3
Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
This commit is contained in:
parent
f1b60c66f0
commit
04e0dc4a7a
568 changed files with 115483 additions and 0 deletions
75
sdk/lib/ucrt/stdio/rmtmp.cpp
Normal file
75
sdk/lib/ucrt/stdio/rmtmp.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// rmtmp.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Defines _rmtmp(), which closes and removes all temporary files created by
|
||||
// tmpfile()
|
||||
//
|
||||
#include <corecrt_internal_stdio.h>
|
||||
|
||||
|
||||
|
||||
_CRT_LINKER_FORCE_INCLUDE(__acrt_tmpfile_terminator);
|
||||
|
||||
|
||||
|
||||
// These definitions will cause this object to be linked in whenever the
|
||||
// termination code requires it.
|
||||
#ifndef CRTDLL
|
||||
extern "C" unsigned __acrt_tmpfile_used = 1;
|
||||
#endif
|
||||
|
||||
extern "C" unsigned _tempoff = 1;
|
||||
extern "C" unsigned _old_pfxlen = 0;
|
||||
|
||||
|
||||
|
||||
// Closes and removes all temporary files created by tmpfile(). Returns the
|
||||
// number of streams that were closed.
|
||||
extern "C" int __cdecl _rmtmp()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
__acrt_lock(__acrt_stdio_index_lock);
|
||||
__try
|
||||
{
|
||||
for (int i = 0; i != _nstream; ++i)
|
||||
{
|
||||
__crt_stdio_stream stream(__piob[i]);
|
||||
|
||||
if (!stream.valid())
|
||||
continue;
|
||||
|
||||
_lock_file(stream.public_stream());
|
||||
__try
|
||||
{
|
||||
if (!stream.is_in_use())
|
||||
__leave;
|
||||
|
||||
if (stream->_tmpfname == nullptr)
|
||||
__leave;
|
||||
|
||||
// The stream is still in use. Close it:
|
||||
_fclose_nolock(stream.public_stream());
|
||||
++count;
|
||||
}
|
||||
__finally
|
||||
{
|
||||
_unlock_file(stream.public_stream());
|
||||
}
|
||||
}
|
||||
}
|
||||
__finally
|
||||
{
|
||||
__acrt_unlock(__acrt_stdio_index_lock);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
extern "C" void __cdecl __acrt_uninitialize_tmpfile()
|
||||
{
|
||||
__acrt_stdio_free_tmpfile_name_buffers_nolock();
|
||||
_rmtmp();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue