1
0

file_avi_reader.cpp 856 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "file_avi_reader.h"
  2. AVIReaderFILE::AVIReaderFILE(const wchar_t *filename)
  3. {
  4. f = _wfopen(filename, L"rb");
  5. }
  6. int AVIReaderFILE::Read(void *buffer, uint32_t read_length, uint32_t *bytes_read)
  7. {
  8. *bytes_read = fread(buffer, 1, read_length, f);
  9. return nsavi::READ_OK;
  10. }
  11. int AVIReaderFILE::Peek(void *buffer, uint32_t read_length, uint32_t *bytes_read)
  12. {
  13. *bytes_read = fread(buffer, 1, read_length, f);
  14. fseek(f, -read_length, SEEK_CUR);
  15. return nsavi::READ_OK;
  16. }
  17. int AVIReaderFILE::Seek(uint64_t position)
  18. {
  19. fsetpos(f, (const fpos_t *)&position);
  20. return nsavi::READ_OK;
  21. }
  22. uint64_t AVIReaderFILE::Tell()
  23. {
  24. uint64_t pos;
  25. fgetpos(f, (fpos_t *)&pos);
  26. return pos;
  27. }
  28. int AVIReaderFILE::Skip(uint32_t skip_bytes)
  29. {
  30. fseek(f, skip_bytes, SEEK_CUR);
  31. return nsavi::READ_OK;
  32. }
  33. AVIReaderFILE::~AVIReaderFILE()
  34. {
  35. fclose(f);
  36. }