libzypp  17.25.8
IOTools.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_IOTOOLS_H
13 #define ZYPP_BASE_IOTOOLS_H
14 
15 #include <stdio.h>
16 #include <utility>
17 #include <string>
18 #include <zypp/base/Exception.h>
19 
20 namespace zypp::io {
21 
22  enum class BlockingMode{
23  FailedToSetMode = -1,
24  WasBlocking,
26  };
27 
32  BlockingMode setFILEBlocking ( FILE *file, bool mode = true );
33 
34 
35  class TimeoutException : public Exception
36  {
37  public:
41  TimeoutException() : Exception( "Timeout Exception" )
42  {}
46  TimeoutException( const std::string & msg_r )
47  : Exception( msg_r )
48  {}
49 
51  virtual ~TimeoutException() noexcept override;
52  };
53 
59  };
60 
61  using timeout_type = size_t;
62  static const timeout_type no_timeout = static_cast<timeout_type>(-1);
63 
70  std::pair<ReceiveUpToResult, std::string> receiveUpto( FILE * file, char c, timeout_type timeout, bool failOnUnblockError = true );
71 
72 }
73 
74 #endif
zypp::io::EndOfFile
@ EndOfFile
Definition: IOTools.h:57
zypp::io::Timeout
@ Timeout
Definition: IOTools.h:56
zypp::io::TimeoutException::TimeoutException
TimeoutException(const std::string &msg_r)
Ctor taking message.
Definition: IOTools.h:46
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
zypp::io::TimeoutException::~TimeoutException
virtual ~TimeoutException() noexcept override
Dtor.
Definition: IOTools.cc:131
zypp::io
Definition: IOTools.cc:22
zypp::io::Error
@ Error
Definition: IOTools.h:58
zypp::io::receiveUpto
std::pair< ReceiveUpToResult, std::string > receiveUpto(FILE *file, char c, timeout_type timeout, bool failOnUnblockError)
Definition: IOTools.cc:52
zypp::io::timeout_type
size_t timeout_type
Definition: IOTools.h:61
zypp::io::Success
@ Success
Definition: IOTools.h:55
Exception.h
zypp::io::ReceiveUpToResult
ReceiveUpToResult
Definition: IOTools.h:54
zypp::io::BlockingMode::FailedToSetMode
@ FailedToSetMode
Failed to block or unblock the fd.
zypp::io::BlockingMode
BlockingMode
Definition: IOTools.h:22
zypp::io::setFILEBlocking
BlockingMode setFILEBlocking(FILE *file, bool mode)
Enables or disabled non blocking mode on a file descriptor.
Definition: IOTools.cc:24
timeout
time_t timeout
Definition: MediaCurl.cc:67
zypp::io::no_timeout
static const timeout_type no_timeout
Definition: IOTools.h:62
zypp::io::TimeoutException
Definition: IOTools.h:36
zypp::io::TimeoutException::TimeoutException
TimeoutException()
Ctor taking message.
Definition: IOTools.h:41