diff --git a/stepmania/src/MsdFile.cpp b/stepmania/src/MsdFile.cpp index 2d253873bd..3012fc45ff 100644 --- a/stepmania/src/MsdFile.cpp +++ b/stepmania/src/MsdFile.cpp @@ -39,11 +39,14 @@ */ #include "MsdFile.h" #include "RageLog.h" +#include "RageUtil.h" + #include #if defined(WIN32) #include #endif -#include "RageUtil.h" +#include +#include 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? diff --git a/stepmania/src/MsdFile.h b/stepmania/src/MsdFile.h index 313867b815..e498c7fc73 100644 --- a/stepmania/src/MsdFile.h +++ b/stepmania/src/MsdFile.h @@ -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 values; + CString error; }; #endif