libzypp 17.31.23
zypp::io Namespace Reference

Classes

class  TimeoutException
 

Typedefs

using timeout_type = size_t
 

Enumerations

enum class  BlockingMode { FailedToSetMode = -1 , WasBlocking , WasNonBlocking }
 
enum class  ReadAllResult { Error , Eof , Ok }
 
enum  ReceiveUpToResult { Success , Timeout , EndOfFile , Error }
 

Functions

BlockingMode setFILEBlocking (FILE *file, bool mode=true)
 Enables or disabled non blocking mode on a file descriptor.
 
BlockingMode setFDBlocking (int fd, bool mode)
 
bool writeAll (int fd, void *buf, size_t size)
 
ReadAllResult readAll (int fd, void *buf, size_t size)
 
std::pair< ReceiveUpToResult, std::string > receiveUpto (FILE *file, char c, timeout_type timeout, bool failOnUnblockError)
 

Variables

static const timeout_type no_timeout = static_cast<timeout_type>(-1)
 

Typedef Documentation

◆ timeout_type

using zypp::io::timeout_type = typedef size_t

Definition at line 76 of file IOTools.h.

Enumeration Type Documentation

◆ BlockingMode

enum class zypp::io::BlockingMode
strong
Enumerator
FailedToSetMode 

Failed to block or unblock the fd.

WasBlocking 

FD was blocking before.

WasNonBlocking 

FD was non blocking before.

Definition at line 22 of file IOTools.h.

◆ ReadAllResult

enum class zypp::io::ReadAllResult
strong

Blocks until the number of bytes passed via size was received

Enumerator
Error 
Eof 
Ok 

Definition at line 43 of file IOTools.h.

◆ ReceiveUpToResult

Enumerator
Success 
Timeout 
EndOfFile 
Error 

Definition at line 69 of file IOTools.h.

Function Documentation

◆ setFILEBlocking()

BlockingMode zypp::io::setFILEBlocking ( FILE *  file,
bool  mode = true 
)

Enables or disabled non blocking mode on a file descriptor.

The return value is one of the zypp::io::BlockingMode values

Definition at line 25 of file IOTools.cc.

◆ setFDBlocking()

BlockingMode zypp::io::setFDBlocking ( int  fd,
bool  mode 
)

Definition at line 31 of file IOTools.cc.

◆ writeAll()

bool zypp::io::writeAll ( int  fd,
void *  buf,
size_t  size 
)

Blocks until all data in buf was written to the fd or a error occured

Definition at line 55 of file IOTools.cc.

◆ readAll()

ReadAllResult zypp::io::readAll ( int  fd,
void *  buf,
size_t  size 
)

Definition at line 69 of file IOTools.cc.

◆ receiveUpto()

std::pair< ReceiveUpToResult, std::string > zypp::io::receiveUpto ( FILE *  file,
char  c,
timeout_type  timeout,
bool  failOnUnblockError = true 
)

Reads data from file until it finds a seperator c, hits the end of the file or times out. The timeout value is specified in milliseconds, a timeout of -1 means no timeout. If failOnUnblockError is set to false the function will not error out if unblocking the file descriptor did not work. The default is to fail if it's not possible to unblock the file.

Definition at line 85 of file IOTools.cc.

Variable Documentation

◆ no_timeout

const timeout_type zypp::io::no_timeout = static_cast<timeout_type>(-1)
static

Definition at line 77 of file IOTools.h.