Files
itgmania212121/stepmania/src/RageFile.h
T

58 lines
1.6 KiB
C++
Raw Normal View History

2003-07-22 07:47:27 +00:00
#ifndef RageFile_H
#define RageFile_H
/*
-----------------------------------------------------------------------------
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-11-27 07:46:36 +00:00
Steve Checkoway
2003-07-22 07:47:27 +00:00
-----------------------------------------------------------------------------
*/
#include <fstream>
2003-11-27 07:46:36 +00:00
#include <cstdio>
2003-07-22 07:47:27 +00:00
using namespace std; // using "std::ifstream" causes problems below in VC6. Why?!?
// 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") { Open(path, mode); }
~RageFile() { Close(); }
bool Open(const CString& path, const char *mode = "r");
void Close();
bool IsOpen() { return (mFP == NULL); }
2003-11-29 11:17:30 +00:00
bool AtEOF() { return !!feof(mFP); }
2003-11-27 07:46:36 +00:00
int GetError() { return ferror(mFP); }
FILE *GetFilePointer() { return mFP; }
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