libzypp  17.35.14
filestreambuf.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
10 #ifndef ZYPP_CORE_BASE_FILESTREAMBUF_H
11 #define ZYPP_CORE_BASE_FILESTREAMBUF_H
12 
13 #include <zypp-core/AutoDispose.h>
14 #include <zypp-core/base/SimpleStreambuf>
15 
16 namespace zypp {
17  namespace detail {
19  public:
22 
27  void disableAutoClose();
28 
29  bool
30  isOpen () const
31  { return (_fd >= 0); }
32 
33  bool
34  canRead () const
35  { return( _mode == std::ios_base::in ); }
36 
37  bool
38  canWrite () const
39  { return( _mode == std::ios_base::out ); }
40 
41  bool canSeek ( std::ios_base::seekdir way_r ) const {
42  // we could implement seek for regular files, in that case openImpl should
43  // check for the file type using fstat and S_ISREG
44  return false;
45  }
46 
47  std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
48 
49  bool writeData( const char * buffer_r, std::streamsize count_r );
50 
51  off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ) {
52  return -1;
53  }
54 
55  off_t tell() const {
56  return -1;
57  }
58 
59  protected:
60  bool openImpl( int fd, std::ios_base::openmode mode_r );
61  bool closeImpl (); // closes the file
62 
63  private:
65  std::ios_base::openmode _mode = std::ios_base::openmode(0);
66  };
67  }
68 
70 }
71 #endif // ZYPP_CORE_BASE_FILESTREAMBUF_H
bool openImpl(int fd, std::ios_base::openmode mode_r)
std::streamsize readData(char *buffer_r, std::streamsize maxcount_r)
AutoDispose<int> calling ::close
Definition: AutoDispose.h:309
off_t seekTo(off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r)
Definition: filestreambuf.h:51
bool writeData(const char *buffer_r, std::streamsize count_r)
bool canSeek(std::ios_base::seekdir way_r) const
Definition: filestreambuf.h:41
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
std::ios_base::openmode _mode
Definition: filestreambuf.h:65