FileReader: fix num_lines()

This commit is contained in:
Josh Holtrop 2014-06-05 17:10:12 -04:00
parent bebd7df072
commit eb1474bd84
2 changed files with 11 additions and 3 deletions

View File

@ -22,7 +22,17 @@ namespace jes
FileReader();
~FileReader();
bool load(const char * fname);
unsigned int num_lines() { return m_num_lines; }
unsigned int num_lines()
{
if (m_lines.is_null())
{
return 0u;
}
else
{
return m_lines->size();
}
}
TextRef get_line(unsigned int line_no);
int get_line_endings() { return m_line_endings; }
protected:
@ -31,7 +41,6 @@ namespace jes
typedef Ref<LineIndexPairVector> LineIndexPairVectorRef;
void load_buf(size_t size);
int m_fd;
unsigned int m_num_lines;
uint8_t * m_buf;
int m_line_endings;
LineIndexPairVectorRef m_lines;

View File

@ -11,7 +11,6 @@ namespace jes
FileReader::FileReader()
{
m_fd = 0;
m_num_lines = 0u;
m_buf = NULL;
m_line_endings = LINE_ENDING_COUNT;
m_lines = NULL;