File tree Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 55
55
#include " Common/file.h"
56
56
57
57
#if USE_BUFFERED_IO
58
- #include < stdio.h >
58
+ #include " Utility/stdio_adapter.h "
59
59
#endif
60
60
61
61
// ----------------------------------------------------------------------------
@@ -100,6 +100,8 @@ class LocalFile : public File
100
100
virtual void close ( void ); // /< Close the file
101
101
virtual Int read ( void *buffer, Int bytes ); // /< Read the specified number of bytes in to buffer: See File::read
102
102
virtual Int write ( const void *buffer, Int bytes ); // /< Write the specified number of bytes from the buffer: See File::write
103
+ virtual Int writeFormat ( const Char* format, ... ); // /< Write an unterminated formatted string to the file
104
+ virtual Int writeFormat ( const WideChar* format, ... ); // /< Write an unterminated formatted string to the file
103
105
virtual Int seek ( Int new_pos, seekMode mode = CURRENT ); // /< Set file position: See File::seek
104
106
virtual Bool flush (); // /< flush data to disk
105
107
virtual void nextLine (Char *buf = NULL , Int bufSize = 0 ); // /< moves file position to after the next new-line
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ class RAMFile : public File
91
91
virtual void close ( void ); // /< Close the file
92
92
virtual Int read ( void *buffer, Int bytes ); // /< Read the specified number of bytes in to buffer: See File::read
93
93
virtual Int write ( const void *buffer, Int bytes ); // /< Write the specified number of bytes from the buffer: See File::write
94
+ virtual Int writeFormat ( const Char* format, ... ); // /< Write the formatted string to the file
95
+ virtual Int writeFormat ( const WideChar* format, ... ); // /< Write the formatted string to the file
94
96
virtual Int seek ( Int new_pos, seekMode mode = CURRENT ); // /< Set file position: See File::seek
95
97
virtual Bool flush (); // /< flush data to disk
96
98
virtual void nextLine (Char *buf = NULL , Int bufSize = 0 ); // /< moves current position to after the next new-line
Original file line number Diff line number Diff line change @@ -153,6 +153,14 @@ class File : public MemoryPoolObject
153
153
* memory pointed at by buffer to the file. Returns the number of bytes written.
154
154
* Returns -1 if an error occurred.
155
155
*/
156
+ virtual Int writeFormat ( const Char* format, ... ) = 0 ; /* *< Write an unterminated formatted string to the file
157
+ * Returns the number of bytes written.
158
+ * Returns -1 if an error occurred.
159
+ */
160
+ virtual Int writeFormat ( const WideChar* format, ... ) = 0 ; /* *< Write an unterminated formatted wide character string to the file
161
+ * Returns the number of bytes written.
162
+ * Returns -1 if an error occurred.
163
+ */
156
164
virtual Int seek ( Int bytes, seekMode mode = CURRENT ) = 0; /* *< Sets the file position of the next read/write operation. Returns the new file
157
165
* position as the number of bytes from the start of the file.
158
166
* Returns -1 if an error occurred.
Original file line number Diff line number Diff line change 47
47
48
48
#include " PreRTS.h"
49
49
50
- #include < stdio.h>
51
50
#include < fcntl.h>
52
51
#include < io.h>
53
52
#include < string.h>
@@ -381,6 +380,38 @@ Int LocalFile::write( const void *buffer, Int bytes )
381
380
return ret;
382
381
}
383
382
383
+ // =================================================================
384
+ // LocalFile::writeFormat - Ascii
385
+ // =================================================================
386
+
387
+ Int LocalFile::writeFormat ( const Char* format, ... )
388
+ {
389
+ char buffer[1024 ];
390
+
391
+ va_list args;
392
+ va_start (args, format);
393
+ Int length = vsnprintf (buffer, sizeof (buffer), format, args);
394
+ va_end (args);
395
+
396
+ return write ( buffer, length );
397
+ }
398
+
399
+ // =================================================================
400
+ // LocalFile::writeFormat - Wide character
401
+ // =================================================================
402
+
403
+ Int LocalFile::writeFormat ( const WideChar* format, ... )
404
+ {
405
+ WideChar buffer[1024 ];
406
+
407
+ va_list args;
408
+ va_start (args, format);
409
+ Int length = vswprintf (buffer, sizeof (buffer) / sizeof (WideChar), format, args);
410
+ va_end (args);
411
+
412
+ return write ( buffer, length * sizeof (WideChar) );
413
+ }
414
+
384
415
// =================================================================
385
416
// LocalFile::seek
386
417
// =================================================================
Original file line number Diff line number Diff line change @@ -294,6 +294,24 @@ Int RAMFile::write( const void *buffer, Int bytes )
294
294
return -1 ;
295
295
}
296
296
297
+ // =================================================================
298
+ // RAMFile::writeFormat - Ascii
299
+ // =================================================================
300
+
301
+ Int RAMFile::writeFormat ( const Char* format, ... )
302
+ {
303
+ return -1 ;
304
+ }
305
+
306
+ // =================================================================
307
+ // RAMFile::writeFormat - Wide character
308
+ // =================================================================
309
+
310
+ Int RAMFile::writeFormat ( const WideChar* format, ... )
311
+ {
312
+ return -1 ;
313
+ }
314
+
297
315
// =================================================================
298
316
// RAMFile::seek
299
317
// =================================================================
You can’t perform that action at this time.
0 commit comments