1
0
mirror of https://github.com/ScrelliCopter/VGM-Tools synced 2025-02-21 04:09:25 +11:00

snprintf for output names

This commit is contained in:
2019-10-01 23:23:38 +10:00
parent b12258970e
commit 6ccf9f6e38

View File

@@ -19,7 +19,6 @@
*/ */
#include <string> #include <string>
#include <sstream>
#include <vector> #include <vector>
#include <cstdint> #include <cstdint>
@@ -62,6 +61,7 @@ int main(int argc, char** argv)
// Search for pcm headers. // Search for pcm headers.
std::vector<uint8_t> smpBytes; std::vector<uint8_t> smpBytes;
char namebuf[32];
int smpaCount = 0, smpbCount = 0; int smpaCount = 0, smpbCount = 0;
while (!feof(file) && !ferror(file)) while (!feof(file) && !ferror(file))
{ {
@@ -72,16 +72,14 @@ int main(int argc, char** argv)
if (byte == 0x82) if (byte == 0x82)
{ {
printf("ADPCM-A data found at 0x%08lX\n", ftell(file)); printf("ADPCM-A data found at 0x%08lX\n", ftell(file));
std::stringstream path; snprintf(namebuf, sizeof(namebuf), "smpa_%x.pcm", smpaCount++);
path << std::hex << "smpa_" << (smpaCount++) << ".pcm"; DecodeSample(file, namebuf, smpBytes);
DecodeSample(file, path.str(), smpBytes);
} }
else if (byte == 0x83) else if (byte == 0x83)
{ {
printf("ADPCM-B data found at 0x%08lX\n", ftell(file)); printf("ADPCM-B data found at 0x%08lX\n", ftell(file));
std::stringstream path; snprintf(namebuf, sizeof(namebuf), "smpb_%x.pcm", smpbCount++);
path << std::hex << "smpb_" << (smpbCount++) << ".pcm"; DecodeSample(file, namebuf, smpBytes);
DecodeSample(file, path.str(), smpBytes);
} }
} }