api_filereader.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef __API_FILEREADER_H
  2. #define __API_FILEREADER_H
  3. #include <bfc/dispatch.h>
  4. class NOVTABLE api_fileReader : public Dispatchable
  5. {
  6. public:
  7. void *fileOpen(const wchar_t *filename, OSFNCSTR mode);
  8. void fileClose(void *fileHandle);
  9. size_t fileRead(void *buffer, size_t size, void *fileHandle);
  10. size_t fileWrite(const void *buffer, int size, void *fileHandle);
  11. int fileSeek(int64_t offset, int origin, void *fileHandle);
  12. uint64_t fileTell(void *fileHandle);
  13. uint64_t fileGetFileSize(void *fileHandle);
  14. //int fileExists(const wchar_t *filename);
  15. int fileRemove(const wchar_t *filename);
  16. int fileRemoveUndoable(const wchar_t *filename);
  17. int fileMove(const wchar_t *filename, const wchar_t *destfilename);
  18. enum {
  19. API_FILEREADER_FILEOPEN = 0,
  20. API_FILEREADER_FILECLOSE = 10,
  21. API_FILEREADER_FILEREAD = 20,
  22. API_FILEREADER_FILEWRITE = 30,
  23. API_FILEREADER_FILESEEK = 40,
  24. API_FILEREADER_FILETELL = 50,
  25. API_FILEREADER_FILEGETFILESIZE = 60,
  26. //API_FILEREADER_FILEEXISTS = 70,
  27. API_FILEREADER_FILEREMOVE = 80,
  28. API_FILEREADER_FILEREMOVEUNDOABLE = 90,
  29. API_FILEREADER_FILEMOVE = 100,
  30. };
  31. };
  32. inline void *api_fileReader::fileOpen(const wchar_t *filename, OSFNCSTR mode) {
  33. return _call(API_FILEREADER_FILEOPEN, (void *)NULL, filename, mode);
  34. }
  35. inline void api_fileReader::fileClose(void *fileHandle) {
  36. _voidcall(API_FILEREADER_FILECLOSE, fileHandle);
  37. }
  38. inline size_t api_fileReader::fileRead(void *buffer, size_t size, void *fileHandle) {
  39. return _call(API_FILEREADER_FILEREAD, (size_t)0, buffer, size, fileHandle);
  40. }
  41. inline size_t api_fileReader::fileWrite(const void *buffer, int size, void *fileHandle) {
  42. return _call(API_FILEREADER_FILEWRITE, (size_t)0, buffer, size, fileHandle);
  43. }
  44. inline int api_fileReader::fileSeek(int64_t offset, int origin, void *fileHandle) {
  45. return _call(API_FILEREADER_FILESEEK, (int)0, offset, origin, fileHandle);
  46. }
  47. inline uint64_t api_fileReader::fileTell(void *fileHandle) {
  48. return _call(API_FILEREADER_FILETELL, (uint64_t)0, fileHandle);
  49. }
  50. inline uint64_t api_fileReader::fileGetFileSize(void *fileHandle) {
  51. return _call(API_FILEREADER_FILEGETFILESIZE, (uint64_t)0, fileHandle);
  52. }
  53. /*inline int api_fileReader::fileExists(const wchar_t *filename) {
  54. return _call(API_FILEREADER_FILEEXISTS, (int)0, filename);
  55. }*/
  56. inline int api_fileReader::fileRemove(const wchar_t *filename) {
  57. return _call(API_FILEREADER_FILEREMOVE, (int)0, filename);
  58. }
  59. inline int api_fileReader::fileRemoveUndoable(const wchar_t *filename) {
  60. return _call(API_FILEREADER_FILEREMOVEUNDOABLE, (int)0, filename);
  61. }
  62. inline int api_fileReader::fileMove(const wchar_t *filename, const wchar_t *destfilename) {
  63. return _call(API_FILEREADER_FILEMOVE, (int)0, filename, destfilename);
  64. }
  65. class api_fileReaderI : public api_fileReader {
  66. public:
  67. virtual void *fileOpen(const wchar_t *filename, const wchar_t *mode)=0;
  68. virtual void fileClose(void *fileHandle)=0;
  69. virtual size_t fileRead(void *buffer, size_t size, void *fileHandle)=0;
  70. virtual int fileWrite(const void *buffer, int size, void *fileHandle)=0;
  71. virtual int fileSeek(int64_t offset, int origin, void *fileHandle)=0;
  72. virtual uint64_t fileTell(void *fileHandle)=0;
  73. virtual uint64_t fileGetFileSize(void *fileHandle)=0;
  74. //virtual int fileExists(const wchar_t *filename)=0;
  75. virtual int fileRemove(const wchar_t *filename)=0;
  76. virtual int fileRemoveUndoable(const wchar_t *filename)=0;
  77. virtual int fileMove(const wchar_t *filename, const wchar_t *destfilename)=0;
  78. protected:
  79. RECVS_DISPATCH;
  80. };
  81. // {E357E736-4967-4279-B948-5073A186F565}
  82. static const GUID fileReaderApiServiceGuid =
  83. { 0xe357e736, 0x4967, 0x4279, { 0xb9, 0x48, 0x50, 0x73, 0xa1, 0x86, 0xf5, 0x65 } };
  84. extern api_fileReader *fileApi;
  85. #endif