2006-06-15 04:19:30 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include "PathTable.h"
|
|
|
|
#include "PtrMacro.h"
|
2007-12-07 00:26:56 +00:00
|
|
|
#include "stricmp.h"
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
using namespace Framework;
|
|
|
|
using namespace ISO9660;
|
2008-03-17 19:20:37 +00:00
|
|
|
using namespace std;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
CPathTable::CPathTable(CStream* pStream, uint32 nAddress)
|
|
|
|
{
|
2008-04-05 03:38:53 +00:00
|
|
|
pStream->Seek(nAddress * 0x800, Framework::STREAM_SEEK_SET);
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2008-03-17 19:20:37 +00:00
|
|
|
CPathTableRecord record(pStream);
|
|
|
|
if(record.GetNameLength() == 0)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2008-03-17 19:20:37 +00:00
|
|
|
m_records.insert(RecordMapType::value_type(m_records.size(), record));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPathTable::~CPathTable()
|
|
|
|
{
|
2008-03-17 19:20:37 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
uint32 CPathTable::GetDirectoryAddress(unsigned int nRecord) const
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
nRecord--;
|
2008-03-17 19:20:37 +00:00
|
|
|
RecordMapType::const_iterator recordIterator(m_records.find(nRecord));
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
if(recordIterator == m_records.end())
|
|
|
|
{
|
|
|
|
throw exception();
|
|
|
|
}
|
|
|
|
const CPathTableRecord& record(recordIterator->second);
|
|
|
|
return record.GetAddress();
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
unsigned int CPathTable::FindRoot() const
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-03-17 19:20:37 +00:00
|
|
|
for(RecordMapType::const_iterator recordIterator(m_records.begin());
|
|
|
|
m_records.end() != recordIterator; recordIterator++)
|
|
|
|
{
|
|
|
|
const CPathTableRecord& record(recordIterator->second);
|
|
|
|
if(record.GetNameLength() == 1)
|
|
|
|
{
|
|
|
|
return static_cast<unsigned int>(recordIterator->first) + 1;
|
|
|
|
}
|
|
|
|
}
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
return 0;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
unsigned int CPathTable::FindDirectory(const char* sName, unsigned int nParent) const
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-03-17 19:20:37 +00:00
|
|
|
for(RecordMapType::const_iterator recordIterator(m_records.begin());
|
|
|
|
m_records.end() != recordIterator; recordIterator++)
|
|
|
|
{
|
|
|
|
const CPathTableRecord& record(recordIterator->second);
|
|
|
|
if(record.GetParentRecord() != nParent) continue;
|
|
|
|
if(stricmp(sName, record.GetName())) continue;
|
|
|
|
return static_cast<unsigned int>(recordIterator->first) + 1;
|
|
|
|
}
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-03-17 19:20:37 +00:00
|
|
|
return 0;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|