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