2007-12-07 00:26:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "VolumeDescriptor.h"
|
2015-05-17 22:10:33 -04:00
|
|
|
#include "File.h"
|
|
|
|
|
|
|
|
#define VOLUME_DESCRIPTOR_LBA 16ULL
|
2007-12-07 00:26:56 +00:00
|
|
|
|
|
|
|
using namespace ISO9660;
|
|
|
|
|
2015-05-17 22:10:33 -04:00
|
|
|
CVolumeDescriptor::CVolumeDescriptor(CBlockProvider* blockProvider)
|
2007-12-07 00:26:56 +00:00
|
|
|
{
|
2015-05-17 22:10:33 -04:00
|
|
|
CFile stream(blockProvider, VOLUME_DESCRIPTOR_LBA * CBlockProvider::BLOCKSIZE);
|
2018-04-30 21:01:23 +01:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Read(&m_type, 1);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2014-07-12 21:59:58 -04:00
|
|
|
if(m_type != 0x01)
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Invalid ISO9660 Volume Descriptor.");
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Read(m_stdId, 5);
|
2014-07-12 21:59:58 -04:00
|
|
|
m_stdId[5] = 0x00;
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2014-07-12 21:59:58 -04:00
|
|
|
if(strcmp(m_stdId, "CD001"))
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Invalid ISO9660 Volume Descriptor.");
|
|
|
|
}
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Seek(34, Framework::STREAM_SEEK_CUR);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Read(m_volumeId, 32);
|
2014-07-12 21:59:58 -04:00
|
|
|
m_volumeId[32] = 0x00;
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Seek(68, Framework::STREAM_SEEK_CUR);
|
2007-12-07 00:26:56 +00:00
|
|
|
|
2015-05-17 21:47:31 -04:00
|
|
|
stream.Read(&m_LPathTableAddress, 4);
|
|
|
|
stream.Read(&m_MPathTableAddress, 4);
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CVolumeDescriptor::~CVolumeDescriptor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CVolumeDescriptor::GetLPathTableAddress() const
|
|
|
|
{
|
2014-07-12 21:59:58 -04:00
|
|
|
return m_LPathTableAddress;
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CVolumeDescriptor::GetMPathTableAddress() const
|
|
|
|
{
|
2014-07-12 21:59:58 -04:00
|
|
|
return m_MPathTableAddress;
|
2007-12-07 00:26:56 +00:00
|
|
|
}
|