libzypp: zypp-core/base/IOTools.h Source File

libzypp 17.38.6

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-core/base/Exception.h>
19
20namespace zypp::io {
21
22 enum class BlockingMode{
23 FailedToSetMode = -1,
24 WasBlocking,
25 WasNonBlocking
26 };
27
32 BlockingMode setFILEBlocking ( FILE *file, bool mode = true );
33 BlockingMode setFDBlocking ( int fd, bool mode = true );
34
35
39 bool writeAll ( int fd, void *buf, size_t size );
40
44 enum class ReadAllResult {
45 Error,
46 Eof,
47 Ok
48 };
49 ReadAllResult readAll ( int fd, void *buf, size_t size );
50
51 class ZYPP_API TimeoutException : public Exception
52 {
53 public:
57 TimeoutException() : Exception( "Timeout Exception" )
58 {}
59
62 TimeoutException( const std::string & msg_r )
63 : Exception( msg_r )
64 {}
65
67 ~TimeoutException() noexcept override;
68 };
69
70 enum ReceiveUpToResult {
71 Success,
72 Timeout,
73 EndOfFile,
74 Error,
75 };
76
77 using timeout_type = size_t;
78 static constexpr timeout_type no_timeout = static_cast<timeout_type>(-1);
79
86 std::pair<ReceiveUpToResult, std::string> receiveUpto( FILE * file, char c, timeout_type timeout, bool failOnUnblockError = true );
87
91 std::vector<char> peek_data_fd ( FILE *fd, off_t offset, size_t count );
92}
93
94#endif
95
Exception.h
zypp::Exception::Exception
Exception()
Default ctor.
Definition Exception.cc:94
zypp::io::TimeoutException
Definition IOTools.h:52
zypp::io::TimeoutException::TimeoutException
TimeoutException(const std::string &msg_r)
Ctor taking message.
Definition IOTools.h:62
zypp::io::TimeoutException::TimeoutException
TimeoutException()
Ctor taking message.
Definition IOTools.h:57
zypp::io
Definition IOTools.cc:23
zypp::io::ReadAllResult
ReadAllResult
Definition IOTools.h:44
zypp::io::ReadAllResult::Eof
@ Eof
Definition IOTools.h:46
zypp::io::ReadAllResult::Ok
@ Ok
Definition IOTools.h:47
zypp::io::writeAll
bool writeAll(int fd, void *buf, size_t size)
Definition IOTools.cc:55
zypp::io::setFILEBlocking
BlockingMode setFILEBlocking(FILE *file, bool mode)
Enables or disabled non blocking mode on a file descriptor.
Definition IOTools.cc:25
zypp::io::receiveUpto
std::pair< ReceiveUpToResult, std::string > receiveUpto(FILE *file, char c, timeout_type timeout, bool failOnUnblockError)
Definition IOTools.cc:85
zypp::io::BlockingMode
BlockingMode
Definition IOTools.h:22
zypp::io::BlockingMode::WasBlocking
@ WasBlocking
FD was blocking before.
Definition IOTools.h:24
zypp::io::BlockingMode::FailedToSetMode
@ FailedToSetMode
Failed to block or unblock the fd.
Definition IOTools.h:23
zypp::io::BlockingMode::WasNonBlocking
@ WasNonBlocking
FD was non blocking before.
Definition IOTools.h:25
zypp::io::ReceiveUpToResult
ReceiveUpToResult
Definition IOTools.h:70
zypp::io::Timeout
@ Timeout
Definition IOTools.h:72
zypp::io::Success
@ Success
Definition IOTools.h:71
zypp::io::Error
@ Error
Definition IOTools.h:74
zypp::io::EndOfFile
@ EndOfFile
Definition IOTools.h:73
zypp::io::readAll
ReadAllResult readAll(int fd, void *buf, size_t size)
Definition IOTools.cc:69
zypp::io::setFDBlocking
BlockingMode setFDBlocking(int fd, bool mode)
Definition IOTools.cc:31
zypp::io::no_timeout
static constexpr timeout_type no_timeout
Definition IOTools.h:78
zypp::io::peek_data_fd
std::vector< char > peek_data_fd(FILE *fd, off_t offset, size_t count)
Definition IOTools.cc:171
zypp::io::timeout_type
size_t timeout_type
Definition IOTools.h:77
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173