home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / NTSTREAM.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  4KB  |  135 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /* --------------------------------------------------------------------
  4.    Module:     ntstream.h
  5.    Subject:    Share-Aware File Streams
  6.    Author:     Heinz Ozwirk
  7.    Started:    30.05.1993 15:22:54
  8.    Modified:   31.05.1993 10:28:24
  9.    --------------------------------------------------------------------
  10.    Description: public domain from the FidoNet C++ echo
  11.    --------------------------------------------------------------------
  12.    History:    (insert new entries at top of list)
  13.    dd.mm.yyyy/ho description
  14.    -------------------------------------------------------------------- */
  15.  
  16. #if !defined __NETSTREAM_H
  17. #define __NETSTREAM_H
  18.  
  19. /* --- Includes ------------------------------------------------------- */
  20. #include <fstream.h>
  21. #include <share.h>
  22.  
  23. /* --- Defines -------------------------------------------------------- */
  24. /* --- Constants ------------------------------------------------------ */
  25. /* --- Types ---------------------------------------------------------- */
  26.  
  27. class nfstream: public fstream
  28.    {
  29.    public:
  30.       enum
  31.          {
  32.          sh_compat = 1 << 15,
  33.          sh_none   = 1 << 14,
  34.          sh_read   = 1 << 13,
  35.          sh_write  = 1 << 12
  36.          };
  37.  
  38.       nfstream(): fstream() {};
  39.       nfstream(const signed char *name, int mode, int prot =
  40. filebuf::openprot);
  41.       nfstream(const unsigned char *name, int mode, int prot =
  42. filebuf::openprot);
  43.       nfstream(int fd): fstream(fd) {};
  44.       nfstream(int fd, char *buffer, int mode)
  45.          : fstream(fd, buffer, mode) {};
  46.       ~nfstream() { close(); }
  47.  
  48.       void open(const signed char *name, int mode, int prot =
  49. filebuf::openprot);
  50.       void open(const unsigned char *name, int mode, int prot =
  51. filebuf::openprot)
  52.          {
  53.          open((const signed char *) name, mode, prot);
  54.          };
  55.       void close();
  56.  
  57.    private:
  58.       int fd;
  59.    };
  60.  
  61. class nifstream: public ifstream
  62.    {
  63.    public:
  64.       enum
  65.          {
  66.          sh_compat = 1 << 15,
  67.          sh_none   = 1 << 14,
  68.          sh_read   = 1 << 13,
  69.          sh_write  = 1 << 12
  70.          };
  71.  
  72.       nifstream(): ifstream() {};
  73.       nifstream(const signed char *name, int mode, int prot =
  74. filebuf::openprot);
  75.       nifstream(const unsigned char *name, int mode, int prot =
  76. filebuf::openprot);
  77.       nifstream(int fd): ifstream(fd) {};
  78.       nifstream(int fd, char *buffer, int mode)
  79.          : ifstream(fd, buffer, mode) {};
  80.       ~nifstream() { close(); }
  81.  
  82.       void open(const signed char *name, int mode, int prot =
  83. filebuf::openprot);
  84.       void open(const unsigned char *name, int mode, int prot =
  85. filebuf::openprot)
  86.          {
  87.          open((const signed char *) name, mode, prot);
  88.          };
  89.       void close();
  90.  
  91.    private:
  92.       int fd;
  93.    };
  94.  
  95. class nofstream: public ofstream
  96.    {
  97.    public:
  98.       enum
  99.          {
  100.          sh_compat = 1 << 15,
  101.          sh_none   = 1 << 14,
  102.          sh_read   = 1 << 13,
  103.          sh_write  = 1 << 12
  104.          };
  105.  
  106.       nofstream(): ofstream() {};
  107.       nofstream(const signed char *name, int mode, int prot =
  108. filebuf::openprot);
  109.       nofstream(const unsigned char *name, int mode, int prot =
  110. filebuf::openprot);
  111.       nofstream(int fd): ofstream(fd) {};
  112.       nofstream(int fd, char *buffer, int mode)
  113.          : ofstream(fd, buffer, mode) {};
  114.       ~nofstream() { close(); }
  115.  
  116.       void open(const signed char *name, int mode, int prot =
  117. filebuf::openprot);
  118.       void open(const unsigned char *name, int mode, int prot =
  119. filebuf::openprot)
  120.          {
  121.          open((const signed char *) name, mode, prot);
  122.          };
  123.       void close();
  124.  
  125.    private:
  126.       int fd;
  127.    };
  128.  
  129. /* --- Prototypes ----------------------------------------------------- */
  130. /* --- External Variables --------------------------------------------- */
  131.  
  132. #endif
  133.  
  134. /* --- End of File ---------------------------------------------------- */
  135.