1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "stdafx.h"
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include "vmtcheck_util.h"
#include "tier0/dbg.h"
extern bool uselogfile;
//-----------------------------------------------------------------------------
// Purpose:
// Input : depth -
// *fmt -
// ... -
//-----------------------------------------------------------------------------
void vprint( int depth, const char *fmt, ... )
{
char string[ 8192 ];
va_list va;
va_start( va, fmt );
vsprintf( string, fmt, va );
va_end( va );
FILE *fp = NULL;
if ( uselogfile )
{
fp = fopen( "log.txt", "ab" );
}
while ( depth-- > 0 )
{
printf( " " );
OutputDebugString( " " );
if ( fp )
{
fprintf( fp, " " );
}
}
::printf( "%s", string );
OutputDebugString( string );
if ( fp )
{
char *p = string;
while ( *p )
{
if ( *p == '\n' )
{
fputc( '\r', fp );
}
fputc( *p, fp );
p++;
}
fclose( fp );
}
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *name -
// *len -
// Output : unsigned char
//-----------------------------------------------------------------------------
unsigned char *COM_LoadFile( const char *name, int *len)
{
FILE *fp;
fp = fopen( name, "rb" );
if ( !fp )
{
*len = 0;
return NULL;
}
fseek( fp, 0, SEEK_END );
*len = ftell( fp );
fseek( fp, 0, SEEK_SET );
unsigned char *buffer = new unsigned char[ *len + 1 ];
fread( buffer, *len, 1, fp );
fclose( fp );
buffer[ *len ] = 0;
return buffer;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *buffer -
//-----------------------------------------------------------------------------
void COM_FreeFile( unsigned char *buffer )
{
delete[] buffer;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *dir -
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool COM_DirectoryExists( const char *dir )
{
if ( !_access( dir, 0 ) )
return true;
return false;
}
|