apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

FileFd Class Reference

#include <fileutl.h>

Collaboration diagram for FileFd:
[legend]

Public Types

enum  OpenMode {
  ReadOnly = (1 << 0) , WriteOnly = (1 << 1) , ReadWrite = ReadOnly | WriteOnly , Create = (1 << 2) ,
  Exclusive = (1 << 3) , Atomic = Exclusive | (1 << 4) , Empty = (1 << 5) , BufferedWrite = (1 << 6) ,
  WriteEmpty = ReadWrite | Create | Empty , WriteExists = ReadWrite , WriteAny = ReadWrite | Create , WriteTemp = ReadWrite | Create | Exclusive ,
  ReadOnlyGzip , WriteAtomic = ReadWrite | Create | Atomic
}
 
enum  CompressMode {
  Auto = 'A' , None = 'N' , Extension = 'E' , Gzip = 'G' ,
  Bzip2 = 'B' , Lzma = 'L' , Xz = 'X' , Lz4 = '4' ,
  Zstd = 'Z'
}
 

Public Member Functions

bool Read (void *To, unsigned long long Size, bool AllowEof)
 
bool Read (void *To, unsigned long long Size, unsigned long long *Actual=0)
 
char * ReadLine (char *To, unsigned long long const Size)
 
bool ReadLine (std::string &To)
 
bool Flush ()
 
bool Write (const void *From, unsigned long long Size)
 
bool Seek (unsigned long long To)
 
bool Skip (unsigned long long To)
 
bool Truncate (unsigned long long To)
 
unsigned long long Tell ()
 
unsigned long long Size ()
 
unsigned long long FileSize ()
 
time_t ModificationTime ()
 
bool Open (std::string FileName, unsigned int const Mode, CompressMode Compress, unsigned long const AccessMode=0666)
 
bool Open (std::string FileName, unsigned int const Mode, APT::Configuration::Compressor const &compressor, unsigned long const AccessMode=0666)
 
bool Open (std::string const &FileName, unsigned int const Mode, unsigned long const AccessMode=0666)
 
bool OpenDescriptor (int Fd, unsigned int const Mode, CompressMode Compress, bool AutoClose=false)
 
bool OpenDescriptor (int Fd, unsigned int const Mode, APT::Configuration::Compressor const &compressor, bool AutoClose=false)
 
bool OpenDescriptor (int Fd, unsigned int const Mode, bool AutoClose=false)
 
bool Close ()
 
bool Sync ()
 
int Fd ()
 
void Fd (int fd)
 
bool IsOpen ()
 
bool Failed ()
 
void EraseOnFailure ()
 
void OpFail ()
 
bool Eof ()
 
bool IsCompressed ()
 
std::string & Name ()
 
void SetFileName (std::string const &name)
 
 FileFd (std::string FileName, unsigned int const Mode, unsigned long AccessMode=0666)
 
 FileFd (std::string FileName, unsigned int const Mode, CompressMode Compress, unsigned long AccessMode=0666)
 
 FileFd ()
 
 FileFd (int const Fd, unsigned int const Mode=ReadWrite, CompressMode Compress=None)
 
 FileFd (int const Fd, bool const AutoClose)
 
virtual ~FileFd ()
 

Static Public Member Functions

static bool Read (int const Fd, void *To, unsigned long long Size, unsigned long long *const Actual=0)
 
static bool Write (int Fd, const void *From, unsigned long long Size)
 

Protected Types

enum  LocalFlags {
  AutoClose = (1<<0) , Fail = (1<<1) , DelOnFail = (1<<2) , HitEof = (1<<3) ,
  Replace = (1<<4) , Compressed = (1<<5)
}
 

Protected Attributes

int iFd
 
unsigned long Flags
 
std::string FileName
 
std::string TemporaryFileName
 

Private Member Functions

APT_HIDDEN FileFd (const FileFd &)
 
APT_HIDDEN FileFdoperator= (const FileFd &)
 
APT_HIDDEN bool OpenInternDescriptor (unsigned int const Mode, APT::Configuration::Compressor const &compressor)
 
APT_HIDDEN bool FileFdErrno (const char *Function, const char *Description,...) APT_PRINTF(3) APT_COLD
 
APT_HIDDEN bool FileFdError (const char *Description,...) APT_PRINTF(2) APT_COLD
 

Private Attributes

FileFdPrivated
 

Friends

class FileFdPrivate
 
class GzipFileFdPrivate
 
class Bz2FileFdPrivate
 
class LzmaFileFdPrivate
 
class Lz4FileFdPrivate
 
class ZstdFileFdPrivate
 
class DirectFileFdPrivate
 
class PipedFileFdPrivate
 

Detailed Description

Definition at line 38 of file fileutl.h.

Member Enumeration Documentation

◆ CompressMode

Enumerator
Auto 
None 
Extension 
Gzip 
Bzip2 
Lzma 
Xz 
Lz4 
Zstd 

Definition at line 76 of file fileutl.h.

◆ LocalFlags

enum LocalFlags
protected
Enumerator
AutoClose 
Fail 
DelOnFail 
HitEof 
Replace 
Compressed 

Definition at line 51 of file fileutl.h.

◆ OpenMode

enum OpenMode
Enumerator
ReadOnly 
WriteOnly 
ReadWrite 
Create 
Exclusive 
Atomic 
Empty 
BufferedWrite 
WriteEmpty 
WriteExists 
WriteAny 
WriteTemp 
ReadOnlyGzip 
WriteAtomic 

Definition at line 58 of file fileutl.h.

Constructor & Destructor Documentation

◆ FileFd() [1/6]

FileFd ( std::string  FileName,
unsigned int const  Mode,
unsigned long  AccessMode = 0666 
)

Definition at line 2394 of file fileutl.cc.

References FileName, None, and Open().

◆ FileFd() [2/6]

FileFd ( std::string  FileName,
unsigned int const  Mode,
CompressMode  Compress,
unsigned long  AccessMode = 0666 
)

Definition at line 2398 of file fileutl.cc.

References FileName, and Open().

◆ FileFd() [3/6]

FileFd ( )

Definition at line 2402 of file fileutl.cc.

◆ FileFd() [4/6]

FileFd ( int const  Fd,
unsigned int const  Mode = ReadWrite,
CompressMode  Compress = None 
)

Definition at line 2403 of file fileutl.cc.

References Fd(), and OpenDescriptor().

◆ FileFd() [5/6]

FileFd ( int const  Fd,
bool const  AutoClose 
)

Definition at line 2407 of file fileutl.cc.

References AutoClose, Fd(), None, OpenDescriptor(), and ReadWrite.

◆ ~FileFd()

~FileFd ( )
virtual

Definition at line 2685 of file fileutl.cc.

References Close(), d, FileName, and FileFdPrivate::InternalClose().

◆ FileFd() [6/6]

APT_HIDDEN FileFd ( const FileFd )
private

Member Function Documentation

◆ Close()

◆ Eof()

bool Eof ( )
inline

Definition at line 154 of file fileutl.h.

Referenced by ExtractTar::Go(), MaybeAddAuth(), Patch::read_diff(), and ReadConfigFile().

◆ EraseOnFailure()

void EraseOnFailure ( )
inline

Definition at line 152 of file fileutl.h.

Referenced by CopyMethod::Fetch(), and StoreMethod::Fetch().

◆ Failed()

◆ Fd() [1/2]

◆ Fd() [2/2]

void Fd ( int  fd)
inline

Definition at line 148 of file fileutl.h.

◆ FileFdErrno()

bool FileFdErrno ( const char *  Function,
const char *  Description,
  ... 
)
private

◆ FileFdError()

bool FileFdError ( const char *  Description,
  ... 
)
private

◆ FileSize()

◆ Flush()

bool Flush ( )

◆ IsCompressed()

bool IsCompressed ( )
inline

Definition at line 155 of file fileutl.h.

Referenced by StoreMethod::Fetch(), and MMap::Map().

◆ IsOpen()

◆ ModificationTime()

time_t ModificationTime ( )

◆ Name()

◆ Open() [1/3]

bool Open ( std::string const &  FileName,
unsigned int const  Mode,
unsigned long const  AccessMode = 0666 
)
inline

Definition at line 135 of file fileutl.h.

◆ Open() [2/3]

bool Open ( std::string  FileName,
unsigned int const  Mode,
APT::Configuration::Compressor const &  compressor,
unsigned long const  AccessMode = 0666 
)

◆ Open() [3/3]

◆ OpenDescriptor() [1/3]

bool OpenDescriptor ( int  Fd,
unsigned int const  Mode,
APT::Configuration::Compressor const &  compressor,
bool  AutoClose = false 
)

Definition at line 2608 of file fileutl.cc.

References AutoClose, Close(), Compressed, Fd(), FileFdError(), FileName, Flags, iFd, and OpenInternDescriptor().

◆ OpenDescriptor() [2/3]

bool OpenDescriptor ( int  Fd,
unsigned int const  Mode,
bool  AutoClose = false 
)
inline

Definition at line 140 of file fileutl.h.

◆ OpenDescriptor() [3/3]

◆ OpenInternDescriptor()

◆ operator=()

APT_HIDDEN FileFd& operator= ( const FileFd )
private

◆ OpFail()

void OpFail ( )
inline

Definition at line 153 of file fileutl.h.

Referenced by CopyMethod::Fetch(), StoreMethod::Fetch(), and pkgDepCache::writeStateFile().

◆ Read() [1/3]

bool Read ( int const  Fd,
void *  To,
unsigned long long  Size,
unsigned long long *const  Actual = 0 
)
static

Definition at line 2743 of file fileutl.cc.

References Fd(), and Size().

◆ Read() [2/3]

◆ Read() [3/3]

bool Read ( void *  To,
unsigned long long  Size,
unsigned long long *  Actual = 0 
)

◆ ReadLine() [1/2]

char * ReadLine ( char *  To,
unsigned long long const  Size 
)

read a complete line or until buffer is full

The buffer will always be \0 terminated, so at most Size-1 characters are read. If the buffer holds a complete line the last character (before \0) will be the newline character \n otherwise the line was longer than the buffer.

Parameters
Tobuffer which will hold the line
Sizeof the buffer to fill

b nullptr is returned in error cases, otherwise the parameter To now filled with the line.

Definition at line 2776 of file fileutl.cc.

References d, Failed(), FileFdPrivate::InternalReadLine(), and Size().

Referenced by AutoDetectProxy(), Patch::dump_lines(), GetProcessName(), MaybeAddAuth(), MirrorMethod::MirrorListFileRecieved(), pkgSourceList::ParseFileOldStyle(), Patch::read_diff(), ReadConfigFile(), Patch::skip_lines(), and pkgCdrom::WriteSourceList().

◆ ReadLine() [2/2]

bool ReadLine ( std::string &  To)

read a complete line from the file

Similar to std::getline() the string does not include the newline, but just the content of the line as the newline is not needed to distinguish cases as for the other ReadLine method.

Parameters
Tostring which will hold the line
Returns
true if successful, otherwise false

Definition at line 2783 of file fileutl.cc.

References d, Failed(), and FileFdPrivate::InternalReadLine().

◆ Seek()

◆ SetFileName()

void SetFileName ( std::string const &  name)
inline

Definition at line 157 of file fileutl.h.

Referenced by GetTempFile(), and OpenConfigurationFileFd().

◆ Size()

◆ Skip()

bool Skip ( unsigned long long  To)

◆ Sync()

bool Sync ( )

Definition at line 3020 of file fileutl.cc.

References FileFdErrno(), and iFd.

◆ Tell()

◆ Truncate()

bool Truncate ( unsigned long long  To)

◆ Write() [1/2]

◆ Write() [2/2]

bool Write ( int  Fd,
const void *  From,
unsigned long long  Size 
)
static

Definition at line 2852 of file fileutl.cc.

References Fd(), and Size().

Friends And Related Function Documentation

◆ Bz2FileFdPrivate

friend class Bz2FileFdPrivate
friend

Definition at line 42 of file fileutl.h.

◆ DirectFileFdPrivate

friend class DirectFileFdPrivate
friend

Definition at line 46 of file fileutl.h.

Referenced by OpenInternDescriptor().

◆ FileFdPrivate

friend class FileFdPrivate
friend

Definition at line 40 of file fileutl.h.

◆ GzipFileFdPrivate

friend class GzipFileFdPrivate
friend

Definition at line 41 of file fileutl.h.

◆ Lz4FileFdPrivate

friend class Lz4FileFdPrivate
friend

Definition at line 44 of file fileutl.h.

◆ LzmaFileFdPrivate

friend class LzmaFileFdPrivate
friend

Definition at line 43 of file fileutl.h.

◆ PipedFileFdPrivate

friend class PipedFileFdPrivate
friend

Definition at line 47 of file fileutl.h.

Referenced by OpenInternDescriptor().

◆ ZstdFileFdPrivate

friend class ZstdFileFdPrivate
friend

Definition at line 45 of file fileutl.h.

Member Data Documentation

◆ d

◆ FileName

◆ Flags

◆ iFd

◆ TemporaryFileName

std::string TemporaryFileName
protected

Definition at line 55 of file fileutl.h.

Referenced by Close(), FileFdPrivate::InternalSeek(), and Open().


The documentation for this class was generated from the following files: