1
0

ISOBurner.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "ISOBurner.h"
  2. #include "../nu/AutoChar.h"
  3. #include "ifc_burner_writecallback.h"
  4. ISOBurner::ISOBurner(obj_primo *_primo) : BurnerCommon(_primo)
  5. {
  6. }
  7. int ISOBurner::Open()
  8. {
  9. if (!primo)
  10. return 1;
  11. return 0;
  12. }
  13. int ISOBurner::Write(wchar_t driveLetter, const wchar_t *isoFile, int flags, unsigned int speed, ifc_burner_writecallback *callback)
  14. {
  15. DWORD unit[] = {driveLetter, 0xFFFFFFFF};
  16. DWORD ret = primo->WriteOtherCDImage(unit, (PBYTE)(char *)AutoChar(isoFile), flags, speed);
  17. if (ret != PRIMOSDK_OK)
  18. return 1;
  19. while (1)
  20. {
  21. DWORD cursec = 0, totsec = 0;
  22. ret = primo->RunningStatus(PRIMOSDK_GETSTATUS, &cursec, &totsec);
  23. if (ret == PRIMOSDK_RUNNING)
  24. {
  25. if (callback)
  26. {
  27. int abort = callback->OnStatus(cursec, totsec);
  28. if (abort)
  29. {
  30. ret = primo->RunningStatus(PRIMOSDK_ABORT, 0, 0);
  31. callback = 0; // cheap way to prevent making further callbacks
  32. }
  33. }
  34. WaitForSingleObject(triggerEvent, 500);
  35. }
  36. else if (ret == PRIMOSDK_OK)
  37. {
  38. DWORD unit = driveLetter;
  39. ret = primo->UnitStatus(&unit, NULL, NULL, NULL, NULL);
  40. if (ret == PRIMOSDK_OK && callback)
  41. callback->Finished();
  42. break;
  43. }
  44. else
  45. break;
  46. }
  47. if (ret != PRIMOSDK_OK)
  48. return 1;
  49. return 0;
  50. }
  51. #define CBCLASS ISOBurner
  52. START_DISPATCH;
  53. CB(ISOBURNER_OPEN, Open)
  54. CB(ISOBURNER_WRITE, Write)
  55. VCB(ISOBURNER_FORCECALLBACK, ForceCallback)
  56. END_DISPATCH;
  57. #undef CBCLASS