ReactOS 0.4.16-dev-889-g9563c07
rmtmp.cpp
Go to the documentation of this file.
1//
2// rmtmp.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// Defines _rmtmp(), which closes and removes all temporary files created by
7// tmpfile()
8//
10
11
12
13_CRT_LINKER_FORCE_INCLUDE(__acrt_tmpfile_terminator);
14
15
16
17// These definitions will cause this object to be linked in whenever the
18// termination code requires it.
19#ifndef CRTDLL
20 extern "C" { unsigned __acrt_tmpfile_used = 1; }
21#endif
22
23extern "C" { unsigned _tempoff = 1; }
24extern "C" { unsigned _old_pfxlen = 0; }
25
26
27
28// Closes and removes all temporary files created by tmpfile(). Returns the
29// number of streams that were closed.
30extern "C" int __cdecl _rmtmp()
31{
32 int count = 0;
33
35 __try
36 {
37 for (int i = 0; i != _nstream; ++i)
38 {
40
41 if (!stream.valid())
42 continue;
43
44 _lock_file(stream.public_stream());
45 __try
46 {
47 if (!stream.is_in_use())
48 __leave;
49
50 if (stream->_tmpfname == nullptr)
51 __leave;
52
53 // The stream is still in use. Close it:
54 _fclose_nolock(stream.public_stream());
55 ++count;
56 }
58 {
59 _unlock_file(stream.public_stream());
60 }
62 }
63 }
65 {
67 }
69
70 return count;
71}
72
74{
76 _rmtmp();
77}
#define __cdecl
Definition: accygwin.h:79
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
Definition: locks.cpp:57
@ __acrt_stdio_index_lock
#define _CRT_LINKER_FORCE_INCLUDE(name)
int _nstream
__crt_stdio_stream_data ** __piob
__acrt_lock(__acrt_heap_lock)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP void __cdecl _unlock_file(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl _fclose_nolock(_Inout_ FILE *_File)
_CRTIMP void __cdecl _lock_file(_Inout_ FILE *_File)
#define __try
Definition: pseh2_64.h:188
#define __leave
Definition: pseh2_64.h:192
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
int __cdecl _rmtmp()
Definition: rmtmp.cpp:30
unsigned _tempoff
Definition: rmtmp.cpp:23
unsigned __acrt_tmpfile_used
Definition: rmtmp.cpp:20
void __cdecl __acrt_uninitialize_tmpfile()
Definition: rmtmp.cpp:73
unsigned _old_pfxlen
Definition: rmtmp.cpp:24
Definition: parse.h:23
void __cdecl __acrt_stdio_free_tmpfile_name_buffers_nolock()
Definition: tmpfile.cpp:49