ProgressiveProcessor.cpp 981 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "ProgressiveProcessor.h"
  2. ProgressiveProcessor::ProgressiveProcessor()
  3. {
  4. tempFile[0]=0;
  5. writeCursor=INVALID_HANDLE_VALUE;
  6. wchar_t tempPath[MAX_PATH-14] = {0};
  7. GetTempPath(MAX_PATH-14, tempPath);
  8. GetTempFileName(tempPath, L"wfv", 0, tempFile);
  9. writeCursor=CreateFile(tempFile, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);
  10. processedCursor=CreateFile(tempFile, GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
  11. readCursor=CreateFile(tempFile, GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
  12. }
  13. ProgressiveProcessor::~ProgressiveProcessor()
  14. {
  15. if (writeCursor != INVALID_HANDLE_VALUE)
  16. CloseHandle(writeCursor);
  17. if (tempFile[0])
  18. DeleteFile(tempFile);
  19. }
  20. int ProgressiveProcessor::Write(void *data, size_t datalen, size_t *written)
  21. {
  22. DWORD dw_written=0;
  23. WriteFile(writeCursor, data, (DWORD)datalen, &dw_written, NULL);
  24. *written=dw_written;
  25. writePosition+=dw_written;
  26. return 0;
  27. }