A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/tar_8cpp.html below:

NCBI C++ ToolKit: src/util/compress/api/tar.cpp File Reference

#include <ncbi_pch.hpp>
#include <util/compress/tar.hpp>
#include <util/error_codes.hpp>
#include "../../../corelib/ncbi_os_unix_p.hpp"
#include <grp.h>
#include <pwd.h>
#include <unistd.h>

Go to the source code of this file.

Go to the SVN repository for this file.

#define  _FORTIFY_SOURCE   0   #define  NCBI_USE_ERRCODE_X   Util_Compress   #define  NCBI_MODULE   NCBITAR   #define  ALIGN_SIZE(size)   (((size) + (BLOCK_SIZE-1)) & ~(BLOCK_SIZE-1))   Round up to the nearest multiple of BLOCK_SIZE: More...
  #define  OFFSET_OF(size)   ( (size) & (BLOCK_SIZE-1))   #define  BLOCK_OF(pos)   ((pos) >> 9)   #define  SIZE_OF(blk)   ((blk) << 9)   #define  BLOCK_SIZE   SIZE_OF(1)   Tar block size (512 bytes) More...
  #define  offsetof(T, F)   ((char*) &(((T*) 0)->F) - (char*) 0)   #define  TAR_PRINTABLE_EX(field, text, size)   #define  TAR_PRINTABLE(field, text)    TAR_PRINTABLE_EX(field, text, sizeof(h->field))   #define  TAR_GNU_REGION   "[gnu.region]: "   #define  TAR_GNU_CONTIND   "[gnu.contind]: "   #define  TAR_THROW(who, errcode, message)   #define  TAR_THROW_EX(who, errcode, message, hdr, fmt)   #define  TAR_POST(subcode, severity, message)   #define  NCBI_FILE_WO   "wb"   enum   ETar_Format {
  eTar_Unknown = 0 , eTar_Legacy = 1 , eTar_OldGNU = 2 , eTar_Ustar = 4 ,
  eTar_Posix = 5 , eTar_Star = 6
}   Recognized TAR formats. More...
  enum   EPAXBit {
  fPAXNone = 0 , fPAXSparseGNU_1_0 = 1 << 0 , fPAXSparse = 1 << 1 , fPAXMtime = 1 << 2 ,
  fPAXAtime = 1 << 3 , fPAXCtime = 1 << 4 , fPAXSize = 1 << 5 , fPAXUid = 1 << 6 ,
  fPAXGid = 1 << 7
}   static bool  s_NumToOctal (Uint8 val, char *ptr, size_t len)   static bool  s_OctalToNum (Uint8 &val, const char *ptr, size_t len)   static bool  s_NumToBase256 (Uint8 val, char *ptr, size_t len)   static int  s_EncodeUint8 (Uint8 val, char *ptr, size_t len)   static bool  s_Base256ToNum (Uint8 &val, const char *ptr, size_t len)   static int  s_DecodeUint8 (Uint8 &val, const char *ptr, size_t len)   static void  s_TarToMode (TTarMode perm, CDirEntry::TMode *usr_mode, CDirEntry::TMode *grp_mode, CDirEntry::TMode *oth_mode, CDirEntry::TSpecialModeBits *special_bits)   static mode_t  s_TarToMode (TTarMode perm)   static TTarMode  s_ModeToTar (mode_t mode)   static size_t  s_Length (const char *ptr, size_t maxsize)   static bool  s_TarChecksum (TTarBlock *block, bool isgnu)   static string  s_ModeAsString (TTarMode mode)   static char  s_TypeAsChar (CTarEntryInfo::EType type)   static string  s_UserGroupAsString (const CTarEntryInfo &info)   static string  s_MajorMinor (unsigned int n)   static string  s_SizeOrMajorMinor (const CTarEntryInfo &info)   CNcbiOstreamoperator<< (CNcbiOstream &os, const CTarEntryInfo &info)   static string  s_OSReason (int x_errno)   static string  s_PositionAsString (const string &file, Uint8 pos, size_t recsize, const string &entryname)   static string  s_OffsetAsString (size_t offset)   static bool  memcchr (const char *s, char c, size_t len)   static string  s_Printable (const char *field, size_t maxsize, bool text)   static string  s_DumpSparseMap (const STarHeader *h, const char *sparse, const char *contind, bool excpt=false)   static string  s_DumpSparseMap (const vector< pair< Uint8, Uint8 > > &bmap)   static string  s_DumpHeader (const STarHeader *h, ETar_Format fmt, bool excpt=false)   void  s_SetStateSafe (CNcbiIos &ios, IOS_BASE::iostate state) throw ()   static int  s_TruncateFile (const string &filename, Uint8 filesize)   static bool  s_ParsePAXNumeric (Uint8 *valp, const char *str, size_t len, string *fraq, EPAXBit assign)   static bool  s_AllLowerCase (const char *str, size_t len)   static Uint8  ipow10 (unsigned int n)   static long  s_FraqToNanosec (const string &fraq)   static void  s_Dump (const string &file, Uint8 pos, size_t recsize, const string &entryname, const STarHeader *h, ETar_Format fmt, Uint8 datasize)   static void  s_DumpSparse (const string &file, Uint8 pos, size_t recsize, const string &entryname, const STarHeader *h, const char *contind, Uint8 datasize)   static void  s_DumpSparse (const string &file, Uint8 pos, size_t recsize, const string &entryname, const vector< pair< Uint8, Uint8 > > &bmap)   static void  s_DumpZero (const string &file, Uint8 pos, size_t recsize, size_t zeroblock_count, bool eot=false)   static bool  s_IsOctal (char c)   static void  sx_Signature (TTarBlock *block)   static bool  s_MatchExcludeMask (const CTempString &name, const list< CTempString > &elems, const CMask *mask, NStr::ECase acase)   static string  s_ToFilesystemPath (const string &base_dir, const string &name, bool noabs=false)   static string  s_ToArchiveName (const string &base_dir, const string &path)   static CTempString  x_DropTrailingSlashes (const string &s)   static string  s_BaseDir (const string &dirname)   ◆ _FORTIFY_SOURCE #define _FORTIFY_SOURCE   0

Definition at line 52 of file tar.cpp.

◆ ALIGN_SIZE

Round up to the nearest multiple of BLOCK_SIZE:

Definition at line 371 of file tar.cpp.

◆ BLOCK_OF #define BLOCK_OF (   pos )    ((pos) >> 9)

Definition at line 373 of file tar.cpp.

◆ BLOCK_SIZE

Tar block size (512 bytes)

Definition at line 377 of file tar.cpp.

◆ NCBI_FILE_WO #define NCBI_FILE_WO   "wb"

Definition at line 3885 of file tar.cpp.

◆ NCBI_MODULE #define NCBI_MODULE   NCBITAR

Definition at line 90 of file tar.cpp.

◆ NCBI_USE_ERRCODE_X #define NCBI_USE_ERRCODE_X   Util_Compress

Definition at line 89 of file tar.cpp.

◆ OFFSET_OF ◆ offsetof #define offsetof (   T,   F  )    ((char*) &(((T*) 0)->F) - (char*) 0)

Definition at line 735 of file tar.cpp.

◆ SIZE_OF #define SIZE_OF (   blk )    ((blk) << 9)

Definition at line 374 of file tar.cpp.

◆ TAR_GNU_CONTIND #define TAR_GNU_CONTIND   "[gnu.contind]: "

Definition at line 749 of file tar.cpp.

◆ TAR_GNU_REGION #define TAR_GNU_REGION   "[gnu.region]: "

Definition at line 748 of file tar.cpp.

◆ TAR_POST #define TAR_POST (   subcode,   severity,   message  ) Value:

m_Current.GetName()) + (message))

#define ERR_POST_X(err_subcode, message)

Error posting with default error code and given error subcode.

static string s_PositionAsString(const string &file, Uint8 pos, size_t recsize, const string &entryname)

Definition at line 1376 of file tar.cpp.

◆ TAR_PRINTABLE ◆ TAR_PRINTABLE_EX #define TAR_PRINTABLE_EX (   field,   text,   size  ) Value:

#define NCBI_AS_STRING(value)

Convert some value to string even if this value is macro itself.

static void text(MDB_val *v)

const struct ncbi::grid::netcache::search::fields::SIZE size

static string s_Printable(const char *field, size_t maxsize, bool text)

static string s_OffsetAsString(size_t offset)

Definition at line 738 of file tar.cpp.

◆ TAR_THROW #define TAR_THROW (   who,   errcode,   message  ) Value:

who->m_BufferSize, \

who->m_Current.GetName()) + (message))

#define NCBI_THROW(exception_class, err_code, message)

Generic macro to throw an exception, given the exception class, error code and message string.

Definition at line 1364 of file tar.cpp.

◆ TAR_THROW_EX #define TAR_THROW_EX (   who,   errcode,   message,   hdr,   fmt  ) Value:

who->m_Flags & fDumpEntryHeaders \

?

string

(message) +

":\n"

+

s_DumpHeader

(hdr, fmt,

true

) \

: string(message))

#define TAR_THROW(who, errcode, message)

static string s_DumpHeader(const STarHeader *h, ETar_Format fmt, bool excpt=false)

Definition at line 1370 of file tar.cpp.

◆ TPAXBits ◆ EPAXBit Enumerator fPAXNone  fPAXSparseGNU_1_0  fPAXSparse  fPAXMtime  fPAXAtime  fPAXCtime  fPAXSize  fPAXUid  fPAXGid 

Definition at line 1828 of file tar.cpp.

◆ ETar_Format

Recognized TAR formats.

Enumerator eTar_Unknown  eTar_Legacy  eTar_OldGNU  eTar_Ustar  eTar_Posix  eTar_Star 

Definition at line 381 of file tar.cpp.

◆ ipow10() ◆ memcchr() ◆ operator<<() ◆ s_AllLowerCase() ◆ s_Base256ToNum() ◆ s_BaseDir() ◆ s_DecodeUint8() ◆ s_Dump()

Definition at line 2070 of file tar.cpp.

References _ASSERT, ALIGN_SIZE, BLOCK_OF, blocks, eDiag_Info, ERR_POST, eTar_OldGNU, file, STarHeader::gnu, Info(), kEmptyStr, NStr::NumericToString(), OFFSET_OF, s_DumpHeader(), s_PositionAsString(), SetDiagPostLevel(), and STarHeader::typeflag.

Referenced by CTar::x_ReadEntryInfo().

◆ s_DumpHeader()

Definition at line 828 of file tar.cpp.

References _ASSERT, CTime::AsString(), BLOCK_SIZE, STarHeader::checksum, STarHeader::devmajor, STarHeader::devminor, dump, eTar_Legacy, eTar_OldGNU, eTar_Posix, eTar_Star, eTar_Ustar, CTime::GetTimeT(), STarHeader::gid, STarHeader::gnu, len, memcchr(), STarHeader::mode, STarHeader::mtime, n, STarHeader::name, NStr::NumericToString(), offset, ok, STarHeader::prefix, NStr::PrintableString(), s_DecodeUint8(), s_DumpSparseMap(), s_Length(), s_ModeAsString(), s_OctalToNum(), s_OffsetAsString(), s_Printable(), ncbi::grid::netcache::search::fields::size, STarHeader::size, STarHeader::star, string, NStr::strncasecmp(), TAR_PRINTABLE, TAR_PRINTABLE_EX, CTime::ToLocalTime(), true, STarHeader::typeflag, STarHeader::uid, val, STarHeader::version, and dtl::version.

Referenced by s_Dump().

◆ s_DumpSparse() [1/2]

Definition at line 2089 of file tar.cpp.

References _ASSERT, ALIGN_SIZE, BLOCK_OF, blocks, eDiag_Info, ERR_POST, file, Info(), kEmptyStr, NStr::NumericToString(), OFFSET_OF, s_DumpSparseMap(), s_PositionAsString(), and SetDiagPostLevel().

Referenced by CTar::x_ExtractSparseFile(), and CTar::x_ReadEntryInfo().

◆ s_DumpSparse() [2/2] ◆ s_DumpSparseMap() [1/2]

Definition at line 751 of file tar.cpp.

References done, dump, len, memcchr(), NStr::NumericToString(), offset, NStr::PrintableString(), s_DecodeUint8(), s_OffsetAsString(), s_Printable(), string, TAR_GNU_CONTIND, and TAR_GNU_REGION.

Referenced by s_DumpHeader(), and s_DumpSparse().

◆ s_DumpSparseMap() [2/2] ◆ s_DumpZero() ◆ s_EncodeUint8() ◆ s_FraqToNanosec() ◆ s_IsOctal() ◆ s_Length() static size_t s_Length ( const char *  ptr, size_t  maxsize  ) static ◆ s_MajorMinor() ◆ s_MatchExcludeMask() ◆ s_ModeAsString()

Definition at line 509 of file tar.cpp.

References buf, fTarGExecute, fTarGRead, fTarGWrite, fTarOExecute, fTarORead, fTarOWrite, fTarSetGID, fTarSetUID, fTarSticky, fTarUExecute, fTarURead, fTarUWrite, and string.

Referenced by operator<<(), and s_DumpHeader().

◆ s_ModeToTar()

Definition at line 289 of file tar.cpp.

References fTarGExecute, fTarGRead, fTarGWrite, fTarOExecute, fTarORead, fTarOWrite, fTarSetGID, fTarSetUID, fTarSticky, fTarUExecute, fTarURead, fTarUWrite, and mask.

Referenced by CTar::x_Append(), and CArchive::x_Append().

◆ s_NumToBase256() ◆ s_NumToOctal() ◆ s_OctalToNum() ◆ s_OffsetAsString() ◆ s_OSReason()

Definition at line 646 of file tar.cpp.

References _ASSERT, kEmptyStr, kUnknownError, CNcbiError::SetErrno(), strerror(), string, and NStr::strncasecmp().

Referenced by CTarReader::Read(), CTar::x_Append(), CTar::x_AppendFile(), CTar::x_AppendStream(), CTar::x_Close(), CTar::x_ExtractEntry(), CTar::x_ExtractPlainFile(), CTar::x_ExtractSparseFile(), CTar::x_Flush(), CTar::x_Open(), CTar::x_ProcessEntry(), CTar::x_RestoreAttrs(), and CTar::x_WriteArchive().

◆ s_ParsePAXNumeric() ◆ s_PositionAsString()

Definition at line 672 of file tar.cpp.

References _ASSERT, BLOCK_OF, BLOCK_SIZE, CDirEntry::eFile, file, NStr::fWithCommas, CDirEntry::GetName(), CDirEntry::GetType(), NStr::NumericToString(), OFFSET_OF, and result.

Referenced by s_Dump(), s_DumpSparse(), s_DumpZero(), and CTar::x_ReadEntryInfo().

◆ s_Printable() ◆ s_SetStateSafe() void s_SetStateSafe ( CNcbiIosios, IOS_BASE::iostate  state  ) throw ( ) inline ◆ s_SizeOrMajorMinor()

Definition at line 603 of file tar.cpp.

References CTarEntryInfo::eBlockDev, CTarEntryInfo::eCharDev, CTarEntryInfo::eDir, CTarEntryInfo::ePipe, CTarEntryInfo::eSparseFile, CTarEntryInfo::eSymLink, CTarEntryInfo::eVolHeader, info, NStr::NumericToString(), s_MajorMinor(), and string.

Referenced by operator<<().

◆ s_TarChecksum() ◆ s_TarToMode() [1/2]

Definition at line 239 of file tar.cpp.

References fTarGExecute, fTarGRead, fTarGWrite, fTarOExecute, fTarORead, fTarOWrite, fTarSetGID, fTarSetUID, fTarSticky, fTarUExecute, fTarURead, and fTarUWrite.

◆ s_TarToMode() [2/2]

Definition at line 203 of file tar.cpp.

References CDirEntry::fExecute, CDirEntry::fRead, CDirEntry::fSetGID, CDirEntry::fSetUID, CDirEntry::fSticky, fTarGExecute, fTarGRead, fTarGWrite, fTarOExecute, fTarORead, fTarOWrite, fTarSetGID, fTarSetUID, fTarSticky, fTarUExecute, fTarURead, fTarUWrite, and CDirEntry::fWrite.

Referenced by CTarEntryInfo::GetMode(), CTar::x_Append(), and CTar::x_RestoreAttrs().

◆ s_ToArchiveName() ◆ s_ToFilesystemPath() ◆ s_TruncateFile() ◆ s_TypeAsChar() ◆ s_UserGroupAsString() ◆ sx_Signature() ◆ x_DropTrailingSlashes()

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4