c_filebuf.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: c_filebuf.h /main/4 1996/08/21 15:54:26 drk $ */
  24. #ifndef _x_filebuf_h
  25. #define _x_filebuf_h
  26. #include "utility/c_streambuf.h"
  27. #include "utility/c_ios.h"
  28. class filebuf : public streambuf
  29. {
  30. protected:
  31. int _fd;
  32. int _mode;
  33. int _prev_action;
  34. char* _name;
  35. streampos current_pos;
  36. streampos new_pos;
  37. streampos default_new_pos;
  38. protected:
  39. void notify(int action_t);
  40. void _notify(int action_t);
  41. int overflow();
  42. int underflow() ;
  43. int _seek();
  44. int _seek(streampos pos, int whence);
  45. int _write(char* ptr, int size);
  46. public:
  47. filebuf(int fd);
  48. filebuf(const char* name, int mode, int protect = 0644);
  49. ~filebuf();
  50. int fd() { return _fd; };
  51. int is_open();
  52. int open(const char* name, int mode, int protect = 0644);
  53. int close();
  54. int flush() ;
  55. int seekg(streampos delta) ;
  56. };
  57. #endif