18#include <zypp-core/AutoDispose.h>
19#include <zypp-core/base/IOTools.h>
20#include <zypp-core/base/LogTools.h>
21#include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
36 int flags = ::fcntl( fd, F_GETFL );
43 flags = flags | O_NONBLOCK;
44 else if ( flags & O_NONBLOCK )
45 flags = flags ^ O_NONBLOCK;
47 flags = ::fcntl( fd,F_SETFL,flags );
57 char *tmpBuf = (
char *) buf;
60 while ( written < size ) {
61 const auto res = zyppng::eintrSafeCall( ::write, fd, tmpBuf+written, size-written );
71 char *tmpBuf = (
char *)buf;
73 while ( read != size ) {
74 const auto r = zyppng::eintrSafeCall( ::read, fd, tmpBuf+read, size - read );
87 FILE * inputfile = file;
91 int inputfileFd = ::fileno( inputfile );
93 size_t linebuffer_size = 0;
107 int remainingTimeout =
static_cast<int>( timeout );
130 ERR <<
"select error: " << zyppng::strerr_cxx() << std::endl;
138 if ( ::feof( inputfile ) ) {
142 if (
errno )
ERR <<
"getdelim error: " << zyppng::strerr_cxx() << std::endl;
143 else ERR <<
"Unknown getdelim error." << std::endl;
152 if ( ! ::ferror( inputfile ) || ::feof( inputfile ) ) {
178 std::vector<char> data(
count + 1 ,
'\0' );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
reference value() const
Reference to the Tp object.
~TimeoutException() noexcept override
Dtor.
bool writeAll(int fd, void *buf, size_t size)
BlockingMode setFILEBlocking(FILE *file, bool mode)
Enables or disabled non blocking mode on a file descriptor.
std::pair< ReceiveUpToResult, std::string > receiveUpto(FILE *file, char c, timeout_type timeout, bool failOnUnblockError)
@ WasBlocking
FD was blocking before.
@ FailedToSetMode
Failed to block or unblock the fd.
@ WasNonBlocking
FD was non blocking before.
ReadAllResult readAll(int fd, void *buf, size_t size)
BlockingMode setFDBlocking(int fd, bool mode)
static constexpr timeout_type no_timeout
std::vector< char > peek_data_fd(FILE *fd, off_t offset, size_t count)