fdstream.hpp: Classes for File Descriptors and File Handles

[intro] [interface] [discussion] [code]

Please note: There is a more general solution proposed for boost, which I recommend using instead of this library.

These are classes for low-level I/O with file descriptors and file handles, which I (Nicolai Josuttis) partially introduced in my book The C++ Standard Library - A Tutorial and Reference. Note that this is not UNIX library. It's purpose is to provide a way to operate with any low level I/O library that uses file descriptors or things like that. In fact, you can also use this library to work with POSIX calls and/or file handles on Window systems.

The classes are:

The class provides the following interface:

under construction

Some issues are open:

I'd appreciate any constructive feedback. Please note: I don't have time to read all boost mails. Thus, to make sure that feedback arrives me, please send me a copy of each mail regarding this class.

The code is provided "as is" without expressed or implied warranty.

fdstream.hpp, the implementation of all classes:

  • as HTML file
  • as plain file
  • fdstest1.cpp, a simple example using file descriptors 0 (standard input) and 1 (standard output):

  • as HTML file
  • as plain file
  • fdstest2.cpp, another example using file descriptors opened with open():

  • as HTML file
  • as plain file
  • fdstest3.cpp, another example starting a pipe with popen():

  • as HTML file
  • as plain file
  • All files

  • as ZIP file (16KB)
  • as TGZ file (10KB)

    To find more details about using our own streams and stream buffers in C++, see e.g.

         The C++ Standard Library - A Tutorial and Reference
         by Nicolai M. Josuttis

         Addison Wesley Longman, 1999

         ISBN 0-201-37926-0

  • Home Page of Nicolai Josuttis

    [intro] [interface] [discussion] [code]