Files
itgmania212121/stepmania/src/RageFile.h
T

56 lines
1.5 KiB
C++
Raw Normal View History

2003-12-03 20:37:10 +00:00
#ifndef RAGE_FILE_H
#define RAGE_FILE_H
2003-07-22 07:47:27 +00:00
/*
-----------------------------------------------------------------------------
Class: RageFile
Desc: Encapsulates C and C++ file classes to deal with arch-specific oddities.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
2003-12-03 20:37:10 +00:00
Steve Checkoway
2003-07-22 07:47:27 +00:00
-----------------------------------------------------------------------------
*/
2003-11-27 07:46:36 +00:00
#include <cstdio>
2003-07-22 07:47:27 +00:00
// call FixSlashes on any path that came from the user
2003-07-22 07:47:27 +00:00
void FixSlashesInPlace( CString &sPath );
CString FixSlashes( CString sPath );
void CollapsePath( CString &sPath );
2003-11-27 07:46:36 +00:00
class RageFile
{
private:
FILE *mFP;
CString mPath;
public:
RageFile() : mPath("") { mFP = NULL; }
RageFile(const CString& path, const char *mode = "r");
2003-11-27 07:46:36 +00:00
~RageFile() { Close(); }
bool Open(const CString& path, const char *mode = "r");
void Close();
2003-11-30 03:45:04 +00:00
bool IsOpen() { return (mFP != NULL); }
bool AtEOF() { return (feof(mFP) != 0); }
2003-11-27 07:46:36 +00:00
int GetError() { return ferror(mFP); }
2003-12-03 20:37:10 +00:00
void ClearError() { clearerr(mFP); }
2003-11-27 07:46:36 +00:00
long Tell() { return ftell(mFP); }
bool Seek(long offset, int origin = SEEK_CUR) { return !fseek(mFP, offset, origin); }
void Rewind() { rewind(mFP); }
// GetLine() strips new lines
CString GetLine();
bool PutString(const CString& string) { return fputs(string, mFP) >= 0; }
size_t Read(void *buffer, size_t bytes);
size_t Write(const void *buffer, size_t bytes);
};
2003-07-22 07:47:27 +00:00
#endif