PLSWriter.cpp 721 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "PLSWriter.h"
  2. #include "../nu/AutoChar.h"
  3. PLSWriter::PLSWriter() : fp(0), numEntries(0)
  4. {
  5. }
  6. int PLSWriter::Open(const wchar_t *filename)
  7. {
  8. fp = _wfopen(filename, L"wt");
  9. if (!fp)
  10. return 0;
  11. fprintf(fp, "[playlist]\r\n");
  12. return 1;
  13. }
  14. void PLSWriter::Write(const wchar_t *filename)
  15. {
  16. fwprintf(fp, L"File%d=%s\r\n", (int)++numEntries, filename);
  17. }
  18. void PLSWriter::Write(const wchar_t *filename, const wchar_t *title, int length)
  19. {
  20. Write(filename);
  21. fwprintf(fp, L"Title%d=%s\r\n", (int)numEntries, title);
  22. fprintf(fp, "Length%d=%d\r\n", (int)numEntries, length);
  23. }
  24. void PLSWriter::Close()
  25. {
  26. fprintf(fp, "NumberOfEntries=%d\r\n", (int)numEntries);
  27. fprintf(fp, "Version=2\r\n");
  28. fclose(fp);
  29. }