B4SWriter.cpp 683 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "B4SWriter.h"
  2. /*
  3. TODO: escape XML shit
  4. */
  5. B4SWriter::B4SWriter() : fp(0)
  6. {
  7. }
  8. int B4SWriter::Open(const wchar_t *filename)
  9. {
  10. fp = _wfopen(filename, L"wt");
  11. if (!fp)
  12. return 0;
  13. fwprintf(fp, L"<playlist>\n");
  14. return 1;
  15. }
  16. void B4SWriter::Write(const wchar_t *filename)
  17. {
  18. fwprintf(fp, L"<entry playstring=\"%s\"/>\n", filename);
  19. }
  20. void B4SWriter::Write(const wchar_t *filename, const wchar_t *title, int length)
  21. {
  22. fwprintf(fp, L"<entry playstring=\"%s\">\n", filename);
  23. fwprintf(fp, L"<name>%s</name>\n", title);
  24. fwprintf(fp, L"<length>%d</length>\n", length);
  25. fwprintf(fp, L"</entry>\n");
  26. }
  27. void B4SWriter::Close()
  28. {
  29. fputs("</playlist>", fp);
  30. fclose(fp);
  31. }