Add error reporting.
This commit is contained in:
@@ -39,11 +39,14 @@
|
||||
*/
|
||||
#include "MsdFile.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#if defined(WIN32)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include "RageUtil.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
void MsdFile::AddParam( char *buf, int len )
|
||||
{
|
||||
@@ -139,11 +142,15 @@ void MsdFile::ReadBuf( char *buf, int len )
|
||||
// returns true if successful, false otherwise
|
||||
bool MsdFile::ReadFile( CString sNewPath )
|
||||
{
|
||||
int fd;
|
||||
error = "";
|
||||
int fd;
|
||||
|
||||
/* Open a file */
|
||||
if( (fd = open(sNewPath, O_RDONLY, 0)) == -1 )
|
||||
return false;
|
||||
/* Open a file. */
|
||||
if( (fd = open(sNewPath, O_RDONLY, 0)) == -1 )
|
||||
{
|
||||
error = strerror(errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
int iBufferSize = GetFileSizeInBytes(sNewPath) + 1000; // +1000 because sometimes the bytes read is > filelength. Why?
|
||||
|
||||
|
||||
@@ -26,20 +26,23 @@ public:
|
||||
|
||||
virtual ~MsdFile() { }
|
||||
|
||||
//returns true if successful, false otherwise
|
||||
// Returns true if successful, false otherwise.
|
||||
bool ReadFile( CString sFilePath );
|
||||
CString GetError() const { return error; }
|
||||
|
||||
unsigned GetNumValues() const { return values.size(); }
|
||||
unsigned GetNumParams(unsigned val) const { if(val >= GetNumValues()) return 0; return values[val].params.size(); }
|
||||
const value_t &GetValue(unsigned val) const { ASSERT(val < GetNumValues()); return values[val]; }
|
||||
CString GetParam(unsigned val, unsigned par) const;
|
||||
|
||||
|
||||
private:
|
||||
void ReadBuf( char *buf, int len );
|
||||
void AddParam( char *buf, int len );
|
||||
void AddValue();
|
||||
|
||||
vector<value_t> values;
|
||||
CString error;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user