1
0

PLSWriter.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "PLSWriter.h"
  2. #include <windows.h>
  3. PLSWriter::PLSWriter() : numEntries(0), entryUsed(0)
  4. {
  5. memset(plsFile, 0, sizeof(plsFile));
  6. }
  7. void PLSWriter::Open(char *filename)
  8. {
  9. lstrcpynA(plsFile, filename, MAX_PATH);
  10. }
  11. void PLSWriter::SetFilename(char *filename)
  12. {
  13. char fieldbuf[32] = {0};
  14. BeforeSet();
  15. wsprintfA(fieldbuf,"File%u",numEntries);
  16. WritePrivateProfileStringA("playlist",fieldbuf,filename,plsFile);
  17. }
  18. void PLSWriter::SetTitle(char *title)
  19. {
  20. char fieldbuf[32] = {0};
  21. BeforeSet();
  22. wsprintfA(fieldbuf,"Title%u",numEntries);
  23. WritePrivateProfileStringA("playlist",fieldbuf,title,plsFile);
  24. }
  25. void PLSWriter::SetLength(int length)
  26. {
  27. char fieldbuf[32] = {0};
  28. char lenStr[32] = {0};
  29. BeforeSet();
  30. wsprintfA(fieldbuf,"Length%u",numEntries);
  31. wsprintfA(lenStr,"%d", length);
  32. WritePrivateProfileStringA("playlist",fieldbuf,lenStr,plsFile);
  33. }
  34. void PLSWriter::BeforeSet()
  35. {
  36. if (!entryUsed)
  37. {
  38. entryUsed=1;
  39. numEntries++;
  40. }
  41. }
  42. void PLSWriter::Next()
  43. {
  44. entryUsed=0;
  45. }
  46. void PLSWriter::Close()
  47. {
  48. if (numEntries)
  49. {
  50. char temp[32] = {0};
  51. wsprintfA(temp,"%u",numEntries);
  52. WritePrivateProfileStringA("playlist","NumberOfEntries",temp,plsFile);
  53. WritePrivateProfileStringA("playlist","Version","2",plsFile);
  54. }
  55. numEntries=0;
  56. entryUsed=0;
  57. }