mirror of
https://github.com/zeldaret/ss
synced 2026-08-31 17:22:51 -04:00
snd_DvdSoundArchive OK
This commit is contained in:
@@ -56,8 +56,10 @@ bool DvdSoundArchive::Open(const char* pPath) {
|
||||
|
||||
char extRoot[FILE_PATH_MAX];
|
||||
for (int i = std::strlen(pPath) - 1; i >= 0; i--) {
|
||||
if (pPath[i] == '/' || pPath[i] == '\\') {
|
||||
// @bug Long path can overflow extRoot buffer
|
||||
if ((pPath[i] == '/' || pPath[i] == '\\')) {
|
||||
if (i >= FILE_PATH_MAX + 1) {
|
||||
return false;
|
||||
}
|
||||
std::strncpy(extRoot, pPath, i);
|
||||
extRoot[i] = '\0';
|
||||
|
||||
@@ -70,8 +72,10 @@ bool DvdSoundArchive::Open(const char* pPath) {
|
||||
}
|
||||
|
||||
void DvdSoundArchive::Close() {
|
||||
DVDClose(&mFileInfo);
|
||||
mOpen = false;
|
||||
if (mOpen) {
|
||||
DVDClose(&mFileInfo);
|
||||
mOpen = false;
|
||||
}
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
@@ -115,7 +119,7 @@ bool DvdSoundArchive::LoadFileHeader() {
|
||||
u8 headerArea[detail::SoundArchiveFile::HEADER_AREA_SIZE];
|
||||
|
||||
static const u32 headerAlignSize =
|
||||
ut::RoundUp(sizeof(detail::SoundArchiveFile::Header), 32);
|
||||
ROUND_UP(sizeof(detail::SoundArchiveFile::Header), 32);
|
||||
|
||||
void* pFile = ut::RoundUp<u8>(headerArea, 32);
|
||||
|
||||
@@ -173,9 +177,6 @@ bool DvdSoundArchive::LoadLabelStringData(void* pBuffer, u32 size) {
|
||||
DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo,
|
||||
u32 offset, u32 size)
|
||||
: DvdLockedFileStream(pFileInfo, false), mOffset(offset), mSize(size) {
|
||||
if (mSize == 0) {
|
||||
mSize = ut::DvdFileStream::GetSize();
|
||||
}
|
||||
|
||||
ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG);
|
||||
}
|
||||
@@ -183,9 +184,6 @@ DvdSoundArchive::DvdFileStream::DvdFileStream(const DVDFileInfo* pFileInfo,
|
||||
DvdSoundArchive::DvdFileStream::DvdFileStream(s32 entrynum, u32 offset,
|
||||
u32 size)
|
||||
: DvdLockedFileStream(entrynum), mOffset(offset), mSize(size) {
|
||||
if (mSize == 0) {
|
||||
mSize = ut::DvdFileStream::GetSize();
|
||||
}
|
||||
|
||||
ut::DvdFileStream::Seek(mOffset, SEEKORG_BEG);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user