From d5bc752e9d104ec662fb67b4cfb8f0030a65f4d5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 4 Dec 2003 04:26:49 +0000 Subject: [PATCH] add RageFile::PutLine --- stepmania/src/RageFile.cpp | 13 +++++++++++++ stepmania/src/RageFile.h | 1 + 2 files changed, 14 insertions(+) diff --git a/stepmania/src/RageFile.cpp b/stepmania/src/RageFile.cpp index ace4fa275a..354ea556dc 100644 --- a/stepmania/src/RageFile.cpp +++ b/stepmania/src/RageFile.cpp @@ -125,6 +125,19 @@ void RageFile::GetLine( CString &out ) } } +#if defined(_WIN32) +#define NEWLINE "\r\n" +#else +#define NEWLINE "\n" +#endif + +int RageFile::PutLine( const CString &str ) +{ + if( Write(str.data(), str.size()) == -1 ) + return -1; + return Write( NEWLINE, strlen(NEWLINE) ); +} + int RageFile::Read( void *buffer, size_t bytes ) { if( !IsOpen() ) diff --git a/stepmania/src/RageFile.h b/stepmania/src/RageFile.h index ec52f9abee..94d57aff1d 100644 --- a/stepmania/src/RageFile.h +++ b/stepmania/src/RageFile.h @@ -57,6 +57,7 @@ public: bool PutString(const CString& string) { return fputs(string, mFP) >= 0; } int Read(void *buffer, size_t bytes); int Write(const void *buffer, size_t bytes); + int PutLine( const CString &str ); /* Line-based I/O: */ CString GetLine();