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

NCBI C++ ToolKit: src/corelib/ncbifile.cpp Source File

42 #if defined(NCBI_OS_MSWIN) 47 # include <sys/utime.h> 49 #elif defined(NCBI_OS_UNIX) 56 # include <sys/mman.h> 57 # include <sys/time.h> 58 # ifdef HAVE_SYS_STATVFS_H 59 # include <sys/statvfs.h> 61 # include <sys/param.h> 62 # ifdef HAVE_SYS_MOUNT_H 63 # include <sys/mount.h> 65 # ifdef HAVE_SYS_VFS_H 68 # if !defined(MAP_FAILED) 69 # define MAP_FAILED ((void *)(-1L)) 71 # include <sys/ioctl.h> 74 # error "File API defined for MS Windows and UNIX platforms only" 80 #if defined(NCBI_OS_UNIX) && !defined(NCBI_OS_CYGWIN) 81 # define SUPPORT_PANFS 82 # include <sys/types.h> 83 # include <sys/wait.h> 87 #define NCBI_USE_ERRCODE_X Corelib_File 96 #undef DIR_SEPARATOR_ALT 100 #undef ALL_OS_SEPARATORS 102 #define DIR_PARENT ".." 103 #define DIR_CURRENT "." 104 #define ALL_OS_SEPARATORS ":/\\" 106 #if defined(NCBI_OS_MSWIN) 107 # define DIR_SEPARATOR '\\' 108 # define DIR_SEPARATOR_ALT '/' 109 # define DISK_SEPARATOR ':' 110 # define DIR_SEPARATORS "/\\" 111 # define ALL_SEPARATORS ":/\\" 112 #elif defined(NCBI_OS_UNIX) 113 # define DIR_SEPARATOR '/' 114 # define DIR_SEPARATORS "/" 115 # define ALL_SEPARATORS "/" 119 #define F_ISSET(flags, mask) ((flags & (mask)) == (mask)) 161 #define DEFAULT_HONOR_UMASK_VALUE false 176 #define DEFAULT_LOGGING_VALUE false 193 #define LOG_ERROR(subcode, log_message) \ 195  if (NCBI_PARAM_TYPE(NCBI, FileAPILogging)::GetDefault()) { \ 196  ERR_POST_X(subcode, log_message); \ 201 #define LOG_ERROR_NCBI(subcode, log_message, ncbierr) \ 203  CNcbiError::Set(ncbierr, log_message); \ 204  if (NCBI_PARAM_TYPE(NCBI, FileAPILogging)::GetDefault()) { \ 205  ERR_POST_X(subcode, log_message); \ 211 #define LOG_ERROR_WIN(subcode, log_message) \ 213  CNcbiError::SetFromWindowsError(log_message); \ 214  if (NCBI_PARAM_TYPE(NCBI, FileAPILogging)::GetDefault()) { \ 215  ERR_POST_X(subcode, log_message); \ 221 #define LOG_ERROR_ERRNO(subcode, log_message) \ 223  int saved_error = errno; \ 224  CNcbiError::SetErrno(saved_error, log_message); \ 225  if (NCBI_PARAM_TYPE(NCBI, FileAPILogging)::GetDefault()) { \ 226  ERR_POST_X(subcode, log_message << ": "

<< _T_STDSTRING(NcbiSys_strerror(saved_error))); \

228

errno = saved_error; \

232 #define _no_warning(expr) while ( expr ) break 235 #define WIN_LAST_ERROR_STR CLastErrorAdapt::GetErrCodeString(::GetLastError()) 238 #if defined(NCBI_OS_DARWIN) 239 # define TV_USEC(x) (int)(x) 241 # define TV_USEC(x) x 262

: m_Path(other.m_Path)

282

ptr =

new CFile

(path);

285

ptr =

new CDir

(path);

301  size_t len

= path.length();

307 # if defined(DISK_SEPARATOR) 347  if

(

this

!= &other) {

359  string

* base,

string

* ext)

363  string

filename = (pos ==

NPOS

) ? path : path.substr(pos+1);

370

pos = filename.rfind(

'.'

);

372

*base = (pos ==

NPOS

) ? filename : filename.substr(0, pos);

381  string

* disk,

string

* dir,

382  string

* base,

string

* ext)

384  size_t

start_pos = 0;

388  if

(

isalpha

((

unsigned char

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

':'

) {

389

*disk = path.substr(0, 2);

397  string

filename = (pos ==

NPOS

) ? path : path.substr(pos+1);

400

*dir = (pos ==

NPOS

) ?

kEmptyStr

: path.substr(start_pos, pos - start_pos + 1);

403

pos = filename.rfind(

'.'

);

405

*base = (pos ==

NPOS

) ? filename : filename.substr(0, pos);

419  if

( dir.length() ) {

424  if

( ext.length() && ext.at(0) !=

'.'

) {

441 #if defined(DISK_SEPARATOR) 446 #if defined(DIR_SEPARATOR_ALT) 457  size_t len

= path.length();

468  if

(pos + 1 < path.length()) {

469  return

path.substr(0, pos + 1);

489  if

((

isalpha

((

unsigned char

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

':'

) &&

490

(path[2] ==

'/'

|| path[2] ==

'\\'

)) {

500  if

((path[0] ==

'\\'

|| path[0] ==

'/'

) &&

501

(path[1] ==

'\\'

|| path[1] ==

'/'

)) {

513 #if defined(NCBI_OS_MSWIN) 517 #elif defined(NCBI_OS_UNIX) 518  if

( path[0] ==

'/'

) {

536  if

(path[0] ==

'/'

) {

552  while

(!entry.

Exists

()) {

553  string

dir = entry.

GetDir

();

556  "Failed to find existing containing directory for: "

+ entry.

GetPath

());

567 static void s_StripDir

(

const string

& dir, vector<string> * dir_parts)

576  size_t

last_ind = dir.length() - 1;

577  size_t

part_start = 0;

579

sep_pos = dir.find(sep, sep_pos);

580  if

(sep_pos ==

NPOS

) {

581

dir_parts->push_back(

string

(dir, part_start, dir.length() - part_start));

586

dir_parts->push_back(

string

(1, sep));

588

dir_parts->push_back(

string

(dir, part_start, sep_pos - part_start));

591

part_start = sep_pos;

592  if

(sep_pos >= last_ind) {

600  const string

& path_to )

615

vector<string> dir_from_parts;

617  if

( dir_from_parts.empty() ) {

622  string

dir_to, base_to, ext_to;

623  SplitPath

(path_to, &dir_to, &base_to, &ext_to);

624

vector<string> dir_to_parts;

626  if

( dir_to_parts.empty() ) {

632 # define DIR_PARTS_CMP_MODE NStr::eNocase 634 # define DIR_PARTS_CMP_MODE NStr::eCase 639

dir_to_parts.front(),

644  size_t

min_parts =

min

(dir_from_parts.size(), dir_to_parts.size());

645  size_t

common_length = min_parts;

646  for

(

size_t i

= 0;

i

< min_parts;

i

++) {

652  for

(

size_t i

= common_length;

i

< dir_from_parts.size();

i

++) {

656  for

(

size_t i

= common_length;

i

< dir_to_parts.size();

i

++) {

657

path += dir_to_parts[

i

];

661  return

path + base_to + ext_to;

672 #if defined(NCBI_OS_MSWIN) 675  "Path must not contain disk separator: "

+ path);

678  if

(!path.empty() && (path[0] ==

'/'

|| path[0] ==

'\\'

)) {

682  "Cannot use network path: "

+ path);

687  "Path can be used as relative to current drive only: "

+ path);

719 #if defined(NCBI_OS_MSWIN) 722  "Path must not contain disk separator: "

+ path);

725  if

(!path.empty() && (path[0] ==

'/'

|| path[0] ==

'\\'

)) {

729  "Cannot use network path: "

+ path);

733  "Path can be used as relative to current drive only: "

+ path);

739  "2nd parameter must represent absolute path: "

+ rtw);

754 #if defined(DIR_PARENT) 759 #if defined(DIR_CURRENT) 765  for

(

size_t i

= 0;

i

< xpath.length();

i

++) {

767  if

( c ==

'\\'

|| c ==

'/'

) {

782  if

( !path.empty() && part.length() > 0 && part[0] ==

DIR_SEPARATOR

) {

798  size_t

pos = path.

size

();

809  if

( part.

size

() > 0 &&

822  if

( path.empty() ) {

827

std::list<string>

head

;

828

std::list<string> tail;

833 # ifdef DISK_SEPARATOR 843  if

( current.empty() ) {

852  while

( !current.empty() || !tail.empty() ) {

853

std::list<string> pretail;

854  if

( !current.empty() ) {

857  if

(pretail.front().empty()

866  static const char

*

const

kUNC[] = {

""

,

""

,

"?"

,

"UNC"

};

867

std::list<string>::iterator it = pretail.begin();

868  unsigned int

matched = 0;

869  while

(matched < 4 && it != pretail.end()

874

pretail.erase(pretail.begin(), it);

887

tail.splice(tail.begin(), pretail);

895  if

( !

head

.empty() ) {

898  if

(!

next

.empty()) {

901 #ifdef DISK_SEPARATOR 908

}

else if

(

next

.empty()) {

911 #ifdef DISK_SEPARATOR 915  if

(

last

.empty()) {

918 #ifdef DISK_SEPARATOR 920  last

.erase(pos + 1);

930  if

( follow_links ) {

933  int

length = (

int

)readlink(s.c_str(),

buf

,

sizeof

(

buf

));

935

current.assign(

buf

, length);

936  if

(++link_depth >= 1024) {

938  "Reached symlink depth limit "

<<

939

link_depth <<

" when resolving "

<< path);

952  if

( (

head

.size() == 0) ||

957  if

(

head

.size() == 1 &&

head

.front().empty()) {

961 #ifdef DISK_SEPARATOR 983  ModeFromModeT

(

st

.st_mode, user_mode, group_mode, other_mode, special);

990 #define UPDATE_PERMS(mode, perms) \ 992  _ASSERT( !F_ISSET(perms, fModeNoChange | fModeAdd) ); \ 993  _ASSERT( !F_ISSET(perms, fModeNoChange | fModeRemove) ); \ 994  _ASSERT( !F_ISSET(perms, fModeAdd | fModeRemove) ); \ 996  if ( perms & fModeNoChange ) { \ 999  if ( perms & fModeAdd ) { \ 1002  if ( perms & fModeRemove ) { \ 1009  mode &= ~(fDefault | static_cast<TMode>( \ 1010  fModeAdd | fModeRemove | fModeNoChange)); \ 1044  if

(special_mode == 0) {

1056  if

( (user_mode & relative_mask) ||

1057

(group_mode & relative_mask) ||

1058

(other_mode & relative_mask) ||

1059

(special_mode & relative_mask) ) {

1085  LOG_ERROR_ERRNO

(7,

"CDirEntry::SetModeEntry(): chmod() failed: set mode "

+

1101  if

( entry_type ==

eDir

) {

1122  if

( special == 0 ) {

1145  if

( special == 0 ) {

1199

(special &

fSetUID

? S_ISUID : 0) |

1202

(special &

fSetGID

? S_ISGID : 0) |

1205

(special &

fSticky

? S_ISVTX : 0) |

1208

#

if

defined(S_IRUSR)

1209

(user_mode &

fRead

? S_IRUSR : 0) |

1210

#elif defined(S_IREAD)

1211

(user_mode &

fRead

? S_IREAD : 0) |

1213

#

if

defined(S_IWUSR)

1214

(user_mode &

fWrite

? S_IWUSR : 0) |

1215

#elif defined(S_IWRITE)

1216

(user_mode &

fWrite

? S_IWRITE : 0) |

1218

#

if

defined(S_IXUSR)

1219

(user_mode &

fExecute

? S_IXUSR : 0) |

1220

#elif defined(S_IEXEC)

1221

(user_mode &

fExecute

? S_IEXEC : 0) |

1224

(group_mode &

fRead

? S_IRGRP : 0) |

1227

(group_mode &

fWrite

? S_IWGRP : 0) |

1230

(group_mode &

fExecute

? S_IXGRP : 0) |

1233

(other_mode &

fRead

? S_IROTH : 0) |

1236

(other_mode &

fWrite

? S_IWOTH : 0) |

1239

(other_mode &

fExecute

? S_IXOTH : 0) |

1253 #if defined(S_IRUSR) 1255

#elif defined(S_IREAD)

1258

#

if

defined(S_IWUSR)

1260

#elif defined(S_IWRITE)

1263

#

if

defined(S_IXUSR)

1265

#elif defined(S_IEXEC)

1271 #ifdef NCBI_OS_MSWIN 1272  if

(group_mode) *group_mode = 0;

1273  if

(other_mode) *other_mode = 0;

1274  if

(special) *special = 0;

1339  if

( special_bit ) {

1366  out

[0] = char(special +

'0'

);

1371  out

[

i

++] = char(user_mode +

'0'

);

1372  out

[

i

++] = char(group_mode +

'0'

);

1373  out

[

i

++] = char(other_mode +

'0'

);

1404  if

(

mode

.empty() ) {

1411  if

((oct > 07777) || (!oct && errno != 0)) {

1416

*other_mode =

TMode

(oct & 7);

1420

*group_mode =

TMode

(oct & 7);

1424

*user_mode =

TMode

(oct & 7);

1443  if

(

mode

.find(

'='

) ==

NPOS

&&

mode

.length() == 9) {

1444  for

(

int i

= 0;

i

< 3;

i

++) {

1446  bool

is_special =

false

;

1448  switch

(

mode

[

i

*3]) {

1458  switch

(

mode

[

i

*3 + 1]) {

1468  switch

(

mode

[

i

*3 + 2]) {

1490  if

(is_special && special)

1496  if

(is_special && special)

1502  if

(is_special && special)

1510

std::list<string> parts;

1512  if

( parts.empty() ) {

1516  bool

have_user =

false

;

1517  bool

have_group =

false

;

1518  bool

have_other =

false

;

1520  ITERATE

(std::list<string>, it, parts) {

1521  string

accessor, perm;

1527  bool

is_special =

false

;

1530  switch

(

char

(*s)) {

1554  ITERATE

(

string

, s, accessor) {

1555  switch

(

char

(*s)) {

1563  if

(is_special && special)

1574  if

(is_special && special)

1585  if

(is_special && special)

1590  if

(is_special || have_user || have_group || have_other) {

1620 #ifdef HAVE_GETUMASK 1634

(group_mode ==

fDefault

) ? 0 : group_mode,

1635

(other_mode ==

fDefault

) ? 0 : other_mode,

1641 #if defined(NCBI_OS_UNIX) && !defined(HAVE_EUIDACCESS) && !defined(EFF_ONLY_OK) 1645  const struct

stat&

st

= *p;

1646

uid_t uid = geteuid();

1649  if

(uid ==

st

.st_uid) {

1650  return

(!(

mode

& R_OK) || (

st

.st_mode & S_IRUSR)) &&

1651

(!(

mode

& W_OK) || (

st

.st_mode & S_IWUSR)) &&

1652

(!(

mode

& X_OK) || (

st

.st_mode & S_IXUSR));

1657

gid_t gids[NGROUPS_MAX + 1];

1658

gids[0] = getegid();

1659

ngroups = getgroups((

int

)(

sizeof

(gids)/

sizeof

(gids[0])) - 1, gids + 1);

1665  for

(

int i

= 1;

i

< ngroups;

i

++) {

1666  if

(gids[

i

] == uid) {

1667  if

(

i

< --ngroups) {

1668  memmove

(&gids[

i

], &gids[

i

+ 1],

sizeof

(gids[0])*(ngroups-

i

));

1674  for

(

int i

= 0;

i

< ngroups;

i

++) {

1675  if

(gids[

i

] ==

st

.st_gid) {

1676  return

(!(

mode

& R_OK) || (

st

.st_mode & S_IRGRP)) &&

1677

(!(

mode

& W_OK) || (

st

.st_mode & S_IWGRP)) &&

1678

(!(

mode

& X_OK) || (

st

.st_mode & S_IXGRP));

1682  if

( (!(

mode

& R_OK) || (

st

.st_mode & S_IROTH)) &&

1683

(!(

mode

& W_OK) || (

st

.st_mode & S_IWOTH)) &&

1684

(!(

mode

& X_OK) || (

st

.st_mode & S_IXOTH)) ) {

1705  if

(stat(path, &

st

) != 0) {

1722 #if defined(NCBI_OS_MSWIN) 1725

ACCESS_MASK

mask

= 0;

1730  return

(access_mode & perm) > 0;

1734 #elif defined(NCBI_OS_UNIX) 1735  const char

* path =

GetPath

().c_str();

1738  if

( access_mode &

fRead

)

mode

|= R_OK;

1743 # if defined(HAVE_EUIDACCESS) 1744  if

(euidaccess(path,

mode

) != 0) {

1750 # elif defined(EFF_ONLY_OK) 1752  mode

|= EFF_ONLY_OK;

1753  if

(access(path,

mode

) != 0) {

1763  if

(getuid() == geteuid() && getgid() == getegid()) {

1764  if

(access(path,

mode

) != 0) {

1781 #ifdef NCBI_OS_MSWIN 1788  if

( !filetime.dwLowDateTime && !filetime.dwHighDateTime ) {

1796  if

( !::FileTimeToLocalFileTime(&filetime, &

local

) ) {

1801  if

( !::FileTimeToSystemTime(&

local

, &system) ) {

1807  CTime

newtime(system.wYear,

1815  t

.GetTimeZonePrecision());

1832

res = Int32x32To64(

t

, 10000000) + 116444736000000000 + nanosec/100;

1833

filetime.dwLowDateTime = (

DWORD

)res;

1834

filetime.dwHighDateTime = (

DWORD

)(res >> 32);

1841  CTime

* last_access,

1842  CTime

* creation)

const 1844 #ifdef NCBI_OS_MSWIN 1846

WIN32_FIND_DATA

buf

;

1854

::FindClose(handle);

1857  if

( modification &&

1859  LOG_ERROR

(9,

"CDirEntry::GetTime(): Cannot get modification time for: "

+

GetPath

());

1864  LOG_ERROR

(9,

"CDirEntry::GetTime(): Cannot get access time for: "

+

GetPath

());

1869  LOG_ERROR

(9,

"CDirEntry::GetTime(): Cannot get creation time for: "

+

GetPath

());

1881  if

( modification ) {

1882

modification->

SetTimeT

(

st

.orig.st_mtime);

1883  if

(

st

.mtime_nsec )

1886  if

( last_access ) {

1888  if

(

st

.atime_nsec )

1893  if

(

st

.ctime_nsec )

1902  const CTime

* last_access,

1903  const CTime

* creation)

const 1905 #ifdef NCBI_OS_MSWIN 1906  if

( !modification && !last_access && !creation ) {

1910

FILETIME x_modification, x_last_access, x_creation;

1911

LPFILETIME p_modification =

NULL

, p_last_access =

NULL

, p_creation =

NULL

;

1914  if

( modification ) {

1916

p_modification = &x_modification;

1918  if

( last_access ) {

1920

p_last_access = &x_last_access;

1924

p_creation = &x_creation;

1929

FILE_SHARE_READ,

NULL

, OPEN_EXISTING,

1930

FILE_FLAG_BACKUP_SEMANTICS

,

NULL

);

1935  if

( !::SetFileTime(h, p_creation, p_last_access, p_modification) ) {

1949  if

( !modification && !last_access

) {

1955  CTime

x_modification, x_last_access;

1957  if

( !modification || !last_access ) {

1958  if

( !

GetTime

(modification ?

NULL

: &x_modification,

1959

last_access ?

NULL

: &x_last_access,

1963  if

(!modification) {

1964

modification = &x_modification;

1966

last_access = &x_last_access;

1971  struct

timeval tvp[2];

1972

tvp[0].tv_sec = last_access->

GetTimeT

();

1974

tvp[1].tv_sec = modification->

GetTimeT

();

1977 # ifdef HAVE_LUTIMES 1978  bool

ut_res = lutimes(

GetPath

().c_str(), tvp) == 0;

1980  bool

ut_res = utimes(

GetPath

().c_str(), tvp) == 0;

1993

time_t x_modification, x_last_access;

1995  if

((!modification || !last_access)

1996

&& !

GetTimeT

(&x_modification, &x_last_access,

NULL

)) {

1997  LOG_ERROR

(12,

"CDirEntry::SetTime(): Cannot get current time for: "

+

GetPath

());

2002  struct

utimbuf times;

2003

times.modtime = modification ? modification->

GetTimeT

() : x_modification;

2004

times.actime = last_access ? last_access->

GetTimeT

() : x_last_access;

2005  if

( utime(

GetPath

().c_str(), &times) != 0 ) {

2018

time_t* last_access,

2019

time_t* creation)

const 2026  if

( modification ) {

2027

*modification =

st

.st_mtime;

2029  if

( last_access ) {

2030

*last_access =

st

.st_atime;

2033

*creation =

st

.st_ctime;

2040  const

time_t* last_access,

2041  const

time_t* creation)

const 2043 #ifdef NCBI_OS_MSWIN 2044  if

( !modification && !last_access && !creation ) {

2048

FILETIME x_modification, x_last_access, x_creation;

2049

LPFILETIME p_modification =

NULL

, p_last_access =

NULL

, p_creation =

NULL

;

2052  if

( modification ) {

2054

p_modification = &x_modification;

2056  if

( last_access ) {

2058

p_last_access = &x_last_access;

2062

p_creation = &x_creation;

2067

FILE_SHARE_READ,

NULL

, OPEN_EXISTING,

2068

FILE_FLAG_BACKUP_SEMANTICS

,

NULL

);

2073  if

( !::SetFileTime(h, p_creation, p_last_access, p_modification) ) {

2087  if

( !modification && !last_access

)

2090

time_t x_modification, x_last_access;

2091  if

((!modification || !last_access)

2092

&& !

GetTimeT

(&x_modification, &x_last_access,

NULL

) ) {

2093  LOG_ERROR

(15,

"CDirEntry::SetTimeT(): Cannot get current time for: "

+

GetPath

());

2098  struct

utimbuf times;

2099

times.modtime = modification ? *modification : x_modification;

2100

times.actime = last_access ? *last_access : x_last_access;

2101  if

( utime(

GetPath

().c_str(), &times) != 0 ) {

2119 #ifdef NCBI_OS_MSWIN 2144 # if !defined(__GLIBC_PREREQ) 2145 # define __GLIBC_PREREQ(x, y) 0 2148 # if defined(NCBI_OS_LINUX) && __GLIBC_PREREQ(2,3) 2149 # if defined(__USE_MISC) 2160 # if defined(NCBI_OS_SOLARIS) 2161 # if !defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE) || \ 2162  defined(__EXTENSIONS__) 2173 # if defined(NCBI_OS_BSD) || defined(NCBI_OS_DARWIN) 2174 # if defined(_POSIX_SOURCE) 2179  buffer

->atime_nsec =

buffer

->orig.st_atimespec.tv_nsec;

2180  buffer

->mtime_nsec =

buffer

->orig.st_mtimespec.tv_nsec;

2181  buffer

->ctime_nsec =

buffer

->orig.st_ctimespec.tv_nsec;

2185 # if defined(NCBI_OS_IRIX) 2186 # if defined(tv_sec) 2208 #if defined(NCBI_OS_MSWIN) 2215  if

(attr == INVALID_FILE_ATTRIBUTES) {

2221  if

(

F_ISSET

(attr, FILE_ATTRIBUTE_DIRECTORY) ) {

2229

errcode = stat(

GetPath

().c_str(), &

st

);

2231

errcode = lstat(

GetPath

().c_str(), &

st

);

2245 #define NCBI_IS_TYPE(mode, mask) (((mode) & S_IFMT) == (mask)) 2249  unsigned int mode

= (

unsigned int

)

st

.st_mode;

2259  if

(S_ISCHR(

mode

))

2265 #ifdef NCBI_OS_MSWIN 2271  if

(S_ISFIFO(

mode

))

2278  if

(S_ISLNK(

mode

))

2285  if

(S_ISSOCK(

mode

))

2292  if

(S_ISBLK(

mode

))

2301  if

(S_ISDOOR(

mode

))

2312  if

(S_ISREG(

mode

))

2322 #if defined(NCBI_OS_MSWIN) 2328

GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,

NULL

,

2330

FILE_FLAG_BACKUP_SEMANTICS

,

NULL

);

2345 #ifdef NCBI_OS_MSWIN 2353

name.assign(

buf

, length);

2362 #ifdef NCBI_OS_MSWIN 2369  if

( name.empty() || name ==

prev

) {

2389 #ifdef NCBI_OS_MSWIN 2397  string

path = entry.

GetPath

();

2402  string

filename = path.substr(pos+1);

2403  string

dirname = path.substr(0, pos);

2404  if

( dirname.empty() ) {

2408

entry.

Reset

(dirname);

2417 #ifdef NCBI_OS_MSWIN 2470  " Source path does not exist: "

+ src.

GetPath

(),

2478 #ifdef NCBI_OS_MSWIN 2497  if

( src_type ==

eFile

&&

2518  " Both source and destination exist and have different types: " 2525  LOG_ERROR_NCBI

(19,

"CDirEntry::Rename(): Destination path already exists: " 2557  LOG_ERROR

(21,

"CDirEntry::Rename(): Destination path exists: "

+

GetPath

());

2565 #ifdef NCBI_OS_MSWIN 2566  if

( errno != EACCES ) {

2568  if

( errno != EXDEV ) {

2577  LOG_ERROR

(102,

"CDirEntry::Rename(): Renaming via Copy() failed for "

+

GetPath

());

2584  LOG_ERROR

(102,

"CDirEntry::Rename(): Renaming via Copy() failed for "

+

GetPath

());

2616 #if defined(NCBI_OS_MSWIN) 2645  return Copy

(backup_name,

flags

, copybufsize);

2664  if

( !

GetTime

(&this_time) ) {

2667  if

( !entry.

GetTime

(&entry_time) ) {

2671  return

this_time > entry_time;

2694  "Directory entry does not exist"

);

2704  switch

(if_absent) {

2712  "Directory entry does not exist"

);

2715  return

current > tm;

2723  switch

(if_absent) {

2731  "Directory entry does not exist"

);

2734  return

current > tm;

2741 #if defined(NCBI_OS_UNIX) 2742  struct SStat

st1, st2;

2743  if

( !

Stat

(&st1, follow_links) ) {

2747  if

( !

CDirEntry

(entry_name).

Stat

(&st2, follow_links) ) {

2748  LOG_ERROR

(23,

"CDirEntry::IsIdentical(): Cannot find: "

+ entry_name);

2751  return

st1.

orig

.st_dev == st2.

orig

.st_dev &&

2752

st1.

orig

.st_ino == st2.

orig

.st_ino;

2762  unsigned int

* uid,

unsigned int

* gid)

const 2764  if

( uid ) *uid = 0;

2765  if

( gid ) *gid = 0;

2767  if

( !owner && !group ) {

2772 #if defined(NCBI_OS_MSWIN) 2777  LOG_ERROR

(24,

"CDirEntry::GetOwner(): Unable to get owner for: "

+

GetPath

());

2781 #elif defined(NCBI_OS_UNIX) 2786

errcode = stat(

GetPath

().c_str(), &

st

);

2788

errcode = lstat(

GetPath

().c_str(), &

st

);

2790  if

( errcode != 0 ) {

2802  if

(owner->empty()) {

2808  if

(group->empty()) {

2820  unsigned int

* uid,

unsigned int

* gid)

const 2822  if

( uid ) *uid = (

unsigned int

)(-1);

2823  if

( gid ) *gid = (

unsigned int

)(-1);

2825  if

( owner.empty() && group.empty() ) {

2830 #if defined(NCBI_OS_MSWIN) 2834  LOG_ERROR

(104,

"CDirEntry::SetOwner(): Unable to set owner \"" 2835

+ owner +

':'

+ group +

"\" for: "

+

GetPath

());

2839 #elif defined(NCBI_OS_UNIX) 2842  if

( !owner.empty() ) {

2844  if

(temp_uid == (uid_t)(-1)){

2848  LOG_ERROR

(25,

"CDirEntry::SetOwner(): Invalid owner name \"" 2849

+ owner +

"\" for: "

+

GetPath

());

2852

temp_uid = (uid_t) temp;

2858

temp_uid = (uid_t)(-1);

2862  if

( !group.empty() ) {

2864  if

(temp_gid == (gid_t)(-1)) {

2868  LOG_ERROR

(26,

"CDirEntry::SetOwner(): Invalid group name \"" 2869

+ group +

"\" for: "

+

GetPath

());

2872

temp_gid = (gid_t) temp;

2878

temp_gid = (gid_t)(-1);

2882  if

( chown(

GetPath

().c_str(), temp_uid, temp_gid) ) {

2884

+ owner +

':'

+ group +

"\" for: "

+

GetPath

());

2888 # if defined(HAVE_LCHOWN) 2890  if

( lchown(

GetPath

().c_str(), temp_uid, temp_gid) ) {

2891  LOG_ERROR_ERRNO

(28,

"CDirEntry::SetOwner(): Cannot change symlink owner \"" 2892

+ owner +

':'

+ group +

"\" for: "

+

GetPath

());

2905 #if defined(NCBI_OS_MSWIN) || defined(NCBI_OS_UNIX) 2910  "Temporary file cannot be auto-created on this platform, " 2911  "return its name only"

);

2925 #if !defined(NCBI_OS_UNIX) && !defined(NCBI_OS_MSWIN) 2926 static string

s_StdGetTmpName(

const char

* dir,

const char

* prefix)

2928  char

* filename = tempnam(dir, prefix);

2930  LOG_ERROR_ERRNO

(92,

"CDirEntry::s_StdGetTmpName(): tempnam() failed"

);

2933  string str

(filename);

2941  const string

& prefix,

2948

temp_file.

Close

();

2965 #if defined(NCBI_OS_MSWIN) 2975  if

( !m_FileName.empty() ) {

2990  if

( tmpname.empty() ) {

2991  LOG_ERROR

(29,

"CDirEntry::CreateTmpFile(): Cannot get temporary file name"

);

2994 #if defined(NCBI_OS_MSWIN) 3003  char mode

[6] =

"w+TDb"

;

3004  if

(text_binary !=

eBinary

) {

3009  LOG_ERROR_ERRNO

(105,

"CDirEntry::CreateTmpFile(): Cannot create temporary file: "

+ tmpname);

3019  if

( text_binary ==

eBinary

) {

3028  if

( !stream->good() ) {

3030  LOG_ERROR_NCBI

(106,

"CDirEntry::CreateTmpFile(): Cannot create temporary file stream for: "

+ tmpname,

3043

text_binary, allow_read);

3060 #if defined(NCBI_OS_UNIX) 3063  LOG_ERROR

(30,

"s_CopyAttrs(): cannot get attributes for: "

+

string

(from));

3071 # if defined(HAVE_UTIMES) 3072  struct

timeval tvp[2];

3073

tvp[0].tv_sec =

st

.orig.st_atime;

3074

tvp[0].tv_usec =

TV_USEC

(

st

.atime_nsec / 1000);

3075

tvp[1].tv_sec =

st

.orig.st_mtime;

3076

tvp[1].tv_usec =

TV_USEC

(

st

.mtime_nsec / 1000);

3077 # if defined(HAVE_LUTIMES) 3078  if

(lutimes(to, tvp)) {

3079  LOG_ERROR_ERRNO

(31,

"CDirEntry::s_CopyAttrs(): lutimes() failed for: "

+

string

(to));

3083  if

(utimes(to, tvp)) {

3084  LOG_ERROR_ERRNO

(32,

"CDirEntry::s_CopyAttrs(): utimes() failed for: "

+

string

(to));

3091  struct

utimbuf times;

3092

times.actime =

st

.orig.st_atime;

3093

times.modtime =

st

.orig.st_mtime;

3094  if

(utime(to, &times)) {

3095  LOG_ERROR_ERRNO

(33,

"CDirEntry::s_CopyAttrs(): utime() failed for: "

+

string

(to));

3107 # if defined(HAVE_LCHOWN) 3108  if

( lchown(to,

st

.orig.st_uid,

st

.orig.st_gid) ) {

3109  if

(errno != EPERM) {

3110  LOG_ERROR_ERRNO

(34,

"CDirEntry::s_CopyAttrs(): lchown() failed for: "

+

string

(to));

3122  if

( chown(to,

st

.orig.st_uid,

st

.orig.st_gid) ) {

3123  if

( errno != EPERM ) {

3124  LOG_ERROR_ERRNO

(35,

"CDirEntry::s_CopyAttrs(): chown() failed for: "

+

string

(to));

3127  st

.orig.st_mode &= ~(S_ISUID | S_ISGID);

3135  if

( chmod(to,

st

.orig.st_mode) ) {

3136  LOG_ERROR_ERRNO

(36,

"CDirEntry::s_CopyAttrs(): chmod() failed for: "

+

string

(to));

3143 #elif defined(NCBI_OS_MSWIN) 3147

WIN32_FILE_ATTRIBUTE_DATA attr;

3148  if

( !::GetFileAttributesEx(

_T_XCSTRING

(from), GetFileExInfoStandard, &attr) ) {

3149  LOG_ERROR_WIN

(30,

"CDirEntry::s_CopyAttrs(): cannot get attributes for: "

+

string

(from));

3156

FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ,

NULL

,

3158

FILE_FLAG_BACKUP_SEMANTICS

,

NULL

);

3160  LOG_ERROR_WIN

(37,

"CDirEntry::s_CopyAttrs(): Cannot open: "

+

string

(to));

3163  if

( !::SetFileTime(h, &attr.ftCreationTime, &attr.ftLastAccessTime, &attr.ftLastWriteTime) ) {

3164  LOG_ERROR_WIN

(38,

"CDirEntry::s_CopyAttrs(): Cannot change time for: "

+

string

(to));

3172  if

( !::SetFileAttributes(

_T_XCSTRING

(to), attr.dwFileAttributes) ) {

3173  LOG_ERROR_WIN

(39,

"CDirEntry::s_CopyAttrs(): Cannot change pemissions for: "

+

string

(to));

3179  string

owner, group;

3182  if

( efrom.GetOwner(&owner, &group) ) {

3219 #if !defined(NCBI_OS_MSWIN) 3223 static int

s_CloseFile(

int

fd)

3225  while

(

close

(fd) != 0) {

3236 static bool

s_CopyFile(

const char

* src,

const char

* dst,

size_t

buf_size)

3248

(fd =

NcbiSys_open

(dst, O_WRONLY|O_CREAT|O_TRUNC,

st

.st_mode & 0777)) == -1) {

3249  int

x_errno = errno;

3261  if

(3 *

sizeof

(x_buf) >= (

Uint8

)

st

.st_size) {

3263

buf_size =

sizeof

(x_buf);

3266  if

(buf_size == 0) {

3270  if

(buf_size > (

Uint8

)

st

.st_size) {

3271

buf_size =

st

.st_size;

3273  buf

= buf_size >

sizeof

(x_buf) ?

new char

[buf_size] : x_buf;

3284  if

(errno == EINTR) {

3291  const char

* ptr =

buf

;

3293  ssize_t

n_written = write(fd, ptr, n_read);

3294  if

(n_written == 0) {

3298  if

( n_written < 0 ) {

3299  if

(errno == EINTR) {

3305

n_read -= n_written;

3307

}

while

(n_read > 0);

3317  int

xx_err = s_CloseFile(fd);

3321  if

(

buf

!= x_buf) {

3346  if

( src_type !=

eFile

) {

3353  bool

dst_exists = (dst_type !=

eUnknown

);

3354  string

dst_safe_path;

3360 #if defined(NCBI_OS_UNIX) 3398  string

path, name, ext;

3402

dst_safe_path = dst.

GetPath

();

3407 #if defined(NCBI_OS_MSWIN) 3415  if

( !s_CopyFile(src.

GetPath

().c_str(), dst.

GetPath

().c_str(), buf_size) ) {

3427  " Cannot rename temporary file "

+ dst.

GetPath

() +

3442 #if defined(NCBI_OS_MSWIN) 3450  LOG_ERROR

(95,

"CFile::Copy(): Cannot copy permissions from "

+

3465  size_t x_size

=

sizeof

(x_buf)/2;

3468  bool

equal =

false

;

3481  LOG_ERROR_NCBI

(93,

"CFile::Compare(): files have different size: "

+

3482  GetPath

() +

" and "

+ filename,

3495  if

(buf_size == 0) {

3500  if

(buf_size > s1) {

3501

buf_size = (size_t)s1 + (8 - s1 % 8);

3503  if

(buf_size >

x_size

) {

3504

buf1 =

new char

[buf_size*2];

3505

buf2 = buf1 + buf_size;

3519  if

(n1 < buf_size) {

3520  n

= f1.

Read

(buf1 + n1, buf_size - n1);

3526  if

(n2 < buf_size) {

3527  n

= f2.

Read

(buf2 + n2, buf_size - n2);

3533  size_t

m =

min

(n1, n2);

3534  if

( memcmp(buf1, buf2, m) != 0 ) {

3538  memmove

(buf1, buf1 + m, n1 - m);

3544  memmove

(buf2, buf2 + m, n2 - m);

3555  " and "

+ filename +

" : "

+ ex.what(),

3558  if

(buf1 != x_buf) {

3566  size_t

buf_size)

const 3584 #if defined(NCBI_OS_UNIX) 3591  if

((pwd = getpwuid(getuid())) == 0) {

3605  if

( !(ptr = getlogin()) ) {

3612  struct

passwd* pwd = getpwnam(ptr);

3613  if

( !pwd || pwd->pw_dir[0] ==

'\0'

) {

3628 #if defined(NCBI_OS_MSWIN) 3635  str

=

NcbiSys_getenv

((home_check_order == eHomeWindows_AppData) ?

_TX

(

"USERPROFILE"

) :

_TX

(

"APPDATA"

));

3640 #elif defined(NCBI_OS_UNIX) 3663 #if defined(NCBI_OS_UNIX) 3665  char

* tmpdir = getenv(

"TMPDIR"

);

3669 # if defined(P_tmpdir) 3676 #elif defined(NCBI_OS_MSWIN) 3682 # if defined(P_tmpdir) 3698  if

( !

tmp

.empty() ) {

3712  LOG_ERROR_ERRNO

(90,

"CDir::GetCwd(): Cannot get current directory"

);

3720  LOG_ERROR_ERRNO

(51,

"CDir::SetCwd(): Cannot change directory to: "

+ dir);

3734  const

vector<string>& masks,

3737  if

( masks.empty() ) {

3740  ITERATE

(vector<string>, itm, masks) {

3741  const string

&

mask

= *itm;

3752 #if defined(NCBI_OS_MSWIN) 3762

::SetLastError(err);

3764  case

ERROR_NO_MORE_FILES:

3765  case

ERROR_FILE_NOT_FOUND:

3766  case

ERROR_PATH_NOT_FOUND:

3769  case

ERROR_NOT_ENOUGH_MEMORY:

3772  case

ERROR_ACCESS_DENIED:

3781 # define IS_RECURSIVE_ENTRY \ 3782  ( (flags & CDir::fIgnoreRecursive) && \ 3783  ((NcbiSys_strcmp(entry.cFileName, _TX("."

)) == 0) || \

3784

(NcbiSys_strcmp(entry.cFileName, _TX("..")) == 0)) )

3787  const string

& base_path,

3788  const

WIN32_FIND_DATA& entry,

3800

contents->push_back(

new CDirEntry

(name));

3806 # define IS_RECURSIVE_ENTRY \ 3807  ( (flags & CDir::fIgnoreRecursive) && \ 3808  ((::strcmp(entry->d_name, "."

) == 0) || \

3809

(::strcmp(entry->d_name, "..") == 0)) )

3812  const string

& base_path,

3813  const struct

dirent* entry,

3820 # if defined(_DIRENT_HAVE_D_TYPE) 3822  if

(entry->d_type) {

3823  st

.st_mode = DTTOIF(entry->d_type);

3829  const string

path = base_path + entry->d_name;

3837

contents->push_back(

new CDirEntry

(name));

3847  if

( !

mask

.empty() ) {

3850  return

GetEntries(masks,

flags

);

3857  if

( !

mask

.empty() ) {

3860  return

GetEntriesPtr(masks,

flags

);

3866

unique_ptr<TEntries> contents(GetEntriesPtr(masks,

flags

));

3867  return

contents.get() ? *contents.get() :

TEntries

();

3873  if

( masks.empty() ) {

3880 #if defined(NCBI_OS_MSWIN) 3883  string

pattern = base_path +

"*"

;

3885

WIN32_FIND_DATA entry;

3888

handle = ::FindFirstFile(

_T_XCSTRING

(pattern), &entry);

3893  ITERATE

(vector<string>, it, masks) {

3894  const string

&

mask

= *it;

3895  if

(

mask

.empty() ||

3902

}

while

(::FindNextFile(handle, &entry));

3904

::FindClose(handle);

3907  DWORD

err = ::GetLastError();

3917 #elif defined(NCBI_OS_UNIX) 3919

DIR* dir = opendir(base_path.c_str());

3928  while

(

struct

dirent* entry = readdir(dir)) {

3932  ITERATE

(vector<string>, it, masks) {

3933  const string

&

mask

= *it;

3951

unique_ptr<TEntries> contents(GetEntriesPtr(masks,

flags

));

3952  return

contents.get() ? *contents.get() :

TEntries

();

3962 #if defined(NCBI_OS_MSWIN) 3965  string

pattern = base_path +

"*"

;

3967

WIN32_FIND_DATA entry;

3970

handle = ::FindFirstFile(

_T_XCSTRING

(pattern), &entry);

3977

}

while

( ::FindNextFile(handle, &entry) );

3979

::FindClose(handle);

3982  DWORD

err = ::GetLastError();

3992 #elif defined(NCBI_OS_UNIX) 3994

DIR* dir = opendir(base_path.c_str());

4003  while

(

struct

dirent* entry = readdir(dir)) {

4005

masks.

Match

(entry->d_name, use_case) ) {

4022 #if defined(NCBI_OS_MSWIN) 4024 #elif defined(NCBI_OS_UNIX) 4028  if

(errno != EEXIST) {

4029  LOG_ERROR_ERRNO

(52,

"s_DirCreate(): Cannot create directory: "

+ path);

4062  LOG_ERROR_ERRNO

(55,

"CDir::Create(): Cannot set mode for directory: "

+ path);

4080  string

path_up(d.

GetDir

());

4081  if

( path_up.empty() || path_up == d.

GetPath

() ) {

4086 #if defined(NCBI_OS_MSWIN) 4089  if

(path_up.length() > 3) {

4117

&& path.length() != 3

4121

path.erase(path.length() - 1);

4127

std::list<CTempString> missed_parts;

4135

missed_parts.push_front(part);

4144  if

(missed_parts.empty()) {

4147

parent.assign(

tmp

);

4149 #if defined(NCBI_OS_MSWIN) 4151  if

(parent.length() == 2) {

4157  LOG_ERROR_ERRNO

(61,

"CDir::CreatePath(): stat() failed for: "

+ parent);

4164  if

(missed_parts.empty()) {

4175  for

(

auto i

: missed_parts) {

4200  if

( src_type !=

eDir

) {

4206  bool

dst_exists = (dst_type !=

eUnknown

);

4207  bool

need_create_dst = !dst_exists;

4208  string

dst_safe_path;

4250  LOG_ERROR

(66,

"CDir::Copy(): Cannot backup destination directory: "

+ dst.

GetPath

());

4253

need_create_dst =

true

;

4264  if

( need_safe_copy ) {

4266  string

path, name, ext;

4270

dst_safe_path = dst.

GetPath

();

4272

need_create_dst =

true

;

4278  if

( need_create_dst ) {

4280  LOG_ERROR

(67,

"CDir::Copy(): Cannot create "

<<

4281

(dst_safe_path.empty() ?

"target"

:

"temporary"

) <<

4282  " directory: "

<< dst.

GetPath

());

4289  if

( !contents.get() ) {

4303  LOG_ERROR

(69,

"CDir::Copy(): Cannot copy "

+

4310  if

(!dst_safe_path.empty()) {

4313  LOG_ERROR

(70,

"CDir:Copy(): Cannot rename temporary directory "

+

4314

dst.

GetPath

() +

" to "

+ dst_safe_path);

4322  LOG_ERROR

(98,

"CDir:Copy(): Cannot copy attributes from "

+

4331  LOG_ERROR

(99,

"CDir:Copy(): Cannot set default directory permissions: "

+ dst.

GetPath

());

4352  LOG_ERROR_ERRNO

(71,

"CDir::Remove(): Cannot remove (by implication empty)" 4359 #if !defined(NCBI_OS_MSWIN) 4367

unique_ptr<TEntries> contents(GetEntriesPtr());

4368  if

(!contents.get()) {

4373  bool

success =

true

;

4377  string

name = (*entry)->GetName();

4378  if

(name ==

"."

|| name ==

".."

|| name ==

string

(1,

GetPathSeparator

())) {

4394  throw "Removing subdirectory failed"

;

4403  throw "Removing directory entry failed"

;

4417  throw "Removing directory entry (non-recursive) failed"

;

4443  throw "Cannot remove directory entry"

;

4447  catch

(

const char

* what) {

4450  LOG_ERROR

(73,

"CDir::Remove(): Cannot remove directory: "

+

GetPath

() +

": "

+ what);

4471

unique_ptr<TEntries> contents(GetEntriesPtr());

4472  if

(!contents.get()) {

4477  bool

success =

true

;

4481  string

name = (*entry)->GetName();

4482  if

(name ==

"."

|| name ==

".."

||

4493  if

(!

CDir

(item.

GetPath

()).

SetMode

(user_mode, group_mode, other_mode, special_mode,

f

)) {

4497  throw "Changing mode for subdirectory failed"

;

4502  if

(!item.

SetModeEntry

(user_mode, group_mode, other_mode, special_mode,

f

)) {

4506  throw "Changing mode for subdirectory entry failed"

;

4516  if

(!

CDir

(item.

GetPath

()).

SetMode

(user_mode, group_mode, other_mode, special_mode,

4521  throw "Changing mode for subdirectory (non-recursive) failed"

;

4529  if

(!item.

SetModeEntry

(user_mode, group_mode, other_mode, special_mode,

flags

)) {

4534  throw "Changing mode for subdirectory entry failed"

;

4541  catch

(

const char

* what) {

4544  LOG_ERROR

(94,

"CDir::SetMode(): Cannot change mode for directory: "

+

GetPath

() +

": "

+ what);

4574 #if defined(NCBI_OS_UNIX) 4579  if

(

strcmp

(

buf

, path.c_str()) == 0) {

4590  " Symbolic links not supported on this platform: " 4599 #if defined(NCBI_OS_UNIX) 4626  bool

dst_exists = (dst_type !=

eUnknown

);

4627  string

dst_safe_path;

4659  LOG_ERROR

(81,

"CSymLink::Copy(): Cannot backup destination: "

+ dst.

GetPath

());

4671  string

path, name, ext;

4675

dst_safe_path = dst.

GetPath

();

4694  " Cannot create symbolic link "

+ dst.

GetPath

() +

4695  " to "

+

string

(

buf

));

4704  " Cannot rename temporary symlink "

+ dst.

GetPath

() +

4712  LOG_ERROR

(100,

"CSymLink::Copy(): Cannot copy permissions from "

+

4713  GetPath

() +

" to "

+ new_path);

4721  return

CParent::Copy(new_path,

flags

, buf_size);

4799 #define GET_STATVFS_INFO \ 4800  struct statvfs st; \ 4801  memset(&st, 0, sizeof(st)); \ 4802  if (statvfs(path.c_str(), &st) != 0) { \ 4803  CNcbiError::SetFromErrno(); \ 4804  NCBI_THROW(CFileErrnoException, eFileSystemInfo, string(msg) + path); \ 4806  info->total_space = (Uint8)st.f_bsize * st.f_blocks; \ 4807  if (st.f_frsize) { \ 4808  info->free_space = (Uint8)st.f_frsize * st.f_bavail; \ 4809  info->block_size = (unsigned long)st.f_frsize; \ 4811  info->free_space = (Uint8)st.f_bsize * st.f_bavail; \ 4812  info->block_size = (unsigned long)st.f_bsize; \ 4814  info->used_space = info->total_space - info->free_space 4817 #define GET_STATFS_INFO \ 4819  memset(&st, 0, sizeof(st)); \ 4820  if (statfs(path.c_str(), &st) != 0) { \ 4821  CNcbiError::SetFromErrno(); \ 4822  NCBI_THROW(CFileErrnoException, eFileSystemInfo, string(msg) + path); \ 4824  info->total_space = (Uint8)st.f_bsize * st.f_blocks; \ 4825  info->free_space = (Uint8)st.f_bsize * st.f_bavail; \ 4826  info->used_space = info->total_space - info->free_space; \ 4827  info->block_size = (unsigned long)st.f_bsize 4831 #if defined(SUPPORT_PANFS) 4837  int

errcode = errno;

4838  _no_warning

(::write(fd, &errcode,

sizeof

(errcode)));

4844 #define CLOSE_PIPE_END(fd) \ 4863  static bool

s_InitEXE =

false

;

4864  static bool

s_ExistEXE =

false

;

4866 #if defined(ALLOW_USE_NCBI_PANFS_DLL) 4869  static bool

s_InitDLL =

false

;

4870  static

FGetDiskSpace_PANFS f_GetDiskSpace =

NULL

;

4875 # define _TOSTRING(x) #x 4876 # define TOSTRING(x) _TOSTRING(x) 4877  const char

* kNcbiPanfsDLL =

"/opt/ncbi/"

TOSTRING(

NCBI_PLATFORM_BITS

)

"/lib/ncbi_panfs.so"

;

4881  void

* handle = ::dlopen(kNcbiPanfsDLL, RTLD_NOW | RTLD_GLOBAL);

4882  const char

* err =

NULL

;

4884

f_GetDiskSpace = (FGetDiskSpace_PANFS) ::dlsym(handle,

"ncbi_GetDiskSpace_PANFS"

);

4885  if

( !f_GetDiskSpace ) {

4886

err =

"Undefined symbol"

;

4889

err =

"Cannot open shared object file"

;

4892  char

* dlerr = dlerror();

4893  string msg

=

"Trying to get ncbi_GetDiskSpace_PANFS() function from '"

+

4894  string

(kNcbiPanfsDLL) +

"': "

+ err;

4896  msg

=

msg

+

" ("

+ dlerr +

")"

;

4906  if

( f_GetDiskSpace ) {

4907  const char

* err_msg =

NULL

;

4908  bool

do_throw =

false

;

4910  int

res = f_GetDiskSpace(path.c_str(), &

info

->total_space, &

info

->free_space, &err_msg);

4914  info

->used_space =

info

->total_space -

info

->free_space;

4918  case

NCBI_PANFS_THROW:

4923  case

NCBI_PANFS_ERR:

4924  case

NCBI_PANFS_ERR_OPEN:

4925  case

NCBI_PANFS_ERR_QUERY:

4926  case

NCBI_PANFS_ERR_VERSION:

4929  string msg

=

"Cannot get information for PANFS mount '"

+ path +

"'"

;

4949  const char

* kPanDF =

"/opt/panfs/bin/pan_df"

;

4961  int

status_pipe[2] = {-1,-1};

4962  int

pipe_fd[2] = {-1,-1};

4967  if

(::pipe(pipe_fd) < 0) {

4968  throw "failed to create pipe for stdout"

;

4972  if

(::pipe(status_pipe) < 0) {

4973  throw "failed to create status pipe"

;

4975  if

(::fcntl(status_pipe[1], F_SETFD,

4976

::fcntl(status_pipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0) {

4977  throw "failed to set close-on-exec mode for status pipe"

;

4981

pid_t pid = ::fork();

4983  throw "fork() failed"

;

4991  _no_warning

(::freopen(

"/dev/null"

,

"r"

, stdin));

4992  _no_warning

(::freopen(

"/dev/null"

,

"a"

, stderr));

5001  int

status = ::execl(kPanDF, kPanDF,

"--block-size=1"

, path.c_str(),

NULL

);

5019  while

((

n

= read(status_pipe[0], &errcode,

sizeof

(errcode))) < 0) {

5026

::waitpid(pid, 0, 0);

5027

errno = (size_t)

n

>=

sizeof

(errcode) ? errcode : 0;

5028  throw "failed to run pan_df"

;

5033  while

((

n

= read(pipe_fd[0], &

buf

,

sizeof

(

buf

)-1)) < 0) {

5039  throw "error reading from pipe"

;

5044  const char

* kParseError =

"results parse error"

;

5045  const char

*

data

= strchr(

buf

,

'\n'

);

5049

vector<string> tokens;

5051  if

( tokens.size() != 6 ) {

5054  Uint8

x_total = 1, x_free = 2, x_used = 3;

5064  if

( x_free + x_used != x_total ) {

5067  info

->total_space = x_total;

5068  info

->free_space = x_free;

5069  info

->used_space = x_used;

5072  catch

(

const char

* what) {

5083  "Cannot use any external method to get information about " 5084  "PANFS mount, fall back to use standard OS info " 5085  "(NOTE: it can be incorrect)"

);

5099  "s_GetFileSystemInfo(path, NULL) is not allowed"

);

5101

memset(

info

, 0,

sizeof

(*

info

));

5102  const char

*

msg

=

"Cannot get system information for "

;

5103  const char

* fs_name_ptr = 0;

5105 #if defined(NCBI_OS_MSWIN) 5107  string

xpath = path;

5123  TXChar

fs_name[MAX_PATH+1];

5129  if

( !::GetVolumeInformation(

_T_XCSTRING

(xpath),

5135  sizeof

(fs_name)/

sizeof

(fs_name[0])) ) {

5138  info

->filename_max = filename_max;

5140

fs_name_ptr = ufs_name.c_str();

5146

(PULARGE_INTEGER)&

info

->free_space,

5147

(PULARGE_INTEGER)&

info

->total_space, 0) ) {

5154  DWORD

dwSectPerClust;

5155  DWORD

dwBytesPerSect;

5157

&dwSectPerClust, &dwBytesPerSect,

5161  info

->block_size = dwBytesPerSect * dwSectPerClust;

5166  bool

need_name_max =

true

;

5167 # ifdef _PC_NAME_MAX 5168  long

r_name_max = pathconf(path.c_str(), _PC_NAME_MAX);

5169  if

(r_name_max != -1) {

5170  info

->filename_max = (

unsigned

long)r_name_max;

5171

need_name_max =

false

;

5175 # if (defined(NCBI_OS_LINUX) || defined(NCBI_OS_CYGWIN)) && defined(HAVE_STATFS) 5179  switch

(

st

.f_type) {

5247  if

(need_name_max) {

5248  info

->filename_max = (

unsigned

long)

st

.f_namelen;

5251 # elif (defined(NCBI_OS_SOLARIS) || defined(NCBI_OS_IRIX) || defined(NCBI_OS_OSF1)) \ 5252  && defined(HAVE_STATVFS) 5255  if

(need_name_max) {

5256  info

->filename_max = (

unsigned

long)

st

.f_namemax;

5258

fs_name_ptr =

st

.f_basetype;

5260 # elif defined(NCBI_OS_DARWIN) && defined(HAVE_STATFS) 5266  if

(need_name_max) {

5269

fs_name_ptr =

st

.f_fstypename;

5271 # elif defined(NCBI_OS_BSD) && defined(HAVE_STATFS) 5274

fs_name_ptr =

st

.f_fstypename;

5275  if

(need_name_max) {

5276  info

->filename_max = (

unsigned

long)

st

.f_namemax;

5279 # elif defined(NCBI_OS_OSF1) && defined(HAVE_STATVFS) 5282  if

(need_name_max) {

5283  info

->filename_max = (

unsigned

long)

st

.f_namelen;

5285

fs_name_ptr =

st

.f_fstypename;

5290  #if defined(HAVE_STATVFS) 5292  #elif defined(HAVE_STATFS) 5310 #if defined(SUPPORT_PANFS) 5330  return info

.free_space;

5338  return info

.used_space;

5346  return info

.total_space;

5390  if

( m_FileName.empty() ) {

5393

m_RemoveOnDestruction = remove_file;

5398

m_RemoveOnDestruction(remove_file)

5436  switch

(if_exists) {

5456  switch

(if_exists) {

5480 #if defined(NCBI_OS_MSWIN) 5490 #if defined(NCBI_OS_MSWIN) 5511 #if defined(NCBI_OS_MSWIN) 5513  switch

(protect_attr) {

5530

attrs->

file_access

= GENERIC_READ | GENERIC_WRITE;

5536

attrs->

file_share

= FILE_SHARE_READ | FILE_SHARE_WRITE;

5541 #elif defined(NCBI_OS_UNIX) 5543  switch

(share_attr) {

5559  switch

(protect_attr) {

5584  "Memory-mapping is not supported by the C++ Toolkit on this platform"

);

5591 #if defined(NCBI_OS_MSWIN) || defined(NCBI_OS_UNIX) 5603

: m_DataPtr(0), m_Offset(

offset

), m_Length(length),

5604

m_DataPtrReal(0), m_OffsetReal(

offset

), m_LengthReal(length)

5608  "File offset may not be negative"

);

5612  "File mapping region size must be greater than 0"

);

5620  "Cannot determine virtual memory allocation granularity"

);

5630 #if defined(NCBI_OS_MSWIN) 5638 #elif defined(NCBI_OS_UNIX) 5649  "Cannot map file '"

+

5650

handle.

sFileName

+

"' to memory (offset="

+

5672 #if defined(NCBI_OS_MSWIN) 5675  LOG_ERROR_WIN

(87,

"CMemoryFileSegment::Flush(): Cannot flush memory segment"

);

5678 #elif defined(NCBI_OS_UNIX) 5681  LOG_ERROR_ERRNO

(87,

"CMemoryFileSegment::Flush(): Cannot flush memory segment"

);

5697 #if defined(NCBI_OS_MSWIN) 5700  LOG_ERROR_WIN

(88,

"CMemoryFileSegment::Unmap(): Cannot unmap memory segment"

);

5703 #elif defined(NCBI_OS_UNIX) 5706  LOG_ERROR_ERRNO

(88,

"CMemoryFileSegment::Unmap(): Cannot unmap memory segment"

);

5731

: m_FileName(

file_name

), m_Handle(0), m_Attrs(0)

5733 #if defined(NCBI_OS_MSWIN) 5747  if

( file_size < 0 ) {

5753  "To be memory mapped the file must exist: '"

+

m_FileName

+

"'"

);

5757  x_Extend

(file_size, max_file_len);

5758

file_size = (

Int8

)max_file_len;

5762  if

( file_size == 0 ) {

5796  "File too big for memory mapping "

\

5800

}

else if

( file_size > 0 ) {

5801

length = (size_t)file_size;

5804  "Mapping region offset specified beyond file size"

);

5809  void

* ptr = segment->

GetPtr

();

5825  bool

status =

false

;

5828

status = segment->second->Unmap();

5830  delete

segment->second;

5835  LOG_ERROR

(89,

"CMemoryFileMap::Unmap(): Memory segment not found"

);

5844  bool

status =

true

;

5845  void

* key_to_delete = 0;

5847  if

( key_to_delete ) {

5850  bool

unmapped = it->second->Unmap();

5855

key_to_delete = it->first;

5861  if

( key_to_delete ) {

5865  LOG_ERROR

(89,

"CMemoryFileMap::UnmapAll(): Memory segment not found"

);

5876  #if defined(NCBI_OS_UNIX) 5901 #if defined(NCBI_OS_MSWIN) 5913

OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,

NULL

);

5922

::CloseHandle(hFile);

5925

::CloseHandle(hFile);

5929 #elif defined(NCBI_OS_UNIX) 5944  "CMemoryFile: Cannot memory map file '"

+

m_FileName

+

"':"

+ errmsg);

5959 #if defined(NCBI_OS_MSWIN) 5961 #elif defined(NCBI_OS_UNIX) 5976 #if defined(NCBI_OS_UNIX) 5981  while

(ftruncate(fd, (off_t)new_size) < 0) {

5982  if

(errno != EINTR) {

6006  if

(current_pos < 0) {

6016  if

(errno != EINTR) {

6031  int

pmode = S_IREAD;

6032 #if defined(NCBI_OS_MSWIN) 6034 #elif defined(NCBI_OS_UNIX) 6043  " Cannot create file '"

+

m_FileName

+

"'"

);

6049 #if defined(NCBI_OS_MSWIN) 6051 #elif defined(NCBI_OS_UNIX) 6055  " Cannot create file with specified size: "

+ errmsg);

6062  if

(

size

>= new_size) {

6069  int

errcode = errno;

6072  "' to change its size: "

+

6079 #if defined(NCBI_OS_MSWIN) 6081 #elif defined(NCBI_OS_UNIX) 6085  " Cannot extend file size: "

+ errmsg);

6095  " File is not mapped"

);

6100  " Cannot find mapped file segment" 6101  " with specified address"

);

6103  return

segment->second;

6163  "Specified length of the mapping region is too big " 6165

}

else if

( fs > 0 ) {

6166

length = (size_t)fs;

6169  "Specified offset of the mapping region" 6170  " exceeds the file size"

);

6208  case eFileIO

:

return "eFileIO"

;

6209  case eTmpFile

:

return "eTmpFile"

;

6217  case eFile

:

return "eFile"

;

6220  case eFileIO

:

return "eFileIO"

;

6233  const

std::list<string>& parts,

6234

std::list<string>::const_iterator

next

,

6235

std::list<string>&

result

,

6238

vector<string> paths;

6239

paths.push_back(path);

6240

vector<string> masks;

6241

masks.push_back(*

next

);

6242  bool last

= ++

next

== parts.end();

6248

std::list<string> found;

6249  FindFiles

(found, paths.begin(), paths.end(), masks, ff);

6251  result

.insert(

result

.end(), found.begin(), found.end());

6254  if

( !found.empty() ) {

6255  ITERATE

(std::list<string>, it, found) {

6269  if

( find_type == 0 ) {

6275  string

search_path = kDirSep;

6277

std::list<string> parts;

6279  if

( parts.empty() ) {

6283 #if defined(DISK_SEPARATOR) 6289  bool

is_network = abs_path.find(kNetSep) == 0;

6291

search_path = kNetSep + parts.front() + kDirSep;

6292

parts.erase(parts.begin());

6297  if

( disk.empty() ) {

6300  if

( !disk.empty() ) {

6301

search_path = disk + kDirSep;

6308

parts.erase(parts.begin());

6309

search_path += kDirSep;

6313  string

temp = parts.front().substr(disk.size());

6314

parts.erase(parts.begin());

6315

parts.insert(parts.begin(), temp);

6325 #define UNDEFINED_SORT_MODE kMax_Int 6359  for

(

int i

= 0;

i

< 3;

i

++) {

6397

m_AutoClose(

false

),

6398

m_AutoRemove(

CFileIO

::eDoNotRemove)

6421 #if defined(NCBI_OS_MSWIN) 6424  DWORD

dwAccessMode, dwShareMode, dwOpenMode;

6426  switch

(open_mode) {

6428

dwOpenMode = CREATE_ALWAYS;

6431

dwOpenMode = CREATE_NEW;

6434

dwOpenMode = OPEN_EXISTING;

6437

dwOpenMode = OPEN_ALWAYS;

6440

dwOpenMode = TRUNCATE_EXISTING;

6445  switch

(access_mode) {

6447

dwAccessMode = GENERIC_READ;

6450

dwAccessMode = GENERIC_WRITE;

6453

dwAccessMode = GENERIC_READ | GENERIC_WRITE;

6458  switch

(share_mode) {

6460

dwShareMode = FILE_SHARE_READ;

6463

dwShareMode = FILE_SHARE_WRITE;

6466

dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;

6476

dwAccessMode, dwShareMode,

NULL

, dwOpenMode,

6477

FILE_ATTRIBUTE_NORMAL,

NULL

);

6482 #elif defined(NCBI_OS_UNIX) 6485 # if defined(O_BINARY) 6486  int flags

= O_BINARY;

6492  switch

(open_mode) {

6494  flags

|= (O_CREAT | O_TRUNC);

6499  "Open mode is eCreateNew but file already exists: " 6508  if

( !

CFile

(filename).Exists() ) {

6518  switch

(access_mode) {

6541

std::ignore = share_mode;

6552  "Cannot open file '"

+ filename +

"': "

+ errmsg);

6560  const string

& prefix,

6565  "Cannot create temporary: Handle already open"

);

6567  static

atomic<int>

s_Count

= 0;

6569  if

(x_dir.empty()) {

6573  if

(!x_dir.empty()) {

6577  unsigned int

tid = (

unsigned int

) x_tid;

6578  string

x_prefix = prefix

6583 #if defined(NCBI_OS_MSWIN) || defined(NCBI_OS_UNIX) 6584  string

pattern = x_dir + x_prefix;

6586 # if defined(NCBI_OS_UNIX) 6587

pattern +=

"XXXXXX"

;

6590  "Pattern too long '"

+ pattern +

"'"

);

6593

memcpy(pathname, pattern.c_str(), pattern.size()+1);

6596  "mkstemp() failed for '"

+ pattern +

"'"

);

6603 # elif defined(NCBI_OS_MSWIN) 6604  unsigned long

ofs = (

unsigned

long)

int

(rand());

6607

_ultoa(ofs,

buffer

, 36);

6608  string

pathname = pattern +

buffer

;

6610

CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY,

NULL

);

6615  if

(::GetLastError() != ERROR_FILE_EXISTS) {

6623  "Unable to create temporary file '"

+ pattern +

"'"

);

6641 #if defined(NCBI_OS_MSWIN) 6645 #elif defined(NCBI_OS_UNIX) 6647  if

(errno != EINTR) {

6665  char

* ptr = (

char

*)

buf

;

6667 #if defined(NCBI_OS_MSWIN) 6669 #elif defined(NCBI_OS_UNIX) 6675 #if defined(NCBI_OS_MSWIN) 6678  if

( ::ReadFile(

m_Handle

, ptr, nmax, &

n

,

NULL

) == 0 ) {

6679  if

(::GetLastError() == ERROR_HANDLE_EOF) {

6687 #elif defined(NCBI_OS_UNIX) 6694  if

(errno == EINTR) {

6703  return

ptr - (

char

*)

buf

;

6712  const char

* ptr = (

const char

*)

buf

;

6714 #if defined(NCBI_OS_MSWIN) 6716 #elif defined(NCBI_OS_UNIX) 6722 #if defined(NCBI_OS_MSWIN) 6725  if

( ::WriteFile(

m_Handle

, ptr, nmax, &

n

,

NULL

) == 0 ) {

6728 #elif defined(NCBI_OS_UNIX) 6731  if

(

n

< 0 && errno == EINTR ) {

6741  return

ptr - (

char

*)

buf

;

6748 #if defined(NCBI_OS_MSWIN) 6750 #elif defined(NCBI_OS_UNIX) 6773 #if defined(NCBI_OS_MSWIN) 6778  BOOL

res = SetFilePointerEx(

m_Handle

, ofs, &pos, FILE_CURRENT);

6780  return

(

Uint8

)pos.QuadPart;

6782 #elif defined(NCBI_OS_UNIX) 6785  return

(

Uint8

)pos;

6796 #if defined(NCBI_OS_MSWIN) 6798

ofs.QuadPart = position;

6799  bool

res = (SetFilePointerEx(

m_Handle

, ofs,

NULL

, FILE_BEGIN) ==

TRUE

);

6800 #elif defined(NCBI_OS_UNIX) 6805  "Cannot change file positon" 6813 #if defined(NCBI_OS_MSWIN) 6815  switch

(move_method) {

6820

from = FILE_CURRENT;

6832 #elif defined(NCBI_OS_UNIX) 6834  switch

(move_method) {

6851  "Cannot change file positon" 6860 #if defined(NCBI_OS_MSWIN) 6863  if

(size_lo != INVALID_FILE_SIZE) {

6864  return

((

unsigned __int64

)size_hi << 32) | size_lo;

6866 #elif defined(NCBI_OS_UNIX) 6880 #if defined(NCBI_OS_MSWIN) 6884

LARGE_INTEGER saved;

6889

res = SetFilePointerEx(

m_Handle

, ofs, &saved, FILE_CURRENT);

6893

ofs.QuadPart = length;

6894

res = SetFilePointerEx(

m_Handle

, ofs,

NULL

, FILE_BEGIN);

6904

res = SetFilePointerEx(

m_Handle

, ofs,

NULL

, FILE_BEGIN);

6907

res = SetFilePointerEx(

m_Handle

, saved,

NULL

, FILE_BEGIN);

6912 #elif defined(NCBI_OS_UNIX) 6915  if

(!errcode && pos !=

eCurrent

) {

6928  "Cannot change file size" 6960  if

( filename ==

"-"

) {

6961 #if defined(NCBI_OS_MSWIN) 6962  TFileHandle

handle = GetStdHandle(STD_INPUT_HANDLE);

6963 #elif defined(NCBI_OS_UNIX) 6964 # ifdef STDIN_FILENO 7037  if

( filename ==

"-"

) {

7038 #if defined(NCBI_OS_MSWIN) 7039  TFileHandle

handle = GetStdHandle(STD_OUTPUT_HANDLE);

7040 #elif defined(NCBI_OS_UNIX) 7041 # ifdef STDOUT_FILENO 7049  return new CFileWriter

(filename, open_mode, share_mode);

7054  size_t count

,

size_t

* bytes_written)

7056  if

( bytes_written ) {

7070  if

( bytes_written ) {

7071

*bytes_written =

n

;

7127  size_t count

,

size_t

* bytes_read)

7157  size_t count

,

size_t

* bytes_written)

7159  if

( bytes_written ) {

7173  if

( bytes_written ) {

7174

*bytes_written =

n

;

7199 #define F_CLEAN_REDUNDANT(group) \ 7200  if (F_ISSET(m_Flags, (group))) \ 7201  m_Flags &= ~unsigned((group) & ~unsigned(fDefault)) 7209 #if defined(NCBI_OS_MSWIN) 7229 #elif defined(NCBI_OS_UNIX) 7243

m_IsLocked(

false

), m_Lock(0)

7252

m_IsLocked(

false

), m_Lock(0)

7260

: m_Handle(handle), m_CloseHandle(

false

), m_Flags(

flags

),

7261

m_IsLocked(

false

), m_Lock(0)

7275 #if defined(NCBI_OS_MSWIN) 7277

FILE_SHARE_READ,

NULL

, OPEN_EXISTING, 0,

NULL

);

7278 #elif defined(NCBI_OS_UNIX) 7284  "Cannot open file '"

+ (filename ?

string

(filename) :

"NULL"

) +

"'"

);

7314 #if defined(NCBI_OS_MSWIN) 7316 #elif defined(NCBI_OS_UNIX) 7333 #if defined(NCBI_OS_MSWIN) 7336  flags

|= LOCKFILE_EXCLUSIVE_LOCK;

7338

OVERLAPPED overlapped;

7339

overlapped.hEvent = 0;

7344

&overlapped) ==

TRUE

;

7345 #elif defined(NCBI_OS_UNIX) 7347

fl.l_type = (

type

==

eShared

) ? F_RDLCK : F_WRLCK;

7349

fl.l_start =

m_Lock

->offset;

7350

fl.l_len =

m_Lock

->length;

7351

fl.l_pid = getpid();

7355

err = fcntl(

m_Handle

, F_SETLK, &fl);

7356

}

while

(err && (errno == EINTR));

7357  bool

res = (err == 0);

7373 #if defined(NCBI_OS_MSWIN) 7374

OVERLAPPED overlapped;

7375

overlapped.hEvent = 0;

7378  bool

res = UnlockFileEx(

m_Handle

, 0,

7380

&overlapped) ==

TRUE

;

7382 #elif defined(NCBI_OS_UNIX) 7384

fl.l_type = F_UNLCK;

7386

fl.l_start =

m_Lock

->offset;

7387

fl.l_len =

m_Lock

->length;

7388

fl.l_pid = getpid();

7392

err = fcntl(

m_Handle

, F_SETLK, &fl);

7393

}

while

(err && (errno == EINTR));

7394  bool

res = (err == 0);

7427

on_off_default ==

eOn

);

ncbi::TMaskedQueryRegions mask

Class for support low level input/output for files.

static unsigned long GetVirtualMemoryAllocationGranularity(void)

Return size of an allocation unit (usually it is a multiple of page size).

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

CTmpStream(const char *s, FILE *file)

CTmpStream(const char *s, IOS_BASE::openmode mode)

virtual ~CTmpStream(void)

static string GetUserNameByUID(uid_t uid)

Look up user name by given numeric user ID.

static gid_t GetGroupGIDByName(const string &group)

Look up numeric group ID by symbolic group name.

static string GetGroupNameByGID(gid_t gid)

Look up group name by given numeric group ID.

static uid_t GetUserUIDByName(const string &user)

Look up numeric user ID by symbolic user name.

static bool GetFileOwner(const string &filename, string *owner, string *group, unsigned int *uid=0, unsigned int *gid=0)

Get file owner name.

static bool GetFilePermissions(const string &path, ACCESS_MASK *permissions)

Get file access permissions.

static bool SetFileOwner(const string &filename, const string &owner, const string &group=kEmptyStr, unsigned int *uid=0, unsigned int *gid=0)

Set file object owner.

A very basic data-read/write interface.

A very basic data-read interface.

A very basic data-write interface.

container_type::const_iterator const_iterator

container_type::iterator iterator

const_iterator end() const

const_iterator find(const key_type &key) const

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

main entry point for tests

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

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

static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)

static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)

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

static string s_Count(unsigned num, const string &item_name)

static string GetAppName(EAppNameType name_type=eBaseName, int argc=0, const char *const *argv=NULL)

#define ITERATE(Type, Var, Cont)

ITERATE macro to sequence through container elements.

ENormalizePath

Whether to normalize a path.

EFollowLinks

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

@ eNormalizePath

Normalize a path.

@ eNotNormalizePath

Do not normalize a path.

@ eIgnoreLinks

Do not follow symbolic links.

@ eFollowLinks

Follow symbolic links.

@ eFullName

per GetProgramExecutablePath(eIgnoreLinks)

@ eRealName

per GetProgramExecutablePath(eFollowLinks)

#define ERR_POST_X_ONCE(err_subcode, message)

Error posting only once during program execution with default error code and given error subcode.

#define ERR_POST_X(err_subcode, message)

Error posting with default error code and given error subcode.

static void SetFromWindowsError(void)

Set last error on MS Windows using GetLastError()

#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 Warning(CExceptionArgs_Base &args)

static void Set(ECode code)

Set last error using native error code enum.

int GetErrno(void) const noexcept

Get error number.

TErrCode GetErrCode(void) const

static void SetWindowsError(int native_err_code)

Set last error using Windows-specific error code.

TErrCode GetErrCode(void) const

virtual const char * GetErrCodeString(void) const

Get error code interpreted as text.

#define NCBI_REPORT_EXCEPTION_X(err_subcode, title, ex)

Generate a report on the exception with default error code and given subcode.

#define NCBI_CATCH_ALL(message)

This macro is deprecated - use *_X or *_XX variant instead of it.

static void SetErrno(int errno_code)

Set last error using errno code.

@ eTooManySymbolicLinkLevels

@ eUnknown

Unknown error.

void Close(void)

Close file.

EWho

Which default mode: user, group, or other.

unsigned int TCopyFlags

Binary OR of "ECopyFlags".

void * m_DataPtr

Pointer to the beginning of the mapped area.

EType

Directory entry type.

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

Normalize a path.

static string GetAppTmpDir(void)

Get temporary directory name for application.

TEntries GetEntries(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const

Get directory entries based on the specified "mask".

static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)

Get an absolute path from some, possibly relative, path.

static string x_ModeToSymbolicString(EWho who, TMode mode, bool special_bit, char filler)

Convert permission mode to symbolic string representation.

static TMode m_DefaultModeGlobal[eUnknown][4]

Holds default mode global values, per entry type.

virtual void SetDefaultMode(EType entry_type, TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)

Set default mode(s) for this entry only.

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

Get temporary file name.

static fstream * CreateTmpFile(const string &filename=kEmptyStr, ETextBinary text_binary=eBinary, EAllowRead allow_read=eAllowRead)

Create temporary file and return pointer to corresponding stream.

TFileHandle m_Handle

System file handle.

CFileReaderWriter(const string &filename, EOpenMode open_mode=eOpen, EShareMode share_mode=eShareRead)

Construct CFileReaderWriter for reading/writing to/from the file with name 'filename'.

static IReaderWriter * New(const string &filename, EOpenMode open_mode=eOpen, EShareMode share_mode=eShareRead)

Return a new IReaderWriter object corresponding to the given filename.

EOpenMode

Memory file open mode.

TSegments m_Segments

Map of pointers to mapped segments.

size_t Write(const void *buf, size_t count) const

Write file.

void DereferencePath(void)

Dereference a path.

static bool IsSupported(void)

Check if memory-mapping is supported by the C++ Toolkit on this platform.

string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const

Get the directory component for this directory entry.

TProcessingFlags TRemoveFlags

Flags based on TProcessingFlags.

int TIfAbsent2

Binary OR of "EIfAbsent2".

static bool IsPathSeparator(const char c)

Check whether a character "c" is a path separator symbol specific for the current platform.

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

Copy a file.

static Uint8 GetTotalDiskSpace(const string &path)

Get total disk space information.

void x_Extend(Uint8 size, Uint8 new_size)

Extend file size from 'size' to 'new_size' with zero bytes.

static bool IsAbsolutePath(const string &path)

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

void Flush(void) const

Flush file buffers.

bool GetMode(TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0) const

Get permission mode(s) of a directory entry.

TFlags m_Flags

General flags.

void Open(const string &filename, EOpenMode open_mode, EAccessMode access_mode, EShareMode share_mode=eShare)

Open file.

int TGetEntriesFlags

Binary OR of "EGetEntriesFlags".

static Uint8 GetUsedDiskSpace(const string &path)

Get used disk space information.

static void SetLogging(ESwitch on_off_default)

Enable or disable logging of errors from the File API classes.

void SetFileSize(Uint8 length, EPositionMoveMethod pos=eCurrent) const

Set new size for the file.

AutoPtr< SLock > m_Lock

Offset and length of the locked area.

unsigned int TCreateFlags

Binary OR of "ECreateFlags".

unsigned int TSpecialModeBits

Bitwise OR of ESpecialModeBits.

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

Virtual methods from IReader.

CNcbiIstream & AsInputFile(EIfExists if_exists, IOS_BASE::openmode mode=IOS_BASE::in)

Create I/O stream on the base of our file.

unique_ptr< CNcbiIstream > m_InFile

static string GetHome(EHomeWindows home=eHomeWindows_AppData)

Get user "home" directory.

unsigned int TMode

Bitwise OR of "EMode".

virtual bool Exists(void) const

Check the entry existence.

ETmpFileCreationMode

Temporary file creation mode.

TMode m_DefaultMode[4]

Holds default mode values.

static void SetDefaultModeGlobal(EType entry_type, TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)

Set default permission modes globally for all CDirEntry objects.

TOffsetType m_Offset

Requested starting offset of the.

virtual ERW_Result Flush(void)

Flush pending data (if any) down to the output device.

void x_Init(const char *filename, EType type, TOffsetType offset, size_t length)

Auxiliary method for constructors.

static string DeleteTrailingPathSeparator(const string &path)

Delete trailing path separator, if any.

void FindFiles(const string &pattern, std::list< string > &result, TFindFiles flags)

Utility function working like glob(): takes a pattern and fills the result list with files/directorie...

void x_Open(void)

Open file mapping for file with name m_FileName.

~CFileDeleteList()

Destructor removes all dir entries on list.

static string ModeToString(TMode user_mode, TMode group_mode, TMode other_mode, TSpecialModeBits special, EModeStringFormat format=eModeFormat_Default)

Convert permission modes to string representation using one of predefined formats.

EIfExists

What to do if stream already exists in the AsInputFile/AsOutputFile.

virtual const char * GetErrCodeString(void) const override

Translate from an error code value to its string representation.

void * Map(TOffsetType offset=0, size_t length=0)

Map file.

void * Map(TOffsetType offset, size_t length)

Map file segment.

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

unique_ptr< CNcbiOstream > m_OutFile

void Unlock(void)

Unlock file.

bool m_CloseHandle

Need to close file handle in destructor.

EIfEmptyPath

What GetDir() should return if the dir entry does not contain path.

TOffsetType GetOffset(void) const

Get offset of the mapped area from beginning of file.

CMemoryFileMap(const string &file_name, EMemMapProtect protect_attr=eMMP_Read, EMemMapShare share_attr=eMMS_Shared, EOpenMode mode=eDefault, Uint8 max_file_len=0)

Constructor.

void x_Create(Uint8 size)

Create new file or rewrite existent with zeros.

static mode_t MakeModeT(TMode user_mode, TMode group_mode, TMode other_mode, TSpecialModeBits special)

Construct mode_t value from permission modes.

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.

static string GetTmpDir(void)

Get temporary directory.

static void SetUmask(TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)

Set file/directory mode creation mask.

Int8 GetLength(void) const

Get size of file.

bool Backup(const string &suffix=kEmptyStr, EBackupMode mode=eBackup_Default, TCopyFlags copyflags=fCF_Default, size_t copybufsize=0)

Backup an entry.

static void SetHonorUmask(ESwitch on_off_default)

Enable or disable honoring umask settings on Unix for newly created files/directories in the File API...

bool CreatePath(TCreateFlags flags=fCreate_Default) const

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

static void GetFileSystemInfo(const string &path, SFileSystemInfo *info)

Get file system information.

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

Rename entry.

bool IsNewer(time_t tm, EIfAbsent if_absent) const

Check if the current entry is newer than a specified date/time.

void CreateTemporary(const string &dir, const string &prefix, EAutoRemove auto_remove=eRemoveInClose)

Create temporary file in the specified directory.

bool GetTimeT(time_t *modification, time_t *last_access=0, time_t *creation=0) const

Get time stamp(s) of a directory entry (time_t version).

void DereferenceLink(ENormalizePath normalize=eNormalizePath)

Dereference a link.

static bool StringToMode(const CTempString &mode, TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)

Convert string (in one of predefined formats, detects automatically) to permission mode(s).

virtual bool Remove(TRemoveFlags flags=eRecursive) const

Remove a directory entry.

static fstream * CreateTmpFileEx(const string &dir=".", const string &prefix=kEmptyStr, ETextBinary text_binary=eBinary, EAllowRead allow_read=eAllowRead)

Create temporary file and return pointer to corresponding stream.

virtual ~CDirEntry(void)

Destructor.

string LookupLink(void) const

Get an entry name that a link points to.

static void ModeFromModeT(mode_t mode, TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)

Convert mode_t to permission mode(s).

Uint8 GetFileSize(void) const

Get file size.

static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)

Assemble a path from basic components.

EIfAbsent

What IsNewer() should do if the dir entry does not exist or is not accessible.

void * m_DataPtrReal

Real pointer to the beginning of the mapped area which should be fried later.

static void GetDefaultModeGlobal(EType entry_type, TMode *user_mode, TMode *group_mode, TMode *other_mode, TSpecialModeBits *special)

Get the default global mode.

EHomeWindows

Windows specific: Historically, we try to use APPDATA% first, and use USERPROFILE% as a fallback to d...

EAccessMode

Which I/O operations permitted on the file.

static Uint8 GetFreeDiskSpace(const string &path)

Get free disk space information.

CNcbiOstream & AsOutputFile(EIfExists if_exists, IOS_BASE::openmode mode=IOS_BASE::out)

void SetFileHandle(TFileHandle handle)

Close previous handle if needed and use given handle for all I/O.

bool Unmap(void)

Unmap file if mapped.

virtual const char * GetErrCodeString(void) const override

Translate from an error code value to its string representation.

void * GetPtr(void) const

Get pointer to beginning of data.

bool Compare(const string &file, size_t buf_size=0) const

Compare files contents in binary form.

static void Add(const string &path)

Add the name of a dir entry; it will be deleted on (normal) exit.

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

Copy link.

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 CheckAccess(TMode access_mode) const

Check access rights.

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.

void Lock(EType type, TOffsetType offset=0, size_t length=0)

Lock file.

Int8 GetFileSize(void) const

Get length of the mapped file.

static string CreateRelativePath(const string &path_from, const string &path_to)

Create a relative path between two points in the file system specified by their absolute paths.

void * Extend(size_t new_lendth=0)

Extend length of the mapped region.

bool IsDir(EFollowLinks follow=eFollowLinks) const

Check whether a directory entry is a directory.

void x_Verify(void) const

static IReader * New(const string &filename, EShareMode share_mode=eShareRead)

Return a new IReader object corresponding to the given filename, taking "-" (but not "....

~CFileIO(void)

Destruct object closing system handle if necessary.

SCompareDirEntries(ESort s1=ePath)

You can sort by up to 3 path components.

EOpenMode

File open mode.

CMemoryFile_Base(void)

Constructor.

void x_Verify(void) const

size_t m_Length

Requested length of the mapped area.

CMemoryFile(const string &file_name, EMemMapProtect protect_attr=eMMP_Read, EMemMapShare share_attr=eMMS_Shared, TOffsetType offset=0, size_t lendth=0, EOpenMode mode=eDefault, Uint8 max_file_len=0)

Constructor.

EFileSystemType

Unix: The path name to any file/dir withing file system.

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

Get an entry owner.

CFileReader(const string &filename, EShareMode share_mode=eShareRead)

Construct CFileReader for reading from the file with name 'filename'.

bool CompareTextContents(const string &file, ECompareText mode, size_t buf_size=0) const

Compare files contents in text form.

unsigned int TRenameFlags

Binary OR of "ERenameFlags".

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

Virtual methods from IReaderWriter.

TNcbiSys_stat orig

Original stat structure.

const string & GetFileName(void) const

Return used file name (generated or given in the constructor).

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

Concatenate two parts of the path for any OS.

CMemoryFileSegment * x_GetMemoryFileSegment(void *ptr) const

Get pointer to memory mapped file segment by pointer to data.

string m_FileName

Name of temporary file.

bool Create(const string &path) const

Create symbolic link.

void GetDefaultMode(TMode *user_mode, TMode *group_mode, TMode *other_mode, TSpecialModeBits *special) const

Get the default mode.

TProcessingFlags TSetModeFlags

bool Flush(void) const

Flush by writing all modified copies of memory pages to the underlying file.

static void SetDeleteReadOnlyFiles(ESwitch on_off_default)

Specify whether read-only files can be deleted via CDirEntry::Remove() on Windows.

virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)

Virtual methods from IWriter.

static string ConvertToOSPath(const string &path)

Convert "path" on any OS to the current OS-dependent path.

static char GetPathSeparator(void)

Get path separator symbol specific for the current platform.

static string GetTmpName(ETmpFileCreationMode mode=eTmpFileGetName)

Get temporary file name.

bool Unmap(void *ptr)

Unmap file segment.

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

Concatenate two parts of the path for the current OS.

CFileIO(void)

Default constructor.

static string GetNearestExistingParentDir(const string &path)

Given a path, gets the closest parent directory which actually exists.

CTmpFile(ERemoveMode remove_file=eRemove)

Default constructor.

~CFileLock(void)

Destruct the CFileLock, close file and remove all locks if necessary.

virtual bool RemoveEntry(TRemoveFlags flags=eEntryOnly) const

Remove a directory entry.

bool SetTimeT(const time_t *modification=0, const time_t *last_access=0, const time_t *creation=0) const

Set time stamp(s) of a directory entry (time_t version).

ERelativeToWhat

How to interpret relative paths.

mode_t GetDefaultModeT(void) const

void * m_Ptr

Pointer to mapped view of file.

bool operator()(const CDir::TEntry &e1, const CDir::TEntry &e2)

Comparison operators.

virtual ~CFile(void)

Destructor.

bool IsIdentical(const string &entry_name, EFollowLinks follow_links=eIgnoreLinks) const

Check if the current entry and the given entry_name are identical.

~CTmpFile(void)

Destructor.

EAutoRemove

Controls how temporary file is removed.

void Reset(const string &path)

Reset path string.

ETextBinary

What type of temporary file to create.

CMemoryFileSegment(SMemoryFileHandle &handle, SMemoryFileAttrs &attrs, TOffsetType offset, size_t length)

Constructor.

bool CopyToDir(const string &dir, TCopyFlags flags=fCF_Default, size_t buf_size=0) const

Copy the entry to a specified directory.

ERemoveMode m_RemoveOnDestruction

Remove file on destruction.

virtual ~CSymLink(void)

Destructor.

EAutoRemove m_AutoRemove

When (if ever) should the temporary file be removed.

static bool IsAbsolutePathEx(const string &path)

Check if the "path" is absolute for any OS.

TOffsetType m_OffsetReal

Corrected starting offset of the.

virtual ~CDir(void)

Destructor.

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

Get status information on a dir entry.

bool Create(TCreateFlags flags=fCreate_Default) const

Create the directory using "dirname" passed in the constructor.

static const char * m_BackupSuffix

Backup suffix.

CFileLock(const string &filename, TFlags flags=fDefault, EType type=eShared, TOffsetType offset=0, size_t length=0)

Construct CFileLock for locking a file with a given name 'filename'.

virtual bool SetModeEntry(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.

ECompareText

Mode to compare streams in text form.

static bool MatchesMask(const string &name, const string &mask, NStr::ECase use_case=NStr::eCase)

Match a "name" against a simple filename "mask".

virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)

Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.

string m_FileName

File name.

Uint8 GetFilePos(void) const

Get file position.

EMemMapShare

Whether to share changes or not.

static const char * GetBackupSuffix(void)

Get backup suffix.

virtual ERW_Result Flush(void)

Flush pending data (if any) down to the output device.

static string GetCwd(void)

Get the current working directory.

unsigned int TFlags

Binary OR of "EFlags".

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) for a directory.

static void GetUmask(TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)

Get file/directory mode creation mask.

string m_Path

Full path of this directory entry.

CFileWriter(const string &filename, EOpenMode open_mode=eCreate, EShareMode share_mode=eShareRead)

Construct CFileWriter for writing to the file with name 'filename'.

void SetFilePos(Uint8 position) const

Set file position from beginning of the file.

EShareMode

Sharing mode for opened file.

CDirEntry & operator=(const CDirEntry &other)

Assignment operator.

static IWriter * New(const string &filename, EOpenMode open_mode=eCreate, EShareMode share_mode=eShareRead)

Return a new IWriter object corresponding to the given filename, taking "-" (but not "....

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

Copy directory.

size_t Read(void *buf, size_t count) const

Read file.

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.

int TFindFiles

Bitwise OR of "EFindFiles".

static bool SetCwd(const string &dir)

Change the current working directory.

TEntries * GetEntriesPtr(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const

Get directory entries based on the specified "mask".

void x_Close(void)

Unmap mapped memory and close mapped file.

bool m_AutoClose

Need to close file handle in destructor.

void * GetPtr(void) const

Get pointer to beginning of data.

virtual bool Remove(TRemoveFlags flags=eRecursive) const

Delete existing directory.

EMemMapProtect

Which operations are permitted in memory map file.

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

Get time stamp(s) of a directory entry.

~CMemoryFileMap(void)

Destructor.

const string & GetPathname(void) const

Return file path and name as it was specified in the Open() method or created in CreateTemporary().

string m_Pathname

File path and name.

bool UnmapAll(void)

Unmap all mapped segment.

EPositionMoveMethod

Which starting point to use for the moves of the file pointer.

const string & GetPath(void) const

Get entry path.

bool m_IsLocked

Lock established.

size_t m_LengthReal

Corrected length of the mapped area.

EAllowRead

Which operations to allow on temporary file.

TFileHandle m_Handle

System file handle.

static const CFileDeleteList & GetDeleteList()

Get underlying static CFileDeleteList object.

ERemoveMode

What to do with the file on object destruction.

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

EBackupMode

Backup modes.

static void SetDeleteList(CFileDeleteList &list)

Set the underlying static CFileDeleteList object.

const HANDLE kInvalidHandle

static void SplitPathEx(const string &path, string *disk=0, string *dir=0, string *base=0, string *ext=0)

Split a path string into its basic components.

~CMemoryFileSegment(void)

Destructor.

bool IsLink(void) const

Check whether a directory entry is a symbolic link (alias).

virtual bool Exists(void) const

Check existence of file.

EModeStringFormat

Permission mode string format.

SMemoryFileAttrs * m_Attrs

Specify operations permitted on memory mapped file and mapping mode.

bool Unmap(void)

Unmap file view from memory.

SMemoryFileHandle * m_Handle

Memory file handle.

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

static void SplitPath(const string &path, string *dir=0, string *base=0, string *ext=0)

Split a path string into its basic components.

@ eSocket

Socket (UNIX only)

@ eBlockSpecial

Block special (UNIX only)

@ eLink

Symbolic link (UNIX only)

@ eCharSpecial

Character special.

@ fModeAdd

Adds the argument permission mode to the entry's current mode.

@ fModeRemove

Removes the argument permission mode from the entry's current mode.

@ fModeNoChange

Do not change permission mode.

@ eExtend

Extend file size with zeros if it exist, throw exception otherwise.

@ eCreate

Create new file or rewrite existent with zeros.

@ fRF_Overwrite

Remove destination if it exists.

@ fRF_FollowLinks

Rename entries following sym.links, not the links themselves.

@ fRF_EqualTypes

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

@ fRF_Backup

Backup destination if it exists before renaming.

@ fRF_Update

Update older entries only (compare modification times).

@ eTmpFileCreate

Create empty file for each GetTmpName* call.

@ eIfExists_Throw

You can make call of AsInputFile/AsOutputFile only once, on each following call throws CFileException...

@ eIfExists_Reset

Delete previous stream and return reference to new object.

@ eIfExists_ReturnCurrent

Return reference to current stream, create new one if it does not exists yet.

@ eIfEmptyPath_Current

Return current dir like "./".

@ fAutoUnlock

Automatically remove all obtained locks in the destructor.

@ fLockNow

Lock file using parameters specified in constructor.

@ fCF_Verify

Verify data after copying.

@ fCF_FollowLinks

Copy entries following their sym.links, not the links themselves.

@ fCF_TopDirOnly

All above flags can be applied to the top directory only (not for every file therein),...

@ fCF_Overwrite

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

@ fCF_PreserveTime

Preserve date/times.

@ fCF_Safe

Safe copy (copy to temporary object and rename).

@ fCF_Recursive

Copy recursively (for dir only)

@ fCF_EqualTypes

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

@ fCF_PreservePerm

Preserve permissions/attributes.

@ fCF_SkipUnsupported

Skip all entries for which we don't have Copy() method.

@ fCF_PreserveOwner

Preserve owner/group.

@ eIfAbsent_Throw

Throw an exception.

@ eIfAbsent_Newer

Deem absent entry to be "newer".

@ eIfAbsent_NotNewer

Deem absent entry to be "older".

@ eRead

File can be read.

@ eReadWrite

File can be read and written.

@ eWrite

File can be written.

@ fFF_Recursive

descend into sub-dirs

@ fFF_All

find files and directories (used automatically if fFF_File or fFF_Dir has not specified)

@ fFF_Dir

find directories

@ ePath

Sort by full path (default)

@ eOpen

Open an existing file, or create a new one.

@ eTruncate

Open an existing file and truncate its size to 0.

@ eCreate

Create a new file, or truncate an existing one.

@ eCreateNew

Open an existing file, or fail if the file does not exist.

@ eSELINUX

Security-Enhanced Linux (SELinux)

@ eNTFS

New Technology File System.

@ ePVFS2

Parallel Virtual File System.

@ eFFS

Fast File System (*BSD)

@ eJFFS2

Journalling Flash File System v2.

@ eHFS

Hierarchical File System.

@ eCDFS

ISO 9660 CD-ROM file system (CDFS/ISO9660)

@ eCODA

Coda File System.

@ eFDFS

File Descriptor File System.

@ eJFS

Journalling File System.

@ eExt

Extended file system.

@ eJFFS

Journalling Flash File System.

@ eFAT

Traditional 8.3 MSDOS-style file system.

@ eVxFS

VERITAS File System (VxFS)

@ eGPFS

IBM General Parallel File System.

@ eNFS

Network File System (NFS)

@ eUBIFS

The Unsorted Block Image File System.

@ eSMBFS

Samba File System.

@ eEXOFS

EXtended Object File System (EXOFS)

@ eOCFS2

Oracle Cluster File System 2.

@ eMFS

Memory File System.

@ eTMPFS

Virtual Memory File System (TMPFS/SHMFS)

@ eMSFS

Mail Slot File System.

@ eXENIX

Xenix (SysV) file system.

@ eHFSPLUS

Hierarchical File System.

@ eSquashFS

Compressed read-only filesystem (Linux)

@ eV7

UNIX V7 File System.

@ eReiserFS

Reiser File System.

@ eExt2

Second Extended file system.

@ eOPENPROM

/proc/openprom filesystem

@ eHSFS

High Sierra File System.

@ eCacheFS

Cache File System.

@ eFUSE

Filesystem in Userspace (FUSE)

@ eUnknown

File system type could not be determined.

@ eHPFS

OS/2 High-Performance File System.

@ ePROC

/proc file system

@ eEFS

The Encrypting File System (EFS) (MSWin)

@ eAUTOFS

Automount File System.

@ eVZFS

Virtuozzo File System (VZFS)

@ eDFS

DCE Distributed File System (DCE/DFS)

@ eFFM

File-on-File Mounting file system.

@ eQNX4

QNX4 file system.

@ eNCPFS

NetWare Core Protocol File System.

@ eSPECFS

SPECial File System.

@ eADFS

Acorn's Advanced Disc Filing System.

@ eUDF

Universal Disk Format.

@ eGFS2

Global File System.

@ eRFS

Remote File Share file system (AT&T RFS)

@ eLOFS

Loopback File System.

@ eDEVFS

Device File System.

@ eFAT32

FAT32 file system.

@ eUSBDEVICE

USBDevice file system.

@ eAFFS

Amiga Fast File System.

@ eExt3

Journalled form of ext2.

@ eUFS2

UNIX File System.

@ eAdvFS

Tru64 UNIX Advanced File System.

@ eFUSE_CTL

Fusectl (helper filesystem for FUSE)

@ eCryptFS

eCryptfs (Enterprise Cryptographic Filesystem)

@ eCRAMFS

Compressed ROMFS.

@ eCIFS

Common Internet File System.

@ eCOH

Coherent (System V)

@ eROMFS

ROM File System.

@ eExclusive

"write" lock.

@ eRelativeToCwd

Relative to the current working directory.

@ eRelativeToExe

Relative to the executable's location.

@ eRemoveInClose

Remove temporary file immediately after closing its handle in Close().

@ eRemoveASAP

Remove the file at the earliest possible moment (in CreateTemporary() on UNIX).

@ eDoNotRemove

Do not ever remove temporary file.

@ eBinary

Create binary file.

@ fDefaultUser

Default user permission for a file.

@ fDefault

Special flag: ignore all other flags, use current default mode.

@ fDefaultDirUser

Default user permission for a dir.

@ fExecute

Execute / List(directory) permission.

@ fDefaultOther

Default other permission for a file.

@ fDefaultGroup

Default group permission for a file.

@ fWrite

Write permission.

@ fDefaultDirGroup

Default group permission for a dir.

@ fDefaultDirOther

Default other permission for a dir.

@ fCreate_PermAsParent

Use same permissions as parent directory (umask ignored)

@ fCreate_Default

Default directory creation mode.

@ fCreate_ErrorIfExists

Error, if directory already exists.

@ fCreate_UpdateIfExists

Allow to "update" permissions for already existent directory using default, umask or parent permissio...

@ fCreate_PermByUmask

Don't change permissions after creation, leave it for OS and umask control.

@ eMMS_Private

Changes are private (write do not change file)

@ eMMS_Shared

Changes are shared.

@ fNoThisHasPath_NotNewer

@ fHasThisNoPath_NotNewer

@ eExclusive

Open file for exclusive access.

@ eShareWrite

Enables subsequent open operations on the file that request write access.

@ eShareRead

Enables subsequent open operations on the file that request read access.

@ eShare

Combines both eShareRead and eShareWrite modes.

@ fIgnorePath

Return only names of entries, not their full paths.

@ fCreateObjects

Create appropriate subclasses of CDirEntry (CFile,CDir,...), not just CDirEntry objects.

@ eMMP_Write

Data can be written.

@ eMMP_Read

Data can be read.

@ eMMP_ReadWrite

Data can be read and written.

@ eBegin

Absolute position from beginning of the file.

@ eCurrent

Relative to current position.

@ eEnd

The starting point is the current EOF position.

@ eAllowRead

Allow read and write.

@ fIgnoreMissing

Ignore missed entries.

@ eRecursive

Process all files and subdirectories recursively.

@ fDir_Subdirs

Subdirectory entries (non recursive)

@ fDir_Files

Non-directory entries.

@ eOnlyEmpty

Directory entry only, no other files or subdirectories.

@ fEntry

Current entry only.

@ fDir_Recursive

Add a recursion.

@ fDir_Self

Top directory entry.

@ fProcessAll

Process all entries.

@ fDir_All

Mask to check what should be processed in a directory.

@ eRecursiveIgnoreMissing

Same as eRecursive, but do not report an error for disappeared entries (e.g.

@ eBackup_Copy

Copy entry.

@ eBackup_Rename

Rename entry.

@ eModeFormat_Symbolic

Shell symbolic format ("u=rwx,g=rwx,o=rx")

@ eModeFormat_Octal

Octal format ("664")

@ eModeFormat_List

Shell list 'ls -l' like format ("rwxrwxrwx")

#define NCBI_PARAM_TYPE(section, name)

Generate typename for a parameter from its {section, name} attributes.

@ eParam_NoThread

Do not use per-thread values.

int64_t Int8

8-byte (64-bit) signed integer

uint64_t Uint8

8-byte (64-bit) unsigned integer

ncbi_numeric_limits< T > get_limits(const T &)

Generic template to get STD limits by a variable.

static TPid GetPid(void)

Get process identifier (pid) for the current process.

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

ECompareTextMode

Mode to compare streams in text form.

IO_PREFIX::istream CNcbiIstream

Portable alias for istream.

IO_PREFIX::ifstream CNcbiIfstream

Portable alias for ifstream.

bool NcbiStreamCompareText(CNcbiIstream &is1, CNcbiIstream &is2, ECompareTextMode mode, size_t buf_size=0)

Compare stream contents in text form.

@ eRW_NotImplemented

Action / information is not available.

@ 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 Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)

Convert Int8 to string.

static CTempString TruncateSpaces_Unsafe(const CTempString str, ETrunc where=eTrunc_Both)

Truncate whitespace in a 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 TNumeric StringToNumeric(const CTempString str, TStringToNumFlags flags=0, int base=10)

Convert string to a numeric value.

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

Convert int to string.

static string Join(const TContainer &arr, const CTempString &delim)

Join strings using the specified delimiter.

static int Compare(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)

Compare of a substring with another string.

size_type find_last_of(const CTempString match, size_type pos=npos) const

Find the last occurrence of any character in the matching string within the current string,...

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

Convert string to Uint8.

static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)

Split a string into two pieces using the specified delimiters.

static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)

Convert string to unsigned int.

CTempString substr(size_type pos) const

Obtain a substring from this string, beginning at a given offset.

static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)

Case-insensitive equality of a substring with another string.

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 string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)

Truncate whitespace in a string.

const char *const kEmptyCStr

Empty "C" string (points to a '\0').

size_type size(void) const

Return the length of the represented array.

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

Case-sensitive compare of a substring with another string.

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

Convert UInt8 to string.

@ fConvErr_NoThrow

Do not throw an exception on error.

@ fSplit_MergeDelimiters

Merge adjacent delimiters.

@ eNocase

Case insensitive compare.

@ eCase

Case sensitive compare.

#define DEFINE_STATIC_FAST_MUTEX(id)

Define static fast mutex and initialize it.

static TThreadSystemID GetCurrentThreadSystemID(void)

Get the current thread ID.

long NanoSecond(void) const

Get nano-seconds.

const long kMilliSecondsPerSecond

Number milliseconds in one second.

time_t GetTimeT(void) const

Get time in time_t format.

void SetNanoSecond(long nanosecond)

Set nanoseconds.

CTime & SetTimeT(const time_t t)

Set time using time_t time value.

CTime GetGmtTime(void) const

const long kMicroSecondsPerSecond

Number of microseconds in one second.

const long kNanoSecondsPerSecond

Number of nanoseconds in one second.

enum ENcbiSwitch ESwitch

Aux.

virtual bool Match(CTempString str, NStr::ECase use_case=NStr::eCase) const =0

Match a string.

void Add(const string &mask)

Add an inclusion mask.

#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 corelib (xncbi.lib).

The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format

if(yy_accept[yy_current_state])

constexpr bool empty(list< Ts... >) noexcept

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

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

static size_t x_size(const char *dst, size_t len, const char *ptr)

Defines MS Windows specific private functions and classes.

Private UNIX specific features.

Defines interface to ncbi_panfs.so to get information about PANFS mounts.

Static variables safety - create on demand, destroy on application termination.

#define TRUE

bool replacment for C indicating true.

#define FALSE

bool replacment for C indicating false.

#define NCBI_PLATFORM_BITS

Defines NCBI C++ Toolkit portable error codes.

static const SFileSystem s_FileSystem[]

#define NCBI_IS_TYPE(mode, mask)

Test macro for file types.

#define LOG_ERROR_NCBI(subcode, log_message, ncbierr)

#define F_ISSET(flags, mask)

#define LOG_ERROR_WIN(subcode, log_message)

const size_t kDefaultBufferSize

static bool s_GetHomeByLOGIN(string &home)

void x_Glob(const string &path, const std::list< string > &parts, std::list< string >::const_iterator next, std::list< string > &result, TFindFiles flags)

#define ALL_OS_SEPARATORS

#define LOG_ERROR_ERRNO(subcode, log_message)

#define UPDATE_PERMS(mode, perms)

void s_UnixTimeToFileTime(time_t t, long nanosec, FILETIME &filetime)

static CSafeStatic< CFileDeleteList > s_DeleteAtExitFileList

int TFileSystemInfo

Binary OR of "EFileSystemInfo".

bool s_Win_IsDiskPath(const string &path)

NCBI_PARAM_DECL(string, NCBI, TmpDir)

static void s_AddEntry(CDir::TEntries *contents, const string &base_path, const WIN32_FIND_DATA &entry, CDir::TGetEntriesFlags flags)

EFileSystemInfo

Flags to get information about file system.

@ fFSI_BlockSize

block_size

@ fFSI_FileNameMax

filename_max

@ fFSI_All

get all possible information

@ fFSI_DiskSpace

total_space, free_space

void s_GetFileSystemInfo(const string &path, CFileUtil::SFileSystemInfo *info, TFileSystemInfo flags)

#define F_CLEAN_REDUNDANT(group)

void s_DereferencePath(CDirEntry &entry)

#define WIN_LAST_ERROR_STR

static bool s_GetHomeByUID(string &home)

#define DIR_PARTS_CMP_MODE

#define DEFAULT_HONOR_UMASK_VALUE

@ eIfExists_Reset

Delete previous stream and return reference to new object.

@ eIfExists_Throw

You can make call of AsInputFile/AsOutputFile only once, on each following call throws CFileException...

@ eIfExists_ReturnCurrent

Return reference to current stream, or new if this is first call.

NCBI_PARAM_DEF_EX(bool, NCBI, DeleteReadOnlyFiles, false, eParam_NoThread, NCBI_CONFIG__DELETEREADONLYFILES)

static void s_SetFindFileError(DWORD err)

static bool s_CheckAccessStat(struct stat *p, int mode)

#define CLOSE_PIPE_END(fd)

static void s_StripDir(const string &dir, vector< string > *dir_parts)

Helper – strips dir to parts: c: \ will be <c:> /usr/bin/ will be </><usr><bin>

#define DEFAULT_LOGGING_VALUE

void s_GetDiskSpace_PANFS(const string &path, CFileUtil::SFileSystemInfo *info)

#define _no_warning(expr)

#define DIR_SEPARATOR_ALT

bool s_Win_IsNetworkPath(const string &path)

static const char * kTmpSafeSuffix

#define UNDEFINED_SORT_MODE

static bool s_CopyAttrs(const char *from, const char *to, CDirEntry::EType type, CDirEntry::TCopyFlags flags)

bool s_FileTimeToCTime(const FILETIME &filetime, CTime &t)

#define IS_RECURSIVE_ENTRY

static void s_PipeExit(int status, int fd)

int s_FTruncate(int fd, Uint8 new_size)

static bool s_CheckAccessPath(const char *path, int mode)

static SMemoryFileAttrs * s_TranslateAttrs(CMemoryFile_Base::EMemMapProtect protect_attr, CMemoryFile_Base::EMemMapShare share_attr)

int s_FExtend(int fd, Uint8 new_size)

NCBI_PARAM_DEF(string, NCBI, TmpDir, "")

#define LOG_ERROR(subcode, log_message)

bool s_DirCreate(const string &path, CDir::TCreateFlags flags, mode_t mode)

Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...

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

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

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

struct _fstat64 TNcbiSys_fstat

struct _stat64 TNcbiSys_stat

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

Structure to store information about file system.

CFileUtil::EFileSystemType type

void Reset(CFileLock::TOffsetType off, size_t len)

SLock(CFileLock::TOffsetType off, size_t len)


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