remove LRCFile
This commit is contained in:
@@ -1,93 +0,0 @@
|
|||||||
#include "global.h"
|
|
||||||
/*
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
Class: LRCFile
|
|
||||||
|
|
||||||
Desc: See header.
|
|
||||||
|
|
||||||
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
|
||||||
Chris Danford
|
|
||||||
Glenn Maynard
|
|
||||||
Kevin Slaughter
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "LRCFile.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
#include <fcntl.h>
|
|
||||||
#if defined(WIN32)
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
#include <sstream>
|
|
||||||
#include "RageUtil.h"
|
|
||||||
#include "Regex.h"
|
|
||||||
|
|
||||||
void LRCFile::AddParam( const CString &buf )
|
|
||||||
{
|
|
||||||
values.back().params.push_back(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LRCFile::AddValue() /* (no extra charge) */
|
|
||||||
{
|
|
||||||
values.push_back(value_t());
|
|
||||||
}
|
|
||||||
|
|
||||||
void LRCFile::ReadBuf( char *buf, int len )
|
|
||||||
{
|
|
||||||
stringstream input(CString(buf, len));
|
|
||||||
string line;
|
|
||||||
|
|
||||||
while(getline(input, line))
|
|
||||||
{
|
|
||||||
if(!line.compare(0, 2, "//"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* "[data1] data2". Ignore whitespace at the beginning of the line. */
|
|
||||||
static Regex x("^ *\\[([^]]+)\\] *(.*)$");
|
|
||||||
|
|
||||||
vector<CString> matches;
|
|
||||||
if(!x.Compare(line, matches))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
StripCrnl(matches[1]);
|
|
||||||
|
|
||||||
AddValue();
|
|
||||||
AddParam(matches[0]);
|
|
||||||
AddParam(matches[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns true if successful, false otherwise
|
|
||||||
bool LRCFile::ReadFile( CString sNewPath )
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
/* Open a file */
|
|
||||||
if( (fd = open(sNewPath, O_RDONLY, 0)) == -1 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int iBufferSize = GetFileSizeInBytes(sNewPath) + 1000; // +1000 because sometimes the bytes read is > filelength. Why?
|
|
||||||
|
|
||||||
// allocate a string to hold the file
|
|
||||||
char* szFileString = new char[iBufferSize];
|
|
||||||
|
|
||||||
int iBytesRead = read( fd, szFileString, iBufferSize );
|
|
||||||
close( fd );
|
|
||||||
|
|
||||||
ASSERT( iBufferSize > iBytesRead );
|
|
||||||
szFileString[iBytesRead] = '\0';
|
|
||||||
|
|
||||||
ReadBuf(szFileString, iBytesRead);
|
|
||||||
|
|
||||||
delete [] szFileString;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CString LRCFile::GetParam(unsigned val, unsigned par) const
|
|
||||||
{
|
|
||||||
if(val >= GetNumValues()) return "";
|
|
||||||
if(par >= GetNumParams(val)) return "";
|
|
||||||
|
|
||||||
return values[val].params[par];
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#ifndef LRCFILE_H
|
|
||||||
#define LRCFILE_H
|
|
||||||
/*
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
Class: LRCFile
|
|
||||||
|
|
||||||
Desc: Wrapper for reading an LRC Lyrics file.
|
|
||||||
|
|
||||||
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
|
||||||
Chris Danford
|
|
||||||
Glenn Maynard
|
|
||||||
Kevin Slaughter
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
class LRCFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/* #param:param:param:param; <- one whole value */
|
|
||||||
struct value_t
|
|
||||||
{
|
|
||||||
vector<CString> params;
|
|
||||||
|
|
||||||
CString operator[](unsigned i) const { if(i >= params.size()) return ""; return params[i]; }
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~LRCFile() { }
|
|
||||||
|
|
||||||
//returns true if successful, false otherwise
|
|
||||||
bool ReadFile( CString sFilePath );
|
|
||||||
|
|
||||||
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( const CString &buf );
|
|
||||||
void AddValue();
|
|
||||||
|
|
||||||
vector<value_t> values;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -50,7 +50,7 @@ SongOptions.cpp SongOptions.h StageStats.cpp StageStats.h StyleDef.cpp StyleDef.
|
|||||||
TitleSubstitution.cpp TitleSubstitution.h Inventory.cpp Inventory.h PlayerNumber.cpp PlayerNumber.h \
|
TitleSubstitution.cpp TitleSubstitution.h Inventory.cpp Inventory.h PlayerNumber.cpp PlayerNumber.h \
|
||||||
LyricsLoader.cpp LyricsLoader.h
|
LyricsLoader.cpp LyricsLoader.h
|
||||||
|
|
||||||
FileTypes = IniFile.cpp IniFile.h MsdFile.cpp MsdFile.h LRCFile.cpp LRCFile.h
|
FileTypes = IniFile.cpp IniFile.h MsdFile.cpp MsdFile.h
|
||||||
|
|
||||||
|
|
||||||
StepMania = global.h ScreenDimensions.h StdString.h StepMania.cpp StepMania.h
|
StepMania = global.h ScreenDimensions.h StdString.h StepMania.cpp StepMania.h
|
||||||
|
|||||||
@@ -567,14 +567,6 @@ SOURCE=.\IniFile.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\LRCFile.cpp
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\LRCFile.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\MsdFile.cpp
|
SOURCE=.\MsdFile.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -708,12 +708,6 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\IniFile.h">
|
RelativePath=".\IniFile.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="LRCFile.cpp">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="LRCFile.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="MsdFile.cpp">
|
RelativePath="MsdFile.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
Reference in New Issue
Block a user