mirror of
https://github.com/ScrelliCopter/VGM-Tools
synced 2025-02-21 04:09:25 +11:00
FILE io for DumpBytes
This commit is contained in:
@@ -45,11 +45,14 @@ void DecodeSample(FILE* file, std::vector <uint8_t>& a_out)
|
|||||||
fread(a_out.data(), sizeof(uint8_t), sampLen, file);
|
fread(a_out.data(), sizeof(uint8_t), sampLen, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpBytes(std::string a_path, const std::vector<uint8_t>& a_bytes)
|
void DumpBytes(const char* path, const std::vector<uint8_t>& a_bytes)
|
||||||
{
|
{
|
||||||
std::ofstream fileOut(a_path, std::ios::binary);
|
FILE* file = fopen(path, "wb");
|
||||||
fileOut.write((const char*)a_bytes.data(), a_bytes.size());
|
if (!file)
|
||||||
fileOut.close();
|
return;
|
||||||
|
|
||||||
|
fwrite(a_bytes.data(), sizeof(uint8_t), a_bytes.size(), file);
|
||||||
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
@@ -77,7 +80,7 @@ int main(int argc, char** argv)
|
|||||||
DecodeSample(file, smpBytes);
|
DecodeSample(file, smpBytes);
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
path << std::hex << "smpa_" << (smpaCount++) << ".pcm";
|
path << std::hex << "smpa_" << (smpaCount++) << ".pcm";
|
||||||
DumpBytes(path.str(), smpBytes);
|
DumpBytes(path.str().c_str(), smpBytes);
|
||||||
}
|
}
|
||||||
else if (byte == 0x83)
|
else if (byte == 0x83)
|
||||||
{
|
{
|
||||||
@@ -85,7 +88,7 @@ int main(int argc, char** argv)
|
|||||||
DecodeSample(file, smpBytes);
|
DecodeSample(file, smpBytes);
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
path << std::hex << "smpb_" << (smpbCount++) << ".pcm";
|
path << std::hex << "smpb_" << (smpbCount++) << ".pcm";
|
||||||
DumpBytes(path.str(), smpBytes);
|
DumpBytes(path.str().c_str(), smpBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user