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_source.html below:

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

49 #ifdef _FORTIFY_SOURCE 50 # undef _FORTIFY_SOURCE 52 #define _FORTIFY_SOURCE 0 56 #if !defined(NCBI_OS_UNIX) && !defined(NCBI_OS_MSWIN) 57 # error "Class CTar can be defined on UNIX and MS-Windows platforms only!" 60 #if defined(NCBI_OS_UNIX) 61 # include "../../../corelib/ncbi_os_unix_p.hpp" 66 # include <sys/mkdev.h> 68 # ifdef HAVE_SYS_SYSMACROS_H 69 # include <sys/sysmacros.h> 71 # ifdef NCBI_OS_DARWIN 75 # define makedev makedev 77 # if !defined(major) || !defined(minor) || !defined(makedev) 78 # error "Device macros undefined in this UNIX build!" 80 #elif defined(NCBI_OS_MSWIN) 81 # include "../../../corelib/ncbi_os_mswin_p.hpp" 83 typedef unsigned int mode_t

;

84 typedef unsigned int

uid_t;

85 typedef unsigned int

gid_t;

89 #define NCBI_USE_ERRCODE_X Util_Compress 90 #define NCBI_MODULE NCBITAR 107

ptr[--

len

] = char(

'0'

+

char

(

val

& 7));

119  size_t i

= *ptr ? 0 : 1;

120  while

(

i

<

len

&& ptr[

i

]) {

121  if

(!

isspace

((

unsigned char

) ptr[

i

]))

127  while

(

i

<

len

&&

'0'

<= ptr[

i

] && ptr[

i

] <=

'7'

) {

130  val

|= ptr[

i

++] -

'0'

;

132  while

(

i

<

len

&& ptr[

i

]) {

133  if

(!

isspace

((

unsigned char

) ptr[

i

]))

145

ptr[--

len

] = (

unsigned

char)(

val

& 0xFF);

175  if

(*ptr &

'\x40'

) {

178  val

= *ptr++ &

'\x3F'

;

184  val

|= (

unsigned

char)(*ptr++);

195  if

(*ptr &

'\x80'

) {

251

#

if

defined(S_IRUSR)

253

#elif defined(S_IREAD)

256

#

if

defined(S_IWUSR)

258

#elif defined(S_IWRITE)

261

#

if

defined(S_IXUSR)

263

#elif defined(S_IEXEC)

302

#

if

defined(S_IRUSR)

304

#elif defined(S_IREAD)

307

#

if

defined(S_IWUSR)

309

#elif defined(S_IWRITE)

312

#

if

defined(S_IXUSR)

314

#elif defined(S_IEXEC)

317

#

if

defined(S_IRGRP)

319

#elif defined(S_IREAD)

329

#

if

defined(S_IROTH)

331

#elif defined(S_IREAD)

342 #if defined(S_IFMT) || defined(_S_IFMT) 349  if

(!(

mask

& 07777)) {

357 static size_t s_Length

(

const char

* ptr,

size_t

maxsize)

359  const char

* pos = (

const char

*) memchr(ptr,

'\0'

, maxsize);

360  return

pos ? (size_t)(pos - ptr) : maxsize;

371 #define ALIGN_SIZE(size) (((size) + (BLOCK_SIZE-1)) & ~(BLOCK_SIZE-1)) 372 #define OFFSET_OF(size) ( (size) & (BLOCK_SIZE-1)) 373 #define BLOCK_OF(pos) ((pos) >> 9) 374 #define SIZE_OF(blk) ((blk) << 9) 377 #define BLOCK_SIZE SIZE_OF(1) 438  size_t len

=

sizeof

(h->

checksum

) - (isgnu ? 2 : 1);

442  unsigned long

checksum = 0;

443  const unsigned char

* p = (

const unsigned char

*) block->

buffer

;

444  for

(

size_t i

= 0;

i

<

sizeof

(block->

buffer

); ++

i

) {

486  if

(

sizeof

(

int

) >= 4 &&

sizeof

(

m_Stat

.

orig

.st_rdev) >= 4) {

487  return

(*((

unsigned int

*) &

m_Stat

.

orig

.st_rdev) >> 16) & 0xFFFF;

490  return

(

unsigned int

)(-1);

501  if

(

sizeof

(

int

) >= 4 &&

sizeof

(

m_Stat

.

orig

.st_rdev) >= 4) {

502  return

*((

unsigned int

*) &

m_Stat

.

orig

.st_rdev) & 0xFFFF;

505  return

(

unsigned int

)(-1);

512

memset(

buf

,

'-'

,

sizeof

(

buf

));

515  char

* grp = usr + 3;

516  char

* oth = grp + 3;

585  string

user(

info

.GetUserName());

589  string

group(

info

.GetGroupName());

593  return

user +

'/'

+ group;

607  unsigned int

major =

info

.GetMajor();

608  unsigned int

minor =

info

.GetMinor();

616  info

.GetSize() == 0) {

625  CTime

mtime(

info

.GetModificationTime());

634

os <<

" -> "

<<

info

.GetLinkName();

655  if

(!strerr || !*strerr

659

::sprintf(errbuf,

"Error %d"

, x_errno);

660

}

else if

(x_errno != -1) {

661

::sprintf(errbuf,

"Error 0x%08X"

, (

unsigned int

) x_errno);

663

::strcpy (errbuf,

"Unknown error (-1)"

);

668  return string

(

": "

) + strerr;

673  const string

& entryname)

678  if

(!

file

.empty()) {

690  if

(!entryname.empty()) {

691  result

+=

", while in '"

+ entryname +

'\''

;

708  for

(

size_t i

= 0;

i

<

len

; ++

i

) {

719  if

(!

text

&& maxsize > 1 && !*field) {

730  return check

&& !retval.empty() ?

"\\0"

+ retval : retval;

734 #if !defined(__GNUC__) && !defined(offsetof) 735 # define offsetof(T, F) ((char*) &(((T*) 0)->F) - (char*) 0) 738 #define TAR_PRINTABLE_EX(field, text, size) \ 739  "@"

+ s_OffsetAsString((size_t) offsetof(STarHeader, field)) + \

740

"[" NCBI_AS_STRING(field) "]:" + \

741

string(14 - sizeof(NCBI_AS_STRING(field)), ' ') + \

742

'"' + s_Printable(h->field, size, text || excpt) + '"'

744 #define TAR_PRINTABLE(field, text) \ 745  TAR_PRINTABLE_EX(field, text, sizeof(h->field)) 748 #define TAR_GNU_REGION "[gnu.region]: " 749 #define TAR_GNU_CONTIND "[gnu.contind]: " 752  const char

* contind,

bool

excpt =

false

)

760  if

(

memcchr

(sparse,

'\0'

, 24)) {

761  offset

= (size_t)(sparse - (

const char

*) h);

769  if

(ok_off & ok_len) {

803

}

while

(sparse < contind);

804  if

(!

dump

.empty()) {

807  offset

= (size_t)(contind - (

const char

*) h);

810

+ (*contind ?

"\" [to-be-cont'd]"

:

"\" [last]"

);

817  size_t size

= bmap.size();

819  for

(

size_t n

= 0;

n

<

size

; ++

n

) {

847  if

(

ok

&& (ok < 0 || val > 7)) {

850  dump

+=

" (base-256)"

;

857  if

(

ok

&& (ok < 0 || val > 7)) {

860  dump

+=

" (base-256)"

;

867  if

(

ok

&& (ok < 0 || val > 7)) {

870  dump

+=

" w/o map(s)!"

;

873  dump

+=

" (base-256)"

;

883  if

(

ok

||

val

> 7) {

899  const char

* tname = 0;

906  if

(namelen && h->

name

[namelen - 1] ==

'/'

)

907

tname =

"legacy regular entry (directory)"

;

910

tname =

"legacy regular entry (file)"

;

917

tname =

"legacy hard link"

;

919

tname =

"legacy hard link - not FULLY supported"

;

921

tname += h->

typeflag

[0] !=

'\1'

? 7

: 0;

927

tname =

"legacy symbolic link"

;

929

tname =

"legacy symbolic link - not FULLY supported"

;

931

tname += h->

typeflag

[0] !=

'\2'

? 7

: 0;

937

tname =

"character device"

;

943

tname =

"block device"

;

947

tname =

"directory"

;

956

tname =

"contiguous file"

;

959

tname =

"global extended header"

;

966

tname =

"extended (POSIX 1003.1-2001 [PAX]) header" 967  " - not FULLY supported"

;

969

tname =

"extended (POSIX 1003.1-2001 [PAX] by Sun) header" 970  " - not FULLY supported"

;

973

tname =

"extended header"

;

977

tname =

"Solaris ACL"

;

981

tname =

"GNU extension: directory dump"

;

985

tname =

"Solaris extended attribute file"

;

990

tname =

"Inode metadata only"

;

995

tname =

"GNU extension: long link"

;

1001

tname =

"GNU extension: long name"

;

1007

tname =

"GNU extension: multi-volume entry"

;

1010

tname =

"STAR extension: multi-volume entry"

;

1018

tname =

"GNU extension (obsolete): long filename(s)"

;

1026

tname =

"GNU extension: sparse file"

;

1031

tname =

"STAR extension: sparse file"

;

1039

tname =

"Volume header"

;

1045

tname =

"local vendor enhancement / user-defined extension"

;

1047  dump

+= (

" ["

+

string

(tname ? tname :

"reserved"

)

1050

:

" -- NOT SUPPORTED]\n"

));

1057

tname =

"legacy (V7)"

;

1061

tname =

"old GNU (NCBI)"

;

1068

tname =

"ustar (NCBI)"

;

1075

tname =

"posix (NCBI)"

;

1106  if

(

ok

&&

val

> 7) {

1113  if

(

ok

&&

val

> 7) {

1122  const char

* realsize = h->

star

.prefix + 107;

1126

+

"[star.realsize]:\"" 1128  if

(

ok

&& (ok < 0 || val > 7)) {

1131  dump

+=

" (base-256)"

;

1144  if

(

ok

||

val

> 7) {

1160  if

(

ok

||

val

> 7) {

1169

tname = (

const char

*) &h->

star

+

sizeof

(h->

star

);

1178  if

(

ok

||

val

> 7) {

1194  if

(

ok

||

val

> 7) {

1205  if

(

memcchr

(h->

gnu

.unused,

'\0'

,

sizeof

(h->

gnu

.unused))) {

1210

h->

gnu

.contind, excpt);

1211  if

(

memcchr

(h->

gnu

.realsize,

'\0'

,

sizeof

(h->

gnu

.realsize))) {

1213  sizeof

(h->

gnu

.realsize));

1216  if

(

ok

&& (ok < 0 || val > 7)) {

1220  dump

+=

" (base-256)"

;

1223

tname = (

const char

*) &h->

gnu

+

sizeof

(h->

gnu

);

1225

tname = h->

gnu

.ctime +

sizeof

(h->

gnu

.ctime);

1239  while

(&tname[

n

] < (

const char

*) h +

BLOCK_SIZE

) {

1241  size_t offset

= (size_t)(&tname[

n

] - (

const char

*) h);

1246  const char

* e = (

const char

*) memchr(&tname[

n

],

'\0'

,

len

);

1248  len

= (size_t)(e - &tname[

n

]);

1262  if

(ok < 0 || val > 7 || okaytime) {

1264  if

(ok < 0 || val > 7) {

1268  dump

+=

"] (base-256)"

;

1269

}

else if

(okaytime) {

1288 #undef TAR_PRINTABLE 1296

ios.setstate(

state

);

1309

: m_FileName(filename),

1311

m_Stream(*m_FileStream),

1312

m_ZeroBlockCount(0),

1313

m_BufferSize(

SIZE_OF

(blocking_factor)),

1318

m_OpenMode(

eNone

),

1319

m_Modified(

false

),

1331

m_ZeroBlockCount(0),

1332

m_BufferSize(

SIZE_OF

(blocking_factor)),

1337

m_OpenMode(

eNone

),

1338

m_Modified(

false

),

1354  for

(

size_t i

= 0;

i

<

sizeof

(

m_Mask

) /

sizeof

(

m_Mask

[0]); ++

i

) {

1364 #define TAR_THROW(who, errcode, message) \ 1365  NCBI_THROW(CTarException, errcode, \ 1366  s_PositionAsString(who->m_FileName, who->m_StreamPos, \ 1367  who->m_BufferSize, \ 1368  who->m_Current.GetName()) + (message)) 1370 #define TAR_THROW_EX(who, errcode, message, hdr, fmt) \ 1371  TAR_THROW(who, errcode, \ 1372  who->m_Flags & fDumpEntryHeaders \ 1373  ? string(message) + ":\n"

+ s_DumpHeader(hdr, fmt, true) \

1376 #define TAR_POST(subcode, severity, message) \ 1377  ERR_POST_X(subcode, (severity) << \ 1378  s_PositionAsString(m_FileName, m_StreamPos, m_BufferSize,\ 1379  m_Current.GetName()) + (message)) 1386  if

(pagesize < 4096 || (pagesize & (pagesize - 1))) {

1389  size_t

pagemask = pagesize - 1;

1439  int

x_errno = errno;

1443  "Archive flush failed"

+

s_OSReason

(x_errno));

1446  "Archive flush failed"

+

s_OSReason

(x_errno));

1459  if

(::truncate(filename.c_str(), (off_t) filesize) != 0)

1462 #ifdef NCBI_OS_MSWIN 1464  HANDLE

handle = ::CreateFile(x_filename.c_str(), GENERIC_WRITE,

1465

0

,

NULL

, OPEN_EXISTING,

1466

FILE_ATTRIBUTE_NORMAL,

NULL

);

1468

LARGE_INTEGER x_filesize;

1469

x_filesize.QuadPart = filesize;

1470  if

(!::SetFilePointerEx(handle, x_filesize,

NULL

, FILE_BEGIN)

1471

|| !::SetEndOfFile(handle)) {

1472

x_error = (

int

) ::GetLastError();

1474  bool

closed = ::CloseHandle(handle) ?

true

:

false

;

1475  if

(!x_error && !closed) {

1476

x_error = (

int

) ::GetLastError();

1479

x_error = (

int

) ::GetLastError();

1491  int

x_errno = errno;

1493  "Cannot close archive"

+

s_OSReason

(x_errno));

1510  bool

toend =

false

;

1521

}

else if

(action !=

eAppend

) {

1529  "Pending changes may be discarded" 1530  " upon reopen of in-stream archive"

);

1538  "Archive I/O stream is in bad state"

);

1547 #ifdef NCBI_OS_MSWIN 1549  HANDLE

handle = (

HANDLE

) _get_osfhandle(_fileno(stdin));

1550  if

(GetFileType(handle) != FILE_TYPE_DISK) {

1599  int

x_errno = errno;

1601  "Cannot open archive"

+

s_OSReason

(x_errno));

1610  "Archive file is in bad state"

);

1662  _ASSERT

(temp && temp->size() < 2);

1663  if

(temp->size() < 1) {

1684

IOS_BASE::iostate iostate =

m_Stream

.rdstate();

1686 #ifdef NCBI_COMPILER_MIPSPRO 1693

xread = is->gcount();

1705 # ifdef NCBI_COMPILER_WORKSHOP 1721

+ (xread ?

")"

:

"): EOF"

));

1729

nread += (size_t) xread;

1760  if

(!nwrite ||

m_Bad

) {

1768  if

(avail > nwrite) {

1771  size_t

advance = avail;

1772  if

(src && src != (

const char

*)(-1L)) {

1782  size_t

nwritten = 0;

1785

streamsize xwritten;

1786

IOS_BASE::iostate iostate =

m_Stream

.rdstate();

1795  if

(xwritten <= 0) {

1797

}

else if

(iostate) {

1803  if

(xwritten <= 0) {

1806  if

(src != (

const char

*)(-1L)) {

1808  "Archive write failed"

+

s_OSReason

(x_errno));

1811  "Archive write failed"

+

s_OSReason

(x_errno));

1814

nwritten += (size_t) xwritten;

1844  string

* fraq,

EPAXBit

assign)

1850  const char

* p = (

const char

*) memchr(

str

,

'.'

,

len

);

1853

}

else if

(fraq == (

string

*)(-1L)) {

1863  if

(*p ==

'.'

&& ++p !=

str

+

len

) {

1864  len

-= (size_t)(p -

str

);

1866  for

(

size_t n

= 0;

n

<

len

; ++

n

) {

1867  if

(!

isdigit

((

unsigned char

) p[

n

])) {

1871  if

(assign && fraq) {

1872

fraq->assign(p,

len

);

1884  for

(

size_t i

= 0;

i

<

len

; ++

i

) {

1885  unsigned char

c = (

unsigned

char)

str

[

i

];

1898  return n

? 10 *

ipow10

(

n

- 1) : 1;

1905  size_t len

= fraq.size();

1918  result

= (long)((temp + 5) / 10);

1927  Uint8

major = 0, minor = 0,

size

= 0, sparse = 0, uid = 0, gid = 0;

1928  Uint8

mtime = 0, atime = 0, ctime = 0,

dummy

= 0;

1929  string

mtime_fraq, atime_fraq, ctime_fraq;

1930  string

path, linkpath, name, uname, gname;

1931  string

* nodot = (

string

*)(-1L);

1932  const struct

SPAXParseTable {

1938

{

"mtime"

, &mtime, &mtime_fraq,

fPAXMtime

},

1939

{

"atime"

, &atime, &atime_fraq,

fPAXAtime

},

1940

{

"ctime"

, &ctime, &ctime_fraq,

fPAXCtime

},

1944

{

"uid"

, &uid, nodot,

fPAXUid

},

1945

{

"gid"

, &gid, nodot,

fPAXGid

},

1948

{

"linkpath"

, 0, &linkpath,

fPAXNone

},

1954

{

"GNU.sparse.realsize"

, &sparse, nodot,

fPAXSparse

},

1955

{

"GNU.sparse.major"

, &major, nodot,

fPAXSparse

},

1956

{

"GNU.sparse.minor"

, &minor, nodot,

fPAXSparse

},

1958

{

"GNU.sparse.name"

, 0, &name,

fPAXNone

},

1960

{

"SCHILY.realsize"

, &sparse, nodot,

fPAXSparse

}

1962  const char

* s =

data

.c_str();

1964  size_t l

=

data

.size();

1973  if

(!(e = (

char

*) memchr(s,

'\n'

,

l

))) {

1977  if

(!

isdigit

((

unsigned char

)(*s)) || !(

len

= strtoul(s, &k, 10))

1978

|| errno || s +

len

- 1 != e || (*k !=

' '

&& *k !=

'\t'

)

1979

|| !(v = (

char

*) memchr(k,

'='

, (

size_t

)(e - k)))

1980

|| !(klen = (

size_t

)(v++ - ++k))

1981

|| memchr(k,

' '

, klen) || memchr(k,

'\t'

, klen)

1982

|| !(vlen = (

size_t

)(e - v))) {

1984  "Skipping malformed PAX data"

);

1988  for

(

size_t n

= 0;

n

<

sizeof

(parser) /

sizeof

(parser[0]); ++

n

) {

1989  if

(strlen(parser[

n

].

key

) == klen

1990

&& memcmp(parser[

n

].

key

, k, klen) == 0) {

1991  if

(!parser[

n

].

val

) {

1992  if

(parser[

n

].

str

) {

1993

parser[

n

].str->assign(v, vlen);

1996

parser[

n

].

str

, parser[

n

].bit)) {

1998  "Ignoring bad numeric \"" 2000

+

"\" in PAX value \"" 2003

parsed |= parser[

n

].bit;

2011  "Ignoring unrecognized PAX value \"" 2025  "Ignoring PAX GNU sparse file size " 2027

+

" when real size " 2029

+

" is also present"

);

2030

}

else if

(!

dummy

&& major == 1 && minor == 0) {

2032  if

(!name.empty()) {

2033  if

(!path.empty()) {

2035  "Replacing PAX file name \""

+ path

2036

+

"\" with GNU sparse file name \""

+ name

2044

}

else if

(!sparse) {

2071  const string

& entryname,

const STarHeader

* h,

2082

|| !*h->

gnu

.contind)

2090  const string

& entryname,

const STarHeader

* h,

2091  const char

* contind,

Uint8

datasize)

2097

+

"GNU sparse file map header (cont'd):\n" 2107  const string

& entryname,

2108  const

vector< pair<Uint8, Uint8> >& bmap)

2113

+

"PAX GNU/1.0 sparse file map data:\n" 2120  size_t

zeroblock_count,

bool

eot =

false

)

2127

: (eot ?

"End-Of-Tape"

:

"End-Of-File"

)) +

'\n'

);

2134  return '0'

<= c && c <=

'7'

?

true

:

false

;

2142  size_t

nread =

sizeof

(block->

buffer

);

2149  "Unexpected EOF in archive"

);

2155  if

(memcmp(h->

magic

,

"ustar"

, 6) == 0) {

2156  if

((h->

star

.prefix[

sizeof

(h->

star

.prefix) - 1] ==

'\0' 2164

}

else if

(memcmp(h->

magic

,

"ustar "

, 8) == 0) {

2167

}

else if

(memcmp(h->

magic

,

"\0\0\0\0\0"

, 6) == 0) {

2172  "Unrecognized header format"

, h, fmt);

2182  for

(

size_t i

= 0;

i

<

sizeof

(block->

buffer

); ++

i

) {

2193  "Bad checksum"

, h, fmt);

2198  int

checksum =

int

(

val

);

2202  unsigned int

usum = 0;

2203  const char

* p = block->

buffer

;

2204  for

(

size_t i

= 0;

i

<

sizeof

(block->

buffer

); ++

i

) {

2206

usum += (

unsigned

char)(*p);

2210  for

(

size_t

j = 0; j <

sizeof

(h->

checksum

); ++j) {

2212

usum -= (

unsigned

char)(*p) -

' '

;

2217  if

(checksum != ssum && (

unsigned int

) checksum != usum) {

2218  string

message =

"Header checksum failed"

;

2220

message +=

", expected "

;

2221  if

(usum != (

unsigned int

) ssum) {

2222

message +=

"either "

;

2228  if

(usum != (

unsigned int

) ssum) {

2230  if

((

unsigned int

) ssum > 7) {

2252

? 107 :

sizeof

(h->

star

.prefix));

2257  sizeof

(h->

name

))));

2269  "Bad entry mode"

, h, fmt);

2277  "Bad user ID"

, h, fmt);

2285  "Bad group ID"

, h, fmt);

2293  "Bad entry size"

, h, fmt);

2299  " This run-time may not support large TAR entries" 2300  " (have you built it --with-lfs?)" 2307  "Bad modification time"

, h, fmt);

2325

tlen = fmt ==

eTar_Star

?

sizeof

(h->

star

.atime) :

sizeof

(h->

gnu

.atime);

2329  "Bad last access time"

, h, fmt);

2335

tlen = fmt ==

eTar_Star

?

sizeof

(h->

star

.ctime) :

sizeof

(h->

gnu

.ctime);

2339  "Bad creation time"

, h, fmt);

2352  if

(namelen && h->

name

[namelen - 1] ==

'/'

) {

2375  "Ignoring hard link size (" 2389  "Bad device minor number"

, h, fmt);

2391

usum = (

unsigned int

)

val

;

2394  "Bad device major number"

, h, fmt);

2401

(

unsigned int

)((

val

<< 16) | usum);

2416  " *** Contiguous TAR entries processed as regular files" 2442  "Repetitious PAX headers," 2443  " archive may be corrupt"

);

2462  const char

* realsize = fmt !=

eTar_Star 2463

? h->

gnu

.realsize : h->

star

.prefix + 107;

2465

?

sizeof

(h->

gnu

.realsize) : 12;

2477  const char

* contind = h->

gnu

.contind;

2483  "Unexpected EOF in GNU sparse file map" 2484  " extended header"

);

2487

contind = block->

buffer

+ (24 * 21)

;

2507  string

(

"Unexpected EOF in "

) +

2517  data

.append(xbuf, nread);

2523  data

.resize(strlen(

data

.c_str()));

2535

:

"Long link name: \""

)

2549  if

(!

val

|| !

data

.size()) {

2551  "Skipping "

+

string

(

val

?

"empty"

:

"zero-sized"

)

2552

+

" extended header data"

);

2600

memcpy(block->

buffer

+

sizeof

(*block) - 4,

"NCBI"

, 4);

2616

+

"' too long in entry '"

+ name +

'\''

);

2624

+

"' too long in entry '"

+ name +

'\''

);

2641  "Cannot store file mode"

);

2652  "Cannot store user ID"

);

2662  "Cannot store group ID"

);

2673  "Cannot store file size"

);

2688  "Cannot store modification time"

);

2691  bool

device =

false

;

2706  "Cannot store major number"

);

2711  "Cannot store minor number"

);

2723  TAR_THROW

(

this

, eUnsupportedEntryType,

2724  "Do not know how to archive entry '"

+ name

2726

+

": Internal error"

);

2733  size_t len

= usr.size();

2735

memcpy(h->

uname

, usr.c_str(),

len

);

2740

memcpy(h->

gname

, grp.c_str(),

len

);

2751

strcpy(h->

magic

,

"ustar"

);

2753

memcpy(h->

version

,

"00"

, 2);

2756

memcpy(h->

magic

,

"ustar "

, 8);

2767  "Cannot store checksum"

);

2783  const char

* src = name.c_str();

2784  size_t len

= name.size();

2788

memcpy(dst, src,

len

);

2792  bool

packed =

false

;

2793  if

(!link &&

len

<=

sizeof

(h->

prefix

) + 1 +

sizeof

(h->

name

)) {

2796  if

(

i

>

sizeof

(h->

prefix

)) {

2799  while

(

i

> 0 && src[--

i

] !=

'/'

);

2800  if

(

i

&&

len

-

i

<=

sizeof

(h->

name

) + 1) {

2802

memcpy(h->

name

, src +

i

+ 1,

len

-

i

- 1);

2811

memcpy(dst, src,

size

);

2822

strcpy(h->

name

,

"././@LongLink"

);

2830

h->

typeflag

[0] = link ?

'K'

:

'L'

;

2833

memcpy(h->

magic

,

"ustar "

, 8);

2866  "In-stream update may result in gapped tar archive"

);

2893  "Archive backspace error in record reget"

);

2904 #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 1101 2909  "Archive backspace error in record reset"

);

2918  const

list<CTempString>& elems,

2923  if

(elems.empty()) {

2924  return mask

->Match(name, acase);

2926  if

(elems.size() == 1) {

2927  return mask

->Match(elems.front(), acase);

2931

temp = temp.empty() ?

string

(*e) :

string

(*e) +

'/'

+ temp;

2932  if

(

mask

->Match(temp, acase)) {

2964  "Interspersing zero block ignored"

);

2988

status !=

eEOF

?

true

:

false

);

2992  "Orphaned extended information ignored"

);

2996  "Unexpected EOF in archive"

);

3000

?

"Incomplete EOT in archive" 3001

:

"Missing EOT in archive"

);

3021  "Unused extended header replaced"

);

3033

|| !xinfo.

GetName

().empty()) {

3035  "Unused long name \""

+ xinfo.

GetName

()

3066  if

(!xinfo.

GetName

().empty()) {

3125  "Ignoring sparse data for non-plain file"

);

3143  "Empty entry name in archive"

);

3160

list<CTempString> elems;

3191  bool

noabs =

false

)

3200 #ifdef NCBI_OS_MSWIN 3201  if

(

isalpha

((

unsigned char

) path[0]) && path[1] ==

':'

) {

3204

}

else if

((path[0] ==

'/'

|| path[0] ==

'\\'

) &&

3205

(path[1] ==

'/'

|| path[1] ==

'\\'

)) {

3207

path.erase(0, path.find_first_of(

"/\\"

, 2));

3210  if

(path[0] ==

'/'

|| path[0] ==

'\\'

) {

3214

path.assign(1,

'.'

);

3228 #if defined(NCBI_OS_MSWIN) 3232 #elif defined(NCBI_OS_CYGWIN) 3243  if

(retval.size() > base_dir.size()) {

3244

retval.erase(0, base_dir.size()

);

3246

retval.assign(1,

'.'

);

3251 #ifdef NCBI_OS_MSWIN 3252  if

(

isalpha

((

unsigned char

) retval[0]) && retval[1] ==

':'

) {

3255

}

else if

(retval[0] ==

'/'

&& retval[1] ==

'/'

) {

3257

pos = retval.find(

'/'

, 2);

3264  while

(pos < retval.size() && retval[pos] ==

'/'

) {

3268

retval.erase(0, pos);

3270

pos = retval.size();

3271  while

(pos > 0 && retval[pos - 1] ==

'/'

) {

3274  if

(pos < retval.size()) {

3279

retval.insert((

SIZE_TYPE

) 0, 1,

'/'

);

3328  size_t len

= s.size();

3330  if

(s[--

len

] !=

'/'

)

3341  bool

extract = action ==

eExtract

;

3345

unique_ptr<CDirEntry> dst

3355

unique_ptr<CDirEntry> src;

3362

dst->DereferenceLink();

3375

} extracted = eNotExtracted;

3387

extracted = eConflict;

3398

|| memcmp(&dst_stat.

orig

.st_dev, &tst_stat.

orig

.st_dev,

sizeof

(dst_stat.

orig

.st_dev)) != 0

3399

|| memcmp(&dst_stat.

orig

.st_ino, &tst_stat.

orig

.st_ino,

sizeof

(dst_stat.

orig

.st_ino)) != 0) {

3403

extracted = eConflict;

3407

extracted = eMisCase;

3411

extracted = eExtracted;

3437  if

(dst_type != src->GetType()) {

3453  "Failed to backup '"

+ dst->GetPath() +

'\'' 3460  if

(!(extracted & eConflict)

3470  if

(

dst->Exists()) {

3476  if

(x_errno != EEXIST || !link) {

3478  "Cannot extract '"

+ dst->GetPath() +

'\'' 3483  "Cannot create "

+ whatlink +

" '"

+ dst->GetPath() +

"' -> '" 3491  "Cannot extract '"

+ dst->GetPath() +

'\'' 3499

umask(u & ~(S_IRUSR | S_IWUSR | S_IXUSR));

3515

}

else if

(pending && !pending->Restore()) {

3518  "Cannot restore '"

+ dst->GetPath()

3524

unique_ptr<CDirEntry> dst

3542 #ifndef NCBI_COMPILER_WORKSHOP 3550  if

(

m_Stream

.rdbuf()->PUBSEEKOFF(fskip, IOS_BASE::cur)

3558  "Cannot fast skip in file archive," 3559  " reverting to slow skip"

);

3570  "Archive skip failed (EOF)"

);

3586

unique_ptr<CDirEntry> src_ptr;

3587  bool

extracted =

true

;

3605  "Cannot create directory '"

+ dir.

GetPath

() +

'\'' 3615

src = src_ptr.get();

3627  if

(link(src->

GetPath

().c_str(), dst->

GetPath

().c_str()) == 0){

3633  int

x_errno = errno;

3634  if

(x_errno == ENOENT || x_errno == EEXIST || x_errno == ENOTDIR) {

3638  "Cannot hard link '"

+ dst->

GetPath

()

3639

+

"' -> '"

+ src->

GetPath

() +

'\'' 3641

+ (extracted ?

", trying to copy"

:

""

));

3651  "Cannot hard link '"

+ dst->

GetPath

()

3652

+

"' -> '"

+ src->

GetPath

() +

"' via copy" 3674  const CDir

* dir =

dynamic_cast<const CDir

*

>

(dst);

3678  "Cannot create directory '"

+ dst->

GetPath

() +

'\'' 3680

?

string

(

": Internal error"

)

3694  string error

=

"Cannot create symlink '"

+ dst->

GetPath

()

3697

?

string

(

": Internal error"

)

3699  if

(!symlink || x_errno != ENOTSUP

3717  int

x_errno = errno;

3720  int

x_errno = ENOTSUP;

3722  string

reason =

": Feature not supported by host OS"

;

3726

=

"Cannot create FIFO '"

+ dst->

GetPath

() +

'\''

+ reason;

3745  int

x_errno = errno;

3748  int

x_errno = ENOTSUP;

3750  string

reason =

": Feature not supported by host OS"

;

3755

?

"character"

:

"block"

)

3756

+

" device '"

+ dst->

GetPath

() +

'\''

+ reason;

3797  int

x_errno = errno;

3799  "Cannot create file '"

+ dst->

GetPath

() +

'\'' 3807  bool

okay = ofs.good();

3808  if

(okay)

while

(

size

) {

3814  "Unexpected EOF in archive"

);

3816  _ASSERT

(nread && ofs.good());

3819

okay = ofs.write(

data

, (streamsize) nread) ?

true

:

false

;

3831  if

(!okay || !ofs.good()) {

3832  int

x_errno = errno;

3834  "Cannot "

+

string

(okay ?

"close"

:

"write"

)

3845  for

(

n

= 0;

n

< nread; ++

n

) {

3850

line.append(

data

,

n

);

3852  if

(

data

[

n

] ==

'\n'

) {

3866  if

(

size

>= nread) {

3884 #ifdef NCBI_OS_MSWIN 3885 # define NCBI_FILE_WO "wb" 3887 # define NCBI_FILE_WO "w" 3900  "Unexpected EOF in archive"

);

3903  if

(

size

>= nread) {

3915  "Cannot expand sparse file '"

+ dst->

GetPath

()

3916

+

"': Region count is " 3917

+

string

(num.empty() ?

"missing"

:

"invalid"

)

3918

+

" (\""

+ num +

"\")"

);

3923

vector< pair<Uint8, Uint8> > bmap(

n

);

3927  for

(

int

k = 0; k < 2; ++k) {

3933  "Cannot expand sparse file '"

+ dst->

GetPath

()

3935

+

string

(k == 0 ?

"offset"

:

"region size"

)

3937

+

string

(num.empty() ?

"missing"

:

"invalid"

)

3938

+

" (\""

+ num +

"\")"

);

3942

bmap[

i

] = pair<Uint8, Uint8>(

val

[0],

val

[1]);

3953  int

x_errno = errno;

3955  "Cannot create file '"

+ dst->

GetPath

() +

'\'' 3967  Uint8

top = bmap[

i

].first + bmap[

i

].second;

3971  if

(!bmap[

i

].second) {

3976  if

(!(x_error = errno))

3989  "Cannot read archive data for sparse file '" 3990

+ dst->

GetPath

() +

"', region #" 3994

:

string

(

": End-of-data"

)));

4003  size_t

xread = nread;

4004  if

(xread > bmap[

i

].second -

done

) {

4005

xread = (size_t)(bmap[

i

].second -

done

);

4007  if

(::fwrite(

data

, 1, xread,

fp

.get()) != xread) {

4008  if

(!(x_error = errno)) {

4016

}

while

(

done

< bmap[

i

].second);

4023  bool

closed = ::fclose(

fp

.release()) == 0 ?

true

:

false

;

4024  if

(!x_error && !closed) {

4025  if

(!(x_error = errno))

4034 #ifdef NCBI_OS_MSWIN 4036  DWORD

rv = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |

4037

FORMAT_MESSAGE_FROM_SYSTEM |

4038

FORMAT_MESSAGE_MAX_WIDTH_MASK |

4039

FORMAT_MESSAGE_IGNORE_INSERTS,

4041

MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),

4048

::LocalFree((HLOCAL)

str

);

4050  if

(reason.empty()) {

4064  "Cannot write sparse file '"

+ dst->

GetPath

() +

'\''

+ reason);

4079

unique_ptr<CDirEntry> path_ptr;

4082

path = path_ptr.get();

4090  CTime

modification(

info

.GetModificationTime());

4091  CTime

last_access(

info

.GetLastAccessTime());

4092  CTime

creation(

info

.GetCreationTime());

4096  if

(!path->

SetTime

(&modification, &last_access, &creation)) {

4099  "Cannot restore date/time for '"

+ path->

GetPath

() +

'\'' 4113  if

(!

info

.GetUserName().empty() || !

info

.GetGroupName().empty()) {

4114  unsigned int

uid, gid;

4117

|| (!

info

.GetGroupName().empty()

4120

|| (uid ==

info

.GetUserId() && gid ==

info

.GetGroupId())) {

4146  if

(chmod(path->

GetPath

().c_str(),

mode

) != 0) {

4148  if

(

mode

& (S_ISUID | S_ISGID)) {

4149  mode

&= ~(S_ISUID | S_ISGID);

4161  s_TarToMode

(perm, &user, &group, &other, &special_bits);

4163  info

.GetMode(&user, &group, &other, &special_bits);

4165  failed

= !path->

SetMode

(user, group, other, special_bits);

4170  "Cannot "

+

string

(perm ?

"change"

:

"restore"

)

4171

+

" permissions for '"

+ path->

GetPath

() +

'\'' 4181 #ifdef NCBI_OS_MSWIN 4195

unique_ptr<CDir::TEntries> dir;

4199  unsigned int

uid = 0, gid = 0;

4200  bool

update =

true

;

4201  bool

added =

false

;

4212  if

(!entry.

Stat

(&

st

, follow_links)) {

4213  int

x_errno = errno;

4215  "Cannot get status of '"

+ path +

'\''

+

s_OSReason

(x_errno));

4223  "Empty entry name not allowed"

);

4226

list<CTempString> elems;

4229  if

(find(elems.begin(), elems.end(),

".."

) != elems.end()) {

4231  "Name '"

+ temp +

"' embeds parent directory (\"..\")"

);

4251  "Empty link name not allowed"

);

4256

follow_links, &uid, &gid);

4265 #ifdef NCBI_OS_MSWIN 4267  st

.orig.st_uid = (uid_t) uid;

4268  st

.orig.st_gid = (gid_t) gid;

4277  bool

found =

false

;

4285  const string

* entry_path_ptr;

4286  if

(e->GetPath().empty()) {

4288

entry_path_ptr = &entry_path;

4290

entry_path_ptr = &e->GetPath();

4292  if

(!temp.empty()) {

4294

temp != *entry_path_ptr) {

4297

}

else if

(path == *entry_path_ptr) {

4315

<= e->GetModificationCTime()) {

4353  "Cannot list directory '"

+ path +

'\''

+

s_OSReason

(x_errno);

4369

unique_ptr<TEntries> add =

x_Append

((*e)->GetPath(), toc);

4379  "Skipping non-archiveable " 4381

+

" '"

+ path +

'\''

);

4388  "Unable to archive '"

+ path +

'\''

);

4397  "Skipping unsupported source '"

+ path

4422

temp.resize(temp.size() - 1);

4426  "Empty entry name not allowed"

);

4429

list<CTempString> elems;

4432  if

(find(elems.begin(), elems.end(),

".."

) != elems.end()) {

4434  "Name '"

+ temp +

"' embeds parent directory (\"..\")"

);

4446  "Bad input file stream"

);

4464 # ifdef HAVE_GETUMASK 4482 #ifdef NCBI_OS_MSWIN 4487  unsigned int

uid = 0, gid = 0;

4519  if

(avail >

size

) {

4520

avail = (size_t)

size

;

4531

xread = is.gcount();

4540

ifstream* ifs =

dynamic_cast<

ifstream*

>

(&is);

4543

+

string

(ifs ?

"file"

:

"stream"

)

4544

+

" '"

+ name +

'\''

+

s_OSReason

(x_errno));

4547

avail = (size_t) xread;

4572  int

x_errno = errno;

4591  if

(idx < 0 ||

sizeof

(

m_Mask

)/

sizeof

(

m_Mask

[0]) <= (

size_t

) idx){

4595  if

(

m_Mask

[idx].owned) {

4612  size_t

blocking_factor,

4613  const string

& base_dir)

4615  const size_t

buffer_size =

SIZE_OF

(blocking_factor);

4626  size_t

namelen = name.size() + 1;

4679  if

(

count

> left) {

4680  count

= (size_t) left;

4691  if

(read >

count

) {

4700  buf

= (

char

*)

buf

+ read;

4715  int

x_errno = errno;

4719  "Read error while streaming"

+

s_OSReason

(x_errno));

4739  if

(!left &&

m_Eof

) {

4749

streamsize sb_avail =

m_Tar

->

m_Stream

.rdbuf()->in_avail();

4750  if

(sb_avail != -1) {

4751

avail = (size_t) sb_avail;

4754

*

count

= avail > left ? (size_t) left : avail;

4762

unique_ptr<CTar> tar(

new CTar

(is, 1

));

4771

unique_ptr<TEntries> temp = tar->x_ReadAndProcess(

eInternal

);

4772  _ASSERT

(temp && temp->size() < 2);

4773  if

(temp->size() < 1) {

4777  _ASSERT

(tar->m_Current == temp->front());

ncbi::TMaskedQueryRegions mask

static unsigned long GetVirtualMemoryPageSize(void)

Return virtual memory page size.

virtual ERW_Result PendingCount(size_t *count)

Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...

virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read=0)

Read as many as "count" bytes into a buffer pointed to by the "buf" argument.

CTarReader(CTar *tar, EOwnership own=eNoOwnership)

CTarTempDirEntry(const CDirEntry &entry)

virtual ~CTarTempDirEntry()

const CDirEntry & m_Entry

User-creatable info for streaming into a tar.

CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...

static string GetUserNameByUID(uid_t uid)

Look up user name by given numeric user ID.

static string GetGroupNameByGID(gid_t gid)

Look up group name by given numeric group ID.

static bool GetObjectOwner(const string &obj_name, SE_OBJECT_TYPE obj_type, string *owner, string *group, unsigned int *uid=0, unsigned int *gid=0)

Get owner name of specified system object.

A very basic data-read interface.

const string kUnknownError

std::ofstream out("events_result.xml")

main entry point for tests

static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)

static const char * str(char *buf, int n)

void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)

Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...

#define ITERATE(Type, Var, Cont)

ITERATE macro to sequence through container elements.

EFollowLinks

Whether to follow symbolic links (also known as shortcuts or aliases)

#define REVERSE_ITERATE(Type, Var, Cont)

ITERATE macro to reverse sequence through container elements.

@ eIgnoreLinks

Do not follow symbolic links.

@ eFollowLinks

Follow symbolic links.

@ eTakeOwnership

An object can take ownership of another.

@ eNoOwnership

No ownership is assumed.

bool x_PackCurrentName(STarHeader *header, bool link)

virtual ~CTar()

Destructor (finalize the archive if currently open).

const size_t m_BufferSize

Buffer(record) size for I/O operations.

const char * x_ReadArchive(size_t &n)

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

EStatus x_ParsePAXData(const string &data)

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)

unsigned int GetMajor(void) const

void SetBaseDir(const string &dirname)

Set base directory to use for files while extracting from/adding to the archive, and in the latter ca...

EOpenMode

Archive open mode and action.

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.

TTarMode GetMode(void) const

void x_WriteArchive(size_t n, const char *buffer=0)

EType GetType(void) const

void SetMask(CMask *mask, EOwnership own=eNoOwnership, EMaskType type=eExtractMask, NStr::ECase acase=NStr::eCase)

Set name mask.

string m_UserName

User name.

const string & GetGroupName(void) const

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.

bool x_ProcessEntry(EAction action, Uint8 size, const TEntries *done)

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

EStatus x_ReadEntryInfo(bool dump, bool pax)

char * m_BufPtr

Page-unaligned buffer pointer.

EType

Archive entry type.

unsigned int TTarMode

Bitwise OR of ETarModeBits.

SMask m_Mask[2]

Entry masks for operations.

time_t GetModificationTime(void) const

static Uint8 EstimateArchiveSize(const TFiles &files, size_t blocking_factor=20, const string &base_dir=kEmptyStr)

Return archive size as if all specified input entries were put in it.

unsigned int GetMinor(void) const

const CTarEntryInfo * GetNextEntryInfo(void)

Iterate over the archive forward and return first (or next) entry.

const string & GetName(void) const

bool x_ExtractSparseFile(Uint8 &size, const CDirEntry *dst, bool dump=false)

size_t m_ZeroBlockCount

Zero blocks seen in between entries.

void x_Skip(Uint8 blocks)

Uint8 m_Pos

Entry (not data!) position in archive.

void x_AppendStream(const string &name, CNcbiIstream &is)

bool x_AppendFile(const string &file)

string m_Name

Entry name.

EOpenMode m_OpenMode

What was it opened for.

void x_Backspace(EAction action)

IReader * GetNextEntryData(void)

Create and return an IReader, which can extract the current archive entry that has been previously re...

string x_ReadLine(Uint8 &size, const char *&data, size_t &nread)

void x_ExtractPlainFile(Uint8 &size, const CDirEntry *dst)

unsigned int GetUserId(void) const

unsigned int TFlags

Bitwise OR of EFlags.

string m_FileName

Tar archive file name (only if file)

void x_WriteEntryInfo(const string &name)

CTar(const string &filename, size_t blocking_factor=20)

Constructors.

string m_BaseDir

Base directory for relative paths.

unique_ptr< TEntries > Extract(void)

Extract the entire archive (into either current directory or a directory otherwise specified by SetBa...

bool x_Flush(bool nothrow=false)

CDirEntry::SStat m_Stat

Direntry-compatible info.

void x_RestoreAttrs(const CTarEntryInfo &info, TFlags what, const CDirEntry *path=0, TTarMode perm=0) const

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.

bool x_ExtractEntry(Uint8 &size, const CDirEntry *dst, const CDirEntry *src)

CNcbiFstream * m_FileStream

File stream of the archive (if file)

@ fTarOWrite

write by other

@ fTarUWrite

write by owner

@ fTarGRead

read by group

@ fTarORead

read by other

@ fTarURead

read 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.

@ eSymLink

Symbolic link.

@ eBlockDev

Block device.

@ eGNULongLink

GNU long link.

@ eGNULongName

GNU long name.

@ ePAXHeader

PAX extended header.

@ eVolHeader

Volume header.

@ eCharDev

Character device.

@ eExtractMask

exact for list or extract

@ eExcludeMask

pattern for all but test

@ fSkipUnsupported

Skip unsupported entries rather than make files out of them when extracting (the latter is the defaul...

@ fPreserveMode

Create extracted files with the original permissions.

@ fConflictOverwrite

Conflict overwrite allowed for entries.

@ fStandardHeaderOnly

Suppress NCBI signatures in entry headers.

@ fOverwrite

Allow to overwrite destinations with entries from the archive.

@ fPreserveOwner

Create extracted files with the original ownership.

@ fFollowLinks

Follow symbolic links (instead of storing/extracting them)

@ fTarfileNoTruncate

Do not trim tar file size after append/update.

@ fIgnoreZeroBlocks

Ignore blocks of zeros in archive.

@ fIgnoreUnreadable

Ignore unreadable files/dirs (still warn them, but don't stop)

@ fUpdate

Only update entries that are older than those already existing.

@ fPreserveTime

Preserve date/times for extracted files.

@ fLongNameSupplement

Always use OldGNU headers for long names (default:only when needed)

@ fEqualTypes

If destination entry exists, it must have the same type as source.

@ fIgnoreNameCase

Ignore case difference in names.

@ fBackup

Backup destinations if they exist (all entries including dirs)

@ fPreserveAll

Preserve all file attributes.

@ fKeepAbsolutePath

Preserve absolute path instead of stripping the leadind slash('/')

@ fStreamPipeThrough

Stream tar data through.

@ fSparseUnsupported

Do not extract PAX GNU/1.0 sparse files (treat 'em as unsupported)

#define ERR_POST_ONCE(message)

Error posting only once during program execution.

EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)

Set the threshold severity for posting the messages.

#define ERR_POST(message)

Error posting with file, line number information but without error codes.

EDiagSev

Severity level for the posted diagnostics.

@ eDiag_Info

Informational message.

void Critical(CExceptionArgs_Base &args)

void Error(CExceptionArgs_Base &args)

#define NCBI_THROW(exception_class, err_code, message)

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

static void SetFromErrno(void)

Set last error using current "errno" code.

void Trace(CExceptionArgs_Base &args)

void Warning(CExceptionArgs_Base &args)

ECode Code(void) const

Get error code.

static const CNcbiError & GetLast(void)

Get the error that was last set (in the current thread)

static void SetErrno(int errno_code)

Set last error using errno code.

void Info(CExceptionArgs_Base &args)

EType

Directory entry type.

static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)

Normalize a path.

static string GetTmpNameEx(const string &dir=kEmptyStr, const string &prefix=kEmptyStr, ETmpFileCreationMode mode=eTmpFileGetName)

Get temporary file name.

string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const

Get the directory component for this directory entry.

static bool IsAbsolutePath(const string &path)

Check if a "path" is absolute for the current OS.

long mtime_nsec

Nanoseconds for modification time.

unsigned int TSpecialModeBits

Bitwise OR of ESpecialModeBits.

unsigned int TMode

Bitwise OR of "EMode".

virtual bool Exists(void) const

Check the entry existence.

virtual bool SetMode(TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0, TSetModeFlags flags=eEntryOnly) const

Set permission mode(s) of a directory entry.

bool CreatePath(TCreateFlags flags=fCreate_Default) const

Create the directory path recursively possibly more than one at a time.

bool Rename(const string &new_path, TRenameFlags flags=fRF_Default)

Rename entry.

virtual bool Remove(TRemoveFlags flags=eRecursive) const

Remove a directory entry.

string LookupLink(void) const

Get an entry name that a link points to.

static CDirEntry * CreateObject(EType type, const string &path=kEmptyStr)

Construct a directory entry object of a specified type.

static string AddTrailingPathSeparator(const string &path)

Add trailing path separator, if needed.

bool SetTime(const CTime *modification=0, const CTime *last_access=0, const CTime *creation=0) const

Set time stamp(s) of a directory entry.

CDirEntry(void)

Default constructor.

bool GetOwner(string *owner, string *group=0, EFollowLinks follow=eFollowLinks, unsigned int *uid=0, unsigned int *gid=0) const

Get an entry owner.

TNcbiSys_stat orig

Original stat structure.

bool Create(const string &path) const

Create symbolic link.

static string ConcatPath(const string &first, const string &second)

Concatenate two parts of the path for the current OS.

long atime_nsec

Nanoseconds for last access time.

bool Stat(struct SStat *buffer, EFollowLinks follow_links=eIgnoreLinks) const

Get status information on a dir entry.

long ctime_nsec

Nanoseconds for creation time.

string GetName(void) const

Get the base entry name with extension (if any).

bool SetOwner(const string &owner, const string &group=kEmptyStr, EFollowLinks follow=eFollowLinks, unsigned int *uid=0, unsigned int *gid=0) const

Set an entry owner and/or group.

EType GetType(EFollowLinks follow=eIgnoreLinks) const

Get a type of a directory entry.

const string & GetPath(void) const

Get entry path.

virtual bool Copy(const string &new_path, TCopyFlags flags=fCF_Default, size_t buf_size=0) const

Copy the entry to a location specified by "new_path".

@ eSymLink

Symbolic link (UNIX only)

@ eSocket

Socket (UNIX only)

@ eBlockSpecial

Block special (UNIX only)

@ eCharSpecial

Character special.

@ fCF_Overwrite

The following flags define what to do when the destination entry already exists:

@ eIfAbsent_Throw

Throw an exception.

@ fExecute

Execute / List(directory) permission.

@ fWrite

Write permission.

@ eBackup_Rename

Rename entry.

uint64_t Uint8

8-byte (64-bit) unsigned integer

static TProcessHandle GetHandle(void)

Get process handle for the current process (esp.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

ERW_Result

Result codes for I/O operations.

IO_PREFIX::ofstream CNcbiOfstream

Portable alias for ofstream.

IO_PREFIX::ostream CNcbiOstream

Portable alias for ostream.

IO_PREFIX::istream CNcbiIstream

Portable alias for istream.

IO_PREFIX::ios CNcbiIos

Portable alias for ios.

IO_PREFIX::ifstream CNcbiIfstream

Portable alias for ifstream.

IO_PREFIX::fstream CNcbiFstream

Portable alias for fstream.

@ eRW_Eof

End of data, should be considered permanent.

@ eRW_Error

Unrecoverable error, no retry possible.

@ eRW_Success

Everything is okay, I/O completed.

NCBI_NS_STD::string::size_type SIZE_TYPE

static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)

Get a printable version of the specified string.

static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)

Case-insensitive compare of a substring with another string.

static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)

Split a string using specified delimiters.

static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)

Check if a string ends with a specified suffix value.

static int strncasecmp(const char *s1, const char *s2, size_t n)

Case-insensitive comparison of two zero-terminated strings, narrowed to the specified number of chara...

static string IntToString(int value, TNumToStringFlags flags=0, int base=10)

Convert int to string.

bool empty(void) const

Return true if the represented string is empty (i.e., the length is zero)

static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)

Convert UInt to string.

static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)

Check if a string starts with a specified prefix value.

static Uint8 StringToUInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)

Convert string to Uint8.

ECase

Which type of string comparison.

static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)

Convert numeric value to string.

static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)

Replace occurrences of a substring within a string.

static int CompareCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)

Case-sensitive compare of a substring with another string.

@ fNewLine_Passthru

Break the line at every "\n" occurrence.

@ fNewLine_Quote

Display "\n" instead of actual linebreak.

@ fConvErr_NoErrMessage

Set errno, but do not set CNcbiError message on error.

@ fConvErr_NoThrow

Do not throw an exception on error.

@ fSplit_MergeDelimiters

Merge adjacent delimiters.

@ fWithCommas

Use commas as thousands separator.

@ eNocase

Case insensitive compare.

@ eCase

Case sensitive compare.

CTime & ToLocalTime(void)

Convert the time into local time.

string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const

Transform time to string.

time_t GetTimeT(void) const

Get time in time_t format.

void SetNanoSecond(long nanosecond)

Set nanoseconds.

static void GetCurrentTimeT(time_t *sec, long *nanosec=0)

Get current UTC time in time_t format (with nanoseconds).

enum ENcbiOwnership EOwnership

Ownership relations between objects.

#define INVALID_HANDLE_VALUE

A value for an invalid file handle.

#define HANDLE

An abstraction for a file handle.

unsigned int

A callback function used to compare two keys in a database.

Definition of all error codes used in util (xutil.lib).

for(len=0;yy_str[len];++len)

if(yy_accept[yy_current_state])

static void text(MDB_val *v)

const string version

version string

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

const struct ncbi::grid::netcache::search::fields::KEY key

int strcmp(const char *str1, const char *str2)

std::istream & in(std::istream &in_, double &x_)

static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)

static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

Alternate stat structure for use instead of the standard struct stat.

static void Delete(FILE *fp)

Functor template for deleting object.

static DP_BlockInfo * blocks

static bool s_IsOctal(char c)

static string s_UserGroupAsString(const CTarEntryInfo &info)

static string s_ToFilesystemPath(const string &base_dir, const string &name, bool noabs=false)

static bool s_NumToBase256(Uint8 val, char *ptr, size_t len)

static bool s_MatchExcludeMask(const CTempString &name, const list< CTempString > &elems, const CMask *mask, NStr::ECase acase)

#define TAR_PRINTABLE_EX(field, text, size)

static CTempString x_DropTrailingSlashes(const string &s)

static bool s_Base256ToNum(Uint8 &val, const char *ptr, size_t len)

static size_t s_Length(const char *ptr, size_t maxsize)

static void sx_Signature(TTarBlock *block)

static int s_TruncateFile(const string &filename, Uint8 filesize)

static void s_Dump(const string &file, Uint8 pos, size_t recsize, const string &entryname, const STarHeader *h, ETar_Format fmt, Uint8 datasize)

static int s_EncodeUint8(Uint8 val, char *ptr, size_t len)

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

static bool s_ParsePAXNumeric(Uint8 *valp, const char *str, size_t len, string *fraq, EPAXBit assign)

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

#define TAR_THROW(who, errcode, message)

static string s_ToArchiveName(const string &base_dir, const string &path)

static bool s_TarChecksum(TTarBlock *block, bool isgnu)

CNcbiOstream & operator<<(CNcbiOstream &os, const CTarEntryInfo &info)

#define TAR_THROW_EX(who, errcode, message, hdr, fmt)

#define TAR_PRINTABLE(field, text)

static bool s_NumToOctal(Uint8 val, char *ptr, size_t len)

static string s_DumpSparseMap(const STarHeader *h, const char *sparse, const char *contind, bool excpt=false)

static string s_ModeAsString(TTarMode mode)

void s_SetStateSafe(CNcbiIos &ios, IOS_BASE::iostate state)

static char s_TypeAsChar(CTarEntryInfo::EType type)

static void s_DumpZero(const string &file, Uint8 pos, size_t recsize, size_t zeroblock_count, bool eot=false)

static string s_MajorMinor(unsigned int n)

static void s_DumpSparse(const string &file, Uint8 pos, size_t recsize, const string &entryname, const STarHeader *h, const char *contind, Uint8 datasize)

static TTarMode s_ModeToTar(mode_t mode)

static string s_SizeOrMajorMinor(const CTarEntryInfo &info)

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

static string s_BaseDir(const string &dirname)

static void s_TarToMode(TTarMode perm, CDirEntry::TMode *usr_mode, CDirEntry::TMode *grp_mode, CDirEntry::TMode *oth_mode, CDirEntry::TSpecialModeBits *special_bits)

static int s_DecodeUint8(Uint8 &val, const char *ptr, size_t len)

static bool s_OctalToNum(Uint8 &val, const char *ptr, size_t len)

static bool memcchr(const char *s, char c, size_t len)

#define BLOCK_SIZE

Tar block size (512 bytes)

static string s_OffsetAsString(size_t offset)

static bool s_AllLowerCase(const char *str, size_t len)

ETar_Format

Recognized TAR formats.

static string s_OSReason(int x_errno)

#define ALIGN_SIZE(size)

Round up to the nearest multiple of BLOCK_SIZE:

#define TAR_POST(subcode, severity, message)

static long s_FraqToNanosec(const string &fraq)

static Uint8 ipow10(unsigned int n)

static wxAcceleratorEntry entries[3]


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