Browse Source

Simplify SRT file path construction with suggestion from Hoikas

tickets/38/38/1
Adam Johnson 3 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() bool plSrtFileReader::ReadFile()
{ {
char path[MAX_PATH]; wchar path[MAX_PATH];
StrPrintf(path, arrsize(path), L"sfx\\%S", fAudioFileName);
PathSetExtension(path, path, L".sub", arrsize(path));
if (strchr(fAudioFileName, '\\') != nil) if (PathDoesFileExist(path)) {
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));
if (PathDoesFileExist(srtPathUnicode)) {
// read sets of SRT data until end of file // read sets of SRT data until end of file
hsUNIXStream srtFileStream; hsUNIXStream srtFileStream;
// if file exists and was opened successfully // if file exists and was opened successfully
if (srtFileStream.Open(srtPathUnicode, L"r")) { if (srtFileStream.Open(path, L"r")) {
plStatusLog::AddLineS("audio.log", "Successfully opened subtitle file {}", srtPathUnicode); plStatusLog::AddLineS("audio.log", "Successfully opened subtitle file {}", path);
uint32_t subtitleNumber = 0; uint32_t subtitleNumber = 0;
uint32_t subtitleStartTimeMs = 0; uint32_t subtitleStartTimeMs = 0;

Loading…
Cancel
Save