1 #ifndef UTIL_COMPRESS__TAR__HPP
2 #define UTIL_COMPRESS__TAR__HPP
130 case eUnsupportedTarFormat:
return "eUnsupportedTarFormat";
131 case eUnsupportedEntryType:
return "eUnsupportedEntryType";
132 case eUnsupportedSource:
return "eUnsupportedSource";
133 case eNameTooLong:
return "eNameTooLong";
134 case eChecksum:
return "eChecksum";
135 case eBadName:
return "eBadName";
136 case eCreate:
return "eCreate";
137 case eOpen:
return "eOpen";
138 case eRead:
return "eRead";
139 case eWrite:
return "eWrite";
140 case eBackup:
return "eBackup";
141 case eMemory:
return "eMemory";
142 case eRestoreAttrs:
return "eRestoreAttrs";
189 const string&
GetName(
void)
const {
return m_Name; }
194 {
return m_Stat.orig.st_mtime; }
196 {
CTime mtime(m_Stat.orig.st_mtime);
200 {
return m_Stat.orig.st_atime; }
202 {
CTime atime(m_Stat.orig.st_atime);
206 {
return m_Stat.orig.st_ctime; }
208 {
CTime ctime(m_Stat.orig.st_ctime);
212 {
return m_Stat.orig.st_size; }
218 unsigned int GetMajor(
void)
const;
219 unsigned int GetMinor(
void)
const;
221 {
return m_Stat.orig.st_uid; }
223 {
return m_Stat.orig.st_gid; }
225 {
return which == ePos_Header ? m_Pos : m_Pos + m_HeaderSize; }
228 const string&
GetPath(
void)
const {
return m_Path; }
232 {
return (m_Type ==
info.m_Type &&
233 m_Name ==
info.m_Name &&
234 m_LinkName ==
info.m_LinkName &&
235 m_UserName ==
info.m_UserName &&
236 m_GroupName ==
info.m_GroupName &&
237 m_HeaderSize ==
info.m_HeaderSize &&
238 memcmp(&m_Stat,&
info.m_Stat,
sizeof(m_Stat)) == 0 &&
239 m_Pos ==
info.m_Pos ?
true :
false); }
244 : m_Type(
eUnknown), m_HeaderSize(0), m_Pos(pos)
245 { memset(&m_Stat, 0,
sizeof(m_Stat)); }
308 fIgnoreZeroBlocks = (1<<1),
312 fFollowLinks = (1<<2),
318 fUpdate = (1<<4) | fOverwrite,
320 fBackup = (1<<5) | fOverwrite,
322 fEqualTypes = (1<<6),
324 fPreserveOwner = (1<<7),
326 fPreserveMode = (1<<8),
328 fPreserveTime = (1<<9),
330 fPreserveAll = fPreserveOwner | fPreserveMode | fPreserveTime,
332 fKeepAbsolutePath = (1<<12),
334 fSparseUnsupported = (1<<13),
339 fSkipUnsupported = (1<<15),
343 fIgnoreUnreadable = (1<<17),
345 fLongNameSupplement = (1<<18),
348 fDumpEntryHeaders = (1<<20),
349 fSlowSkipWithRead = (1<<21),
353 fIgnoreNameCase = (1<<24),
355 fConflictOverwrite = (1<<25),
358 fStreamPipeThrough = (1<<28),
360 fTarfileNoTruncate = (1<<29),
363 fStandardHeaderOnly = (1<<30),
366 fDefault = fOverwrite | fPreserveAll
385 CTar(
const string& filename,
size_t blocking_factor = 20);
453 unique_ptr<TEntries> Append(
const string& name);
487 unique_ptr<TEntries> Update(
const string& name);
511 unique_ptr<TEntries> Extract(
void);
520 unique_ptr<TEntries> List(
void);
537 TFlags GetFlags(
void)
const;
543 Uint8 GetCurrentPosition(
void)
const;
569 const string& GetBaseDir(
void)
const;
575 void SetBaseDir(
const string& dirname);
587 static Uint8 EstimateArchiveSize(
const TFiles& files,
588 size_t blocking_factor = 20,
629 IReader* GetNextEntryData(
void);
674 eList = (1 << 2) | eRO,
675 eAppend = (1 << 3) | eRW,
676 eUpdate = eList | eAppend,
677 eExtract = (1 << 4) | eRO,
678 eTest = eList | eExtract,
679 eCreate = (1 << 5) | eWO,
680 eInternal = (1 << 6) | eRO
705 void x_Open(EAction action);
709 bool x_Flush(
bool nothrow =
false);
712 void x_Backspace(EAction action);
722 bool x_PackCurrentName(
STarHeader* header,
bool link);
725 void x_WriteEntryInfo(
const string& name);
728 unique_ptr<TEntries> x_ReadAndProcess(EAction action);
733 bool x_ProcessEntry(EAction action,
Uint8 size,
const TEntries*
done);
759 const char* x_ReadArchive (
size_t&
n);
760 void x_WriteArchive(
size_t n,
const char*
buffer = 0);
763 unique_ptr<TEntries> x_Append(
const string& name,
const TEntries* toc = 0);
770 void x_AppendStream(
const string& name,
CNcbiIstream& is);
773 bool x_AppendFile(
const string&
file);
User-creatable info for streaming into a tar.
A very basic data-read interface.
bool operator==(const CEquivRange &A, const CEquivRange &B)
static void Test(const char *bind1, SQLSMALLINT type1, const char *bind2, SQLSMALLINT type2)
@ eNoOwnership
No ownership is assumed.
const string & GetPath(void) const
void Create(void)
Create a new empty archive.
void Test(void)
Verify archive integrity.
const size_t m_BufferSize
Buffer(record) size for I/O operations.
string m_GroupName
Group name.
string m_LinkName
Link name if type is e{Sym|Hard}Link.
void x_Close(bool truncate)
const string & GetLinkName(void) const
const string & GetUserName(void) const
bool m_Bad
True if a fatal output error occurred.
CTarEntryInfo m_Current
Current entry being processed.
bool m_Modified
True after at least one write.
Uint8 m_StreamPos
Position in stream (0-based)
void x_Open(EAction action)
EOpenMode
Archive open mode and action.
time_t GetLastAccessTime(void) const
Uint8 GetCurrentPosition(void) const
Get current stream position.
unique_ptr< TEntries > x_Append(const string &name, const TEntries *toc=0)
char * m_Buffer
I/O buffer (page-aligned)
string m_Path
Iff filesystem involved in processing.
EType GetType(void) const
string m_UserName
User name.
pair< string, Uint8 > TFile
Define a list of files with sizes (directories and specials, such as devices, must be given with size...
const string & GetGroupName(void) const
const string & GetBaseDir(void) const
Get base directory to use for files while extracting from/adding to the archive, and in the latter ca...
CNcbiIos & m_Stream
Archive stream (used for all I/O)
Uint8 GetSize(void) const
virtual bool Checkpoint(const CTarEntryInfo &, bool)
Return false to skip the current entry when reading; the return code gets ignored when writing.
virtual const char * GetErrCodeString(void) const override
Translate from an error code value to its string representation.
CTar & operator=(const CTar &)
TFlags m_Flags
Bitwise OR of flags.
unsigned int GetGroupId(void) const
CTime GetModificationCTime(void) const
list< CTarEntryInfo > TEntries
Define a list of entries.
Uint8 GetPosition(EPos which) const
NCBI_EXCEPTION_DEFAULT(CTarException, CCoreException)
CTime GetCreationCTime(void) const
char * m_BufPtr
Page-unaligned buffer pointer.
unsigned int TTarMode
Bitwise OR of ETarModeBits.
time_t GetModificationTime(void) const
CTime GetLastAccessCTime(void) const
const string & GetName(void) const
size_t m_ZeroBlockCount
Zero blocks seen in between entries.
CTarUserEntryInfo(const string &name, Uint8 size)
Uint8 m_Pos
Entry (not data!) position in archive.
unique_ptr< TEntries > List(void)
Get information about all matching archive entries.
void SetFlags(TFlags flags)
Set processing flags.
void Close(void)
Close the archive making sure all pending output is flushed.
EOpenMode m_OpenMode
What was it opened for.
unique_ptr< TEntries > Append(const string &name)
Append an entry at the end of the archive that already exists.
TFlags GetFlags(void) const
Get processing flags.
unsigned int GetUserId(void) const
unsigned int TFlags
Bitwise OR of EFlags.
unique_ptr< TEntries > Update(const string &name)
Look whether more recent copies of the archive members are available in the file system,...
string m_FileName
Tar archive file name (only if file)
CTarEntryInfo(Uint8 pos=0)
string m_BaseDir
Base directory for relative paths.
bool x_Flush(bool nothrow=false)
CDirEntry::SStat m_Stat
Direntry-compatible info.
unique_ptr< TEntries > x_ReadAndProcess(EAction action)
streamsize m_HeaderSize
Total size of all headers for the entry.
EStatus
I/O completion code.
size_t m_BufferPos
Position within the record.
time_t GetCreationTime(void) const
ostream & operator<<(ostream &, const CTarEntryInfo &)
Nice TOC(table of contents) printout.
CNcbiFstream * m_FileStream
File stream of the archive (if file)
@ fTarOWrite
write by other
@ fTarUWrite
write by owner
@ fTarGExecute
execute/search by group
@ fTarGWrite
write by group
@ fTarOExecute
execute/search by other
@ fTarSetGID
set GID on execution
@ fTarSetUID
set UID on execution
@ fTarSticky
reserved (sticky bit)
@ fTarUExecute
execute/search by owner
@ eSparseFile
GNU/STAR sparse file.
@ eGNULongName
GNU long name.
@ ePAXHeader
PAX extended header.
@ eVolHeader
Volume header.
virtual void x_Init(const CDiagCompileInfo &info, const string &message, const CException *prev_exception, EDiagSev severity)
Helper method for initializing exception data.
EErrCode
Error types that an application can generate.
TErrCode GetErrCode(void) const
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
unsigned int TSpecialModeBits
Bitwise OR of ESpecialModeBits.
unsigned int TMode
Bitwise OR of "EMode".
TNcbiSys_stat orig
Original stat structure.
@ eSymLink
Symbolic link (UNIX only)
@ eBlockSpecial
Block special (UNIX only)
@ eCharSpecial
Character special.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ios CNcbiIos
Portable alias for ios.
IO_PREFIX::fstream CNcbiFstream
Portable alias for fstream.
ECase
Which type of string comparison.
@ eCase
Case sensitive compare.
void SetNanoSecond(long nanosecond)
Set nanoseconds.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
const struct ncbi::grid::netcache::search::fields::SIZE size
static EIO_Status x_Flush(CONN conn, const STimeout *timeout, int isflush)
static void x_Close(SHttpConnector *uuu)
static const char * x_ReadLine(const char *path, char *line, size_t size)
static SERV_ITER x_Open(const char *service, int ismask, TSERV_Type types, unsigned int preferred_host, unsigned short preferred_port, double preference, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, int external, const char *arg, const char *val, SSERV_Info **info, HOST_INFO *host_info)
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
@ eSuccess
Successfully retrieved.
NCBI_XUTIL_EXPORT
Parameter to control printing diagnostic message about conversion of static array data from a differe...
Alternate stat structure for use instead of the standard struct stat.
static DP_BlockInfo * blocks