Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
file-descriptor.hh File Reference
#include "types.hh"
#include "error.hh"

Go to the source code of this file.

Classes

class  nix::AutoCloseFD
 
class  nix::Pipe
 

Typedefs

using nix::Descriptor
 

Functions

std::string nix::readFile (Descriptor fd)
 
void nix::readFull (Descriptor fd, char *buf, size_t count)
 
void nix::writeFull (Descriptor fd, std::string_view s, bool allowInterrupts=true)
 
std::string nix::readLine (Descriptor fd, bool eofOk=false)
 
void nix::writeLine (Descriptor fd, std::string s)
 
std::string nix::drainFD (Descriptor fd, bool block, const size_t reserveSize)
 
void nix::drainFD (Descriptor fd, Sink &sink, bool block=true)
 
Descriptor nix::getStandardInput ()
 
Descriptor nix::getStandardOutput ()
 
Descriptor nix::getStandardError ()
 
void nix::unix::closeExtraFDs ()
 
void nix::unix::closeOnExec (Descriptor fd)
 
 nix::MakeError (EndOfFile, Error)
 

Variables

const Descriptor nix::INVALID_DESCRIPTOR
 

Typedef Documentation

◆ Descriptor

Initial value:
int

Operating System capability

Function Documentation

◆ closeExtraFDs()

void nix::unix::closeExtraFDs ( )

Close all file descriptors except stdio fds (ie 0, 1, 2). Good practice in child processes.

◆ closeOnExec()

void nix::unix::closeOnExec ( Descriptor fd)

Set the close-on-exec flag for the given file descriptor.

◆ drainFD() [1/2]

std::string nix::drainFD ( Descriptor fd,
bool block = true,
const size_t reserveSize = 0 )

Read a file descriptor until EOF occurs.

◆ drainFD() [2/2]

void nix::drainFD ( Descriptor fd,
Sink & sink,
bool block = true )

The Windows version is always blocking.

◆ getStandardError()

Descriptor nix::getStandardError ( )
inline

◆ getStandardInput()

Descriptor nix::getStandardInput ( )
inline

◆ getStandardOutput()

Descriptor nix::getStandardOutput ( )
inline

◆ readFile()

std::string nix::readFile ( Descriptor fd)

Read the contents of a resource into a string.

◆ readFull()

void nix::readFull ( Descriptor fd,
char * buf,
size_t count )

Wrappers arount read()/write() that read/write exactly the requested number of bytes.

◆ readLine()

std::string nix::readLine ( Descriptor fd,
bool eofOk = false )

Read a line from a file descriptor.

Parameters
fdThe file descriptor to read from
eofOkIf true, return an unterminated line if EOF is reached. (e.g. the empty string)
Returns
A line of text ending in \n, or a string without \n if eofOk is true and EOF is reached.

◆ writeLine()

void nix::writeLine ( Descriptor fd,
std::string s )

Write a line to a file descriptor.

Variable Documentation

◆ INVALID_DESCRIPTOR

const Descriptor nix::INVALID_DESCRIPTOR
Initial value:
=
-1