Browse Source

Simplify SRT file path construction with suggestion from Hoikas

tickets/38/38/1
Adam Johnson 2 years ago committed by ZarothYe
parent
commit
8a2534dff6
  1. 19
      Sources/Plasma/PubUtilLib/plAudioCore/plSrtFileReader.cpp

19
Sources/Plasma/PubUtilLib/plAudioCore/plSrtFileReader.cpp

@ -54,24 +54,17 @@ static const std::regex timingsRegex("^(\\d{2}):(\\d{2}):(\\d{2}),(\\d{3}) --> (
bool plSrtFileReader::ReadFile()
{
char path[MAX_PATH];
if (strchr(fAudioFileName, '\\') != nil)
strcpy(path, fAudioFileName);
else
sprintf(path, "sfx\\%s", fAudioFileName);
wchar srtPathUnicode[MAX_PATH];
StrToUnicode(srtPathUnicode, path, arrsize(srtPathUnicode));
PathSetExtension(srtPathUnicode, srtPathUnicode, L".sub", arrsize(srtPathUnicode));
wchar path[MAX_PATH];
StrPrintf(path, arrsize(path), L"sfx\\%S", fAudioFileName);
PathSetExtension(path, path, L".sub", arrsize(path));
if (PathDoesFileExist(srtPathUnicode)) {
if (PathDoesFileExist(path)) {
// read sets of SRT data until end of file
hsUNIXStream srtFileStream;
// if file exists and was opened successfully
if (srtFileStream.Open(srtPathUnicode, L"r")) {
plStatusLog::AddLineS("audio.log", "Successfully opened subtitle file {}", srtPathUnicode);
if (srtFileStream.Open(path, L"r")) {
plStatusLog::AddLineS("audio.log", "Successfully opened subtitle file {}", path);
uint32_t subtitleNumber = 0;
uint32_t subtitleStartTimeMs = 0;

Loading…
Cancel
Save