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 9cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#include "MyTypes.h" 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "MyWindows.h" 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 12cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#ifdef _WIN32 13cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#ifdef _MSC_VER 14cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbeckytypedef size_t ssize_t; 15cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#endif 16cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#endif 17cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky 18baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NC { 19baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NFile { 20baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NIO { 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 22baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CFileBase 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 24baa3858d3f5d128a5c8466b700098109edcad5f2repo syncprotected: 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int _handle; 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool OpenBinary(const char *name, int flags); 27baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CFileBase(): _handle(-1) {}; 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ~CFileBase() { Close(); } 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool Close(); 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool GetLength(UInt64 &length) const; 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync off_t Seek(off_t distanceToMove, int moveMethod) const; 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 35baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass CInFile: public CFileBase 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 37baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool Open(const char *name); 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool OpenShared(const char *name, bool shareForWrite); 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ssize_t Read(void *data, size_t size); 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 43baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass COutFile: public CFileBase 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 45baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool Create(const char *name, bool createAlways); 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool Open(const char *name, DWORD creationDisposition); 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ssize_t Write(const void *data, size_t size); 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}}} 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 54