api_filelock.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "foundation/foundation.h"
  3. #include "nx/nxuri.h"
  4. #include "service/types.h"
  5. class cb_filelock : public Wasabi2::Dispatchable
  6. {
  7. protected:
  8. cb_filelock() : Wasabi2::Dispatchable(DISPATCHABLE_VERSION) {}
  9. ~cb_filelock() {}
  10. public:
  11. int Interrupt() { return FileLockCallback_Interrupt(); }
  12. enum
  13. {
  14. DISPATCHABLE_VERSION=0,
  15. };
  16. private:
  17. virtual int WASABICALL FileLockCallback_Interrupt()=0;
  18. };
  19. // {AC2E21C6-7C66-47F6-8C99-267D6CAA1942}
  20. static const GUID file_lock_service_guid =
  21. { 0xac2e21c6, 0x7c66, 0x47f6, { 0x8c, 0x99, 0x26, 0x7d, 0x6c, 0xaa, 0x19, 0x42 } };
  22. class api_filelock : public Wasabi2::Dispatchable
  23. {
  24. protected:
  25. api_filelock() : Wasabi2::Dispatchable(DISPATCHABLE_VERSION) {}
  26. ~api_filelock() {}
  27. public:
  28. static GUID GetServiceType() { return SVC_TYPE_UNIQUE; }
  29. static GUID GetServiceGUID() { return file_lock_service_guid; }
  30. int WaitForRead(nx_uri_t filename) { return FileLock_WaitForRead(filename); }
  31. int WaitForReadInterruptable(nx_uri_t filename, cb_filelock *callback) { return FileLock_WaitForReadInterruptable(filename, callback); }
  32. int WaitForWrite(nx_uri_t filename) { return FileLock_WaitForWrite(filename); }
  33. int WaitForWriteInterruptable(nx_uri_t filename, cb_filelock *callback) { return FileLock_WaitForWriteInterruptable(filename, callback); }
  34. int UnlockFile(nx_uri_t filename) { return FileLock_UnlockFile(filename); }
  35. enum
  36. {
  37. DISPATCHABLE_VERSION=0,
  38. };
  39. private:
  40. virtual int WASABICALL FileLock_WaitForRead(nx_uri_t filename)=0;
  41. virtual int WASABICALL FileLock_WaitForReadInterruptable(nx_uri_t filename, cb_filelock *callback)=0;
  42. virtual int WASABICALL FileLock_WaitForWrite(nx_uri_t filename)=0;
  43. virtual int WASABICALL FileLock_WaitForWriteInterruptable(nx_uri_t filename, cb_filelock *callback)=0;
  44. virtual int WASABICALL FileLock_UnlockFile(nx_uri_t filename)=0;
  45. };