Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
wwfile.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : G *
24 * *
25 * $Archive:: /G/wwlib/wwfile.cpp $*
26 * *
27 * $Author:: Eric_c $*
28 * *
29 * $Modtime:: 8/19/99 2:36p $*
30 * *
31 * $Revision:: 2 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#include <stdio.h>
38#include <stdarg.h>
39#include <memory.h>
40#include "wwfile.h"
41
42#pragma warning(disable : 4514)
43
44int FileClass::Printf(char *str, ...)
45{
46 char text[PRINTF_BUFFER_SIZE];
47 va_list args;
48 va_start(args, str);
49 int length = _vsnprintf(text, PRINTF_BUFFER_SIZE, str, args);
50 va_end(args);
51 return Write(text, length);
52}
53
54int FileClass::Printf(char *buffer, int bufferSize, char *str, ...)
55{
56 va_list args;
57 va_start(args, str);
58 int length = _vsnprintf(buffer, bufferSize, str, args);
59 va_end(args);
60 return Write(buffer, length);
61}
62
63int FileClass::Printf_Indented(unsigned depth, char *str, ...)
64{
65 char text[PRINTF_BUFFER_SIZE];
66 va_list args;
67 va_start(args, str);
68
69 if(depth > PRINTF_BUFFER_SIZE)
70 depth = PRINTF_BUFFER_SIZE;
71
72 memset(text, '\t', depth);
73
74 int length;
75 if(depth < PRINTF_BUFFER_SIZE)
76 length = _vsnprintf(text + depth, PRINTF_BUFFER_SIZE - depth, str, args);
77 else
78 length = PRINTF_BUFFER_SIZE;
79
80 va_end(args);
81
82 return Write(text, length + depth);
83}
84
int Printf_Indented(unsigned depth, char *str,...)
Definition wwfile.cpp:63
int Printf(char *str,...)
Definition wwfile.cpp:44
virtual int Write(void const *buffer, int size)=0
@ PRINTF_BUFFER_SIZE
Definition WWFILE.H:73