C_FileIO.h 884 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Common/C_FileIO.h
  2. #ifndef __COMMON_C_FILEIO_H
  3. #define __COMMON_C_FILEIO_H
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include "Types.h"
  7. #include "MyWindows.h"
  8. namespace NC {
  9. namespace NFile {
  10. namespace NIO {
  11. class CFileBase
  12. {
  13. protected:
  14. int _handle;
  15. bool OpenBinary(const char *name, int flags);
  16. public:
  17. CFileBase(): _handle(-1) {};
  18. ~CFileBase() { Close(); }
  19. bool Close();
  20. bool GetLength(UInt64 &length) const;
  21. off_t Seek(off_t distanceToMove, int moveMethod) const;
  22. };
  23. class CInFile: public CFileBase
  24. {
  25. public:
  26. bool Open(const char *name);
  27. bool OpenShared(const char *name, bool shareForWrite);
  28. ssize_t Read(void *data, size_t size);
  29. };
  30. class COutFile: public CFileBase
  31. {
  32. public:
  33. bool Create(const char *name, bool createAlways);
  34. bool Open(const char *name, DWORD creationDisposition);
  35. ssize_t Write(const void *data, size_t size);
  36. };
  37. }}}
  38. #endif