mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
Replace FileAPI with c++ streams and std::filesystem
This commit is contained in:
@ -14,9 +14,9 @@ std::string AssetDumperLoadedSound::GetFileNameForAsset(Zone* zone, XAssetInfo<L
|
||||
return "sound/" + asset->m_name;
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, FileAPI::File* out)
|
||||
void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, std::ostream& stream)
|
||||
{
|
||||
const uint32_t riffMasterChunkSize = sizeof WAV_CHUNK_ID_RIFF
|
||||
const auto riffMasterChunkSize = sizeof WAV_CHUNK_ID_RIFF
|
||||
+ sizeof uint32_t
|
||||
+ sizeof WAV_WAVE_ID
|
||||
+ sizeof WavChunkHeader
|
||||
@ -24,16 +24,16 @@ void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, Fi
|
||||
+ sizeof WavChunkHeader
|
||||
+ sizeof asset->sound.info.data_len;
|
||||
|
||||
out->Write(&WAV_CHUNK_ID_RIFF, sizeof WAV_CHUNK_ID_RIFF, 1);
|
||||
out->Write(&riffMasterChunkSize, sizeof riffMasterChunkSize, 1);
|
||||
out->Write(&WAV_WAVE_ID, sizeof WAV_WAVE_ID, 1);
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_CHUNK_ID_RIFF), sizeof WAV_CHUNK_ID_RIFF);
|
||||
stream.write(reinterpret_cast<const char*>(&riffMasterChunkSize), sizeof riffMasterChunkSize);
|
||||
stream.write(reinterpret_cast<const char*>(&WAV_WAVE_ID), sizeof WAV_WAVE_ID);
|
||||
|
||||
const WavChunkHeader formatChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_FMT,
|
||||
sizeof WavFormatChunkPcm
|
||||
};
|
||||
out->Write(&formatChunkHeader, sizeof formatChunkHeader, 1);
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunkHeader), sizeof formatChunkHeader);
|
||||
|
||||
WavFormatChunkPcm formatChunk
|
||||
{
|
||||
@ -44,24 +44,24 @@ void AssetDumperLoadedSound::DumpWavPcm(Zone* zone, const LoadedSound* asset, Fi
|
||||
static_cast<uint16_t>(asset->sound.info.block_size),
|
||||
static_cast<uint16_t>(asset->sound.info.bits)
|
||||
};
|
||||
out->Write(&formatChunk, sizeof formatChunk, 1);
|
||||
stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof formatChunk);
|
||||
|
||||
const WavChunkHeader dataChunkHeader
|
||||
{
|
||||
WAV_CHUNK_ID_DATA,
|
||||
asset->sound.info.data_len
|
||||
};
|
||||
out->Write(&dataChunkHeader, sizeof dataChunkHeader, 1);
|
||||
out->Write(asset->sound.data, 1, asset->sound.info.data_len);
|
||||
stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof dataChunkHeader);
|
||||
stream.write(asset->sound.data, asset->sound.info.data_len);
|
||||
}
|
||||
|
||||
void AssetDumperLoadedSound::DumpAsset(Zone* zone, XAssetInfo<LoadedSound>* asset, FileAPI::File* out)
|
||||
void AssetDumperLoadedSound::DumpAsset(Zone* zone, XAssetInfo<LoadedSound>* asset, std::ostream& stream)
|
||||
{
|
||||
const auto* loadedSound = asset->Asset();
|
||||
switch (static_cast<WavFormat>(loadedSound->sound.info.format))
|
||||
{
|
||||
case WavFormat::PCM:
|
||||
DumpWavPcm(zone, loadedSound, out);
|
||||
DumpWavPcm(zone, loadedSound, stream);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user