tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

C_FileIO.h (1008B)


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