duck_io32.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /***********************************************\
  2. ??? duck_io.c
  3. \***********************************************/
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <io.h>
  7. #include <fcntl.h>
  8. #include <windows.h>
  9. #include "duck_io.h"
  10. int duck_open(const char *name, unsigned long userData)
  11. {
  12. char filename[255];
  13. (void) userData;
  14. if(name[strlen(name)-4] != '.') { /*no extension, try .AVI */
  15. sprintf(filename,"%s.AVI",name);
  16. //f = open(filename,O_BINARY|O_RDONLY);
  17. //return(f);
  18. }else
  19. strcpy(filename,name);
  20. //return(open(filename,O_BINARY|O_RDONLY));
  21. return (int)CreateFile(filename,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_FLAG_NO_BUFFERING,NULL);
  22. }
  23. void duck_close(int handle)
  24. {
  25. //close(handle);
  26. CloseHandle((void *)handle);
  27. }
  28. long duck_read(int handle,unsigned char *buffer,long bytes)
  29. {
  30. DWORD bytesRead;
  31. if (buffer == NULL){
  32. duck_seek(handle,bytes,SEEK_CUR);
  33. return bytes;
  34. }
  35. ReadFile((void *)handle,buffer,bytes,&bytesRead,NULL);
  36. //return(read(handle,buffer,bytes));
  37. return bytesRead;
  38. }
  39. int64_t duck_seek(int handle,int64_t offset,int origin)
  40. {
  41. //return(lseek(handle,offset,origin));
  42. return(SetFilePointer((HANDLE) handle,(LONG)offset,NULL,origin));
  43. }
  44. int duck_readFinished(int han, int flag)
  45. {
  46. (void)han; // not used;
  47. (void)flag; // not used;
  48. return 1;
  49. }
  50. void set_iofuncs()
  51. {
  52. // HFB_Setopen(duck_open);
  53. // HFB_Setclose(duck_close);
  54. // HFB_Setread(duck_read);
  55. // HFB_Setseek(duck_seek);
  56. }