From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Plugins/Library/ml_disc/PLSWriter.cpp | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Src/Plugins/Library/ml_disc/PLSWriter.cpp (limited to 'Src/Plugins/Library/ml_disc/PLSWriter.cpp') diff --git a/Src/Plugins/Library/ml_disc/PLSWriter.cpp b/Src/Plugins/Library/ml_disc/PLSWriter.cpp new file mode 100644 index 00000000..8231d5b7 --- /dev/null +++ b/Src/Plugins/Library/ml_disc/PLSWriter.cpp @@ -0,0 +1,65 @@ +#include "PLSWriter.h" +#include + +PLSWriter::PLSWriter() : numEntries(0), entryUsed(0) +{ + memset(plsFile, 0, sizeof(plsFile)); +} + +void PLSWriter::Open(char *filename) +{ + lstrcpynA(plsFile, filename, MAX_PATH); +} + +void PLSWriter::SetFilename(char *filename) +{ + char fieldbuf[32] = {0}; + BeforeSet(); + wsprintfA(fieldbuf,"File%u",numEntries); + WritePrivateProfileStringA("playlist",fieldbuf,filename,plsFile); +} + +void PLSWriter::SetTitle(char *title) +{ + char fieldbuf[32] = {0}; + BeforeSet(); + wsprintfA(fieldbuf,"Title%u",numEntries); + WritePrivateProfileStringA("playlist",fieldbuf,title,plsFile); +} + +void PLSWriter::SetLength(int length) +{ + char fieldbuf[32] = {0}; + char lenStr[32] = {0}; + BeforeSet(); + wsprintfA(fieldbuf,"Length%u",numEntries); + wsprintfA(lenStr,"%d", length); + WritePrivateProfileStringA("playlist",fieldbuf,lenStr,plsFile); +} + +void PLSWriter::BeforeSet() +{ + if (!entryUsed) + { + entryUsed=1; + numEntries++; + } +} + +void PLSWriter::Next() +{ + entryUsed=0; +} + +void PLSWriter::Close() +{ + if (numEntries) + { + char temp[32] = {0}; + wsprintfA(temp,"%u",numEntries); + WritePrivateProfileStringA("playlist","NumberOfEntries",temp,plsFile); + WritePrivateProfileStringA("playlist","Version","2",plsFile); + } + numEntries=0; + entryUsed=0; +} \ No newline at end of file -- cgit