PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/mordor/streams/efs.h

http://github.com/mozy/mordor
C Header | 54 lines | 43 code | 10 blank | 1 comment | 0 complexity | baa194eb5c9b57122e281a52a3e3b0f0 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #ifndef __MORDOR_EFS_STREAM__
  2. #define __MORDOR_EFS_STREAM__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include "stream.h"
  5. namespace Mordor {
  6. class Fiber;
  7. class EFSStream : public Stream
  8. {
  9. public:
  10. EFSStream(void *context, bool read = true, bool ownContext = true);
  11. EFSStream(const char *filename, bool read = true);
  12. EFSStream(const wchar_t *filename, bool read = true);
  13. EFSStream(const std::string &filename, bool read = true);
  14. EFSStream(const std::wstring &filename, bool read = true);
  15. ~EFSStream();
  16. bool supportsRead() { return m_read; }
  17. bool supportsWrite() { return !m_read; }
  18. bool supportsSeek() { return m_read; }
  19. void close(CloseType type = BOTH);
  20. size_t read(Buffer &b, size_t len);
  21. size_t write(const Buffer &b, size_t len);
  22. long long seek(long long offset, Anchor anchor = BEGIN);
  23. private:
  24. void init();
  25. void readFiber();
  26. static DWORD WINAPI ExportCallback(PBYTE pbData, PVOID pvCallbackContext,
  27. ULONG ulLength);
  28. void writeFiber();
  29. static DWORD WINAPI ImportCallback(PBYTE pbData, PVOID pvCallbackContext,
  30. PULONG ulLength);
  31. private:
  32. boost::shared_ptr<Fiber> m_fiber;
  33. void *m_context;
  34. bool m_read, m_own;
  35. union {
  36. Buffer *m_readBuffer;
  37. const Buffer *m_writeBuffer;
  38. };
  39. size_t m_todo;
  40. long long m_pos;
  41. long long m_seekTarget;
  42. };
  43. }
  44. #endif