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] ==
'/') {
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.length();
803 if ( sep_pos !=
NPOS ) {
804 sep = path.at(sep_pos);
810 if ( part.length() > 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() ) {
901 #ifdef DISK_SEPARATOR
908 }
else if (
next.empty()) {
911 #ifdef DISK_SEPARATOR
918 #ifdef DISK_SEPARATOR
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);
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;
1554 ITERATE(
string, s, accessor) {
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();
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);
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 ) {
1886 if ( last_access ) {
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(), ×) != 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(), ×) != 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;
2265 #ifdef NCBI_OS_MSWIN
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);
2667 if ( !entry.
GetTime(&entry_time) ) {
2671 return this_time > entry_time;
2694 "Directory entry does not exist");
2712 "Directory entry does not exist");
2715 return current > tm;
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) ) {
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);
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";
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;
3075 tvp[1].tv_sec = st.
orig.st_mtime;
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, ×)) {
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);
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;
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);
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)
3641 #elif defined(NCBI_OS_UNIX)
3664 #if defined(NCBI_OS_UNIX)
3666 char* tmpdir = getenv(
"TMPDIR");
3670 # if defined(P_tmpdir)
3677 #elif defined(NCBI_OS_MSWIN)
3683 # if defined(P_tmpdir)
3700 if ( !
tmp.empty() ) {
3722 LOG_ERROR_ERRNO(51,
"CDir::SetCwd(): Cannot change directory to: " + dir);
3736 const vector<string>& masks,
3739 if ( masks.empty() ) {
3742 ITERATE(vector<string>, itm, masks) {
3743 const string&
mask = *itm;
3754 #if defined(NCBI_OS_MSWIN)
3764 ::SetLastError(err);
3766 case ERROR_NO_MORE_FILES:
3767 case ERROR_FILE_NOT_FOUND:
3768 case ERROR_PATH_NOT_FOUND:
3771 case ERROR_NOT_ENOUGH_MEMORY:
3774 case ERROR_ACCESS_DENIED:
3783 # define IS_RECURSIVE_ENTRY \
3784 ( (flags & CDir::fIgnoreRecursive) && \
3785 ((NcbiSys_strcmp(entry.cFileName, _TX(".")) == 0) || \
3786 (NcbiSys_strcmp(entry.cFileName, _TX("..")) == 0)) )
3789 const string& base_path,
3790 const WIN32_FIND_DATA& entry,
3802 contents->push_back(
new CDirEntry(name));
3808 # define IS_RECURSIVE_ENTRY \
3809 ( (flags & CDir::fIgnoreRecursive) && \
3810 ((::strcmp(entry->d_name, ".") == 0) || \
3811 (::strcmp(entry->d_name, "..") == 0)) )
3814 const string& base_path,
3815 const struct dirent* entry,
3822 # if defined(_DIRENT_HAVE_D_TYPE)
3824 if (entry->d_type) {
3825 st.st_mode = DTTOIF(entry->d_type);
3831 const string path = base_path + entry->d_name;
3839 contents->push_back(
new CDirEntry(name));
3849 if ( !
mask.empty() ) {
3852 return GetEntries(masks,
flags);
3859 if ( !
mask.empty() ) {
3862 return GetEntriesPtr(masks,
flags);
3868 unique_ptr<TEntries> contents(GetEntriesPtr(masks,
flags));
3869 return contents.get() ? *contents.get() :
TEntries();
3875 if ( masks.empty() ) {
3882 #if defined(NCBI_OS_MSWIN)
3885 string pattern = base_path +
"*";
3887 WIN32_FIND_DATA entry;
3890 handle = ::FindFirstFile(
_T_XCSTRING(pattern), &entry);
3895 ITERATE(vector<string>, it, masks) {
3896 const string&
mask = *it;
3897 if (
mask.empty() ||
3904 }
while (::FindNextFile(handle, &entry));
3906 ::FindClose(handle);
3909 DWORD err = ::GetLastError();
3919 #elif defined(NCBI_OS_UNIX)
3921 DIR* dir = opendir(base_path.c_str());
3930 while (
struct dirent* entry = readdir(dir)) {
3934 ITERATE(vector<string>, it, masks) {
3935 const string&
mask = *it;
3953 unique_ptr<TEntries> contents(GetEntriesPtr(masks,
flags));
3954 return contents.get() ? *contents.get() :
TEntries();
3964 #if defined(NCBI_OS_MSWIN)
3967 string pattern = base_path +
"*";
3969 WIN32_FIND_DATA entry;
3972 handle = ::FindFirstFile(
_T_XCSTRING(pattern), &entry);
3979 }
while ( ::FindNextFile(handle, &entry) );
3981 ::FindClose(handle);
3984 DWORD err = ::GetLastError();
3994 #elif defined(NCBI_OS_UNIX)
3996 DIR* dir = opendir(base_path.c_str());
4005 while (
struct dirent* entry = readdir(dir)) {
4007 masks.
Match(entry->d_name, use_case) ) {
4024 #if defined(NCBI_OS_MSWIN)
4026 #elif defined(NCBI_OS_UNIX)
4030 if (errno != EEXIST) {
4031 LOG_ERROR_ERRNO(52,
"s_DirCreate(): Cannot create directory: " + path);
4064 LOG_ERROR_ERRNO(55,
"CDir::Create(): Cannot set mode for directory: " + path);
4082 string path_up(d.
GetDir());
4083 if ( path_up.empty() || path_up == d.
GetPath() ) {
4088 #if defined(NCBI_OS_MSWIN)
4091 if (path_up.length() > 3) {
4119 && path.length() != 3
4123 path.erase(path.length() - 1);
4129 std::list<CTempString> missed_parts;
4137 missed_parts.push_front(part);
4146 if (missed_parts.empty()) {
4151 #if defined(NCBI_OS_MSWIN)
4153 if (parent.length() == 2) {
4159 LOG_ERROR_ERRNO(61,
"CDir::CreatePath(): stat() failed for: " + parent);
4166 if (missed_parts.empty()) {
4177 for (
auto i : missed_parts) {
4202 if ( src_type !=
eDir ) {
4208 bool dst_exists = (dst_type !=
eUnknown);
4209 bool need_create_dst = !dst_exists;
4210 string dst_safe_path;
4252 LOG_ERROR(66,
"CDir::Copy(): Cannot backup destination directory: " + dst.
GetPath());
4255 need_create_dst =
true;
4266 if ( need_safe_copy ) {
4268 string path, name, ext;
4272 dst_safe_path = dst.
GetPath();
4274 need_create_dst =
true;
4280 if ( need_create_dst ) {
4282 LOG_ERROR(67,
"CDir::Copy(): Cannot create " <<
4283 (dst_safe_path.empty() ?
"target" :
"temporary") <<
4284 " directory: " << dst.
GetPath());
4291 if ( !contents.get() ) {
4305 LOG_ERROR(69,
"CDir::Copy(): Cannot copy " +
4312 if (!dst_safe_path.empty()) {
4315 LOG_ERROR(70,
"CDir:Copy(): Cannot rename temporary directory " +
4316 dst.
GetPath() +
" to " + dst_safe_path);
4324 LOG_ERROR(98,
"CDir:Copy(): Cannot copy attributes from " +
4333 LOG_ERROR(99,
"CDir:Copy(): Cannot set default directory permissions: " + dst.
GetPath());
4354 LOG_ERROR_ERRNO(71,
"CDir::Remove(): Cannot remove (by implication empty)"
4361 #if !defined(NCBI_OS_MSWIN)
4369 unique_ptr<TEntries> contents(GetEntriesPtr());
4370 if (!contents.get()) {
4375 bool success =
true;
4379 string name = (*entry)->GetName();
4380 if (name ==
"." || name ==
".." || name ==
string(1,
GetPathSeparator())) {
4396 throw "Removing subdirectory failed";
4405 throw "Removing directory entry failed";
4419 throw "Removing directory entry (non-recursive) failed";
4445 throw "Cannot remove directory entry";
4449 catch (
const char* what) {
4452 LOG_ERROR(73,
"CDir::Remove(): Cannot remove directory: " +
GetPath() +
": " + what);
4473 unique_ptr<TEntries> contents(GetEntriesPtr());
4474 if (!contents.get()) {
4479 bool success =
true;
4483 string name = (*entry)->GetName();
4484 if (name ==
"." || name ==
".." ||
4499 throw "Changing mode for subdirectory failed";
4504 if (!item.
SetModeEntry(user_mode, group_mode, other_mode, special_mode,
f)) {
4508 throw "Changing mode for subdirectory entry failed";
4523 throw "Changing mode for subdirectory (non-recursive) failed";
4531 if (!item.
SetModeEntry(user_mode, group_mode, other_mode, special_mode,
flags)) {
4536 throw "Changing mode for subdirectory entry failed";
4543 catch (
const char* what) {
4546 LOG_ERROR(94,
"CDir::SetMode(): Cannot change mode for directory: " +
GetPath() +
": " + what);
4576 #if defined(NCBI_OS_UNIX)
4592 " Symbolic links not supported on this platform: "
4601 #if defined(NCBI_OS_UNIX)
4628 bool dst_exists = (dst_type !=
eUnknown);
4629 string dst_safe_path;
4661 LOG_ERROR(81,
"CSymLink::Copy(): Cannot backup destination: " + dst.
GetPath());
4673 string path, name, ext;
4677 dst_safe_path = dst.
GetPath();
4696 " Cannot create symbolic link " + dst.
GetPath() +
4697 " to " +
string(
buf));
4706 " Cannot rename temporary symlink " + dst.
GetPath() +
4714 LOG_ERROR(100,
"CSymLink::Copy(): Cannot copy permissions from " +
4715 GetPath() +
" to " + new_path);
4723 return CParent::Copy(new_path,
flags, buf_size);
4801 #define GET_STATVFS_INFO \
4802 struct statvfs st; \
4803 memset(&st, 0, sizeof(st)); \
4804 if (statvfs(path.c_str(), &st) != 0) { \
4805 CNcbiError::SetFromErrno(); \
4806 NCBI_THROW(CFileErrnoException, eFileSystemInfo, string(msg) + path); \
4808 info->total_space = (Uint8)st.f_bsize * st.f_blocks; \
4809 if (st.f_frsize) { \
4810 info->free_space = (Uint8)st.f_frsize * st.f_bavail; \
4811 info->block_size = (unsigned long)st.f_frsize; \
4813 info->free_space = (Uint8)st.f_bsize * st.f_bavail; \
4814 info->block_size = (unsigned long)st.f_bsize; \
4816 info->used_space = info->total_space - info->free_space
4819 #define GET_STATFS_INFO \
4821 memset(&st, 0, sizeof(st)); \
4822 if (statfs(path.c_str(), &st) != 0) { \
4823 CNcbiError::SetFromErrno(); \
4824 NCBI_THROW(CFileErrnoException, eFileSystemInfo, string(msg) + path); \
4826 info->total_space = (Uint8)st.f_bsize * st.f_blocks; \
4827 info->free_space = (Uint8)st.f_bsize * st.f_bavail; \
4828 info->used_space = info->total_space - info->free_space; \
4829 info->block_size = (unsigned long)st.f_bsize
4833 #if defined(SUPPORT_PANFS)
4839 int errcode = errno;
4840 _no_warning(::write(fd, &errcode,
sizeof(errcode)));
4846 #define CLOSE_PIPE_END(fd) \
4865 static bool s_InitEXE =
false;
4866 static bool s_ExistEXE =
false;
4868 #if defined(ALLOW_USE_NCBI_PANFS_DLL)
4871 static bool s_InitDLL =
false;
4872 static FGetDiskSpace_PANFS f_GetDiskSpace =
NULL;
4877 # define _TOSTRING(x) #x
4878 # define TOSTRING(x) _TOSTRING(x)
4879 const char* kNcbiPanfsDLL =
"/opt/ncbi/" TOSTRING(
NCBI_PLATFORM_BITS)
"/lib/ncbi_panfs.so";
4883 void* handle = ::dlopen(kNcbiPanfsDLL, RTLD_NOW | RTLD_GLOBAL);
4884 const char* err =
NULL;
4886 f_GetDiskSpace = (FGetDiskSpace_PANFS) ::dlsym(handle,
"ncbi_GetDiskSpace_PANFS");
4887 if ( !f_GetDiskSpace ) {
4888 err =
"Undefined symbol";
4891 err =
"Cannot open shared object file";
4894 char* dlerr = dlerror();
4895 string msg =
"Trying to get ncbi_GetDiskSpace_PANFS() function from '" +
4896 string(kNcbiPanfsDLL) +
"': " + err;
4898 msg = msg +
" (" + dlerr +
")";
4908 if ( f_GetDiskSpace ) {
4909 const char* err_msg =
NULL;
4910 bool do_throw =
false;
4912 int res = f_GetDiskSpace(path.c_str(), &
info->total_space, &
info->free_space, &err_msg);
4916 info->used_space =
info->total_space -
info->free_space;
4920 case NCBI_PANFS_THROW:
4925 case NCBI_PANFS_ERR:
4926 case NCBI_PANFS_ERR_OPEN:
4927 case NCBI_PANFS_ERR_QUERY:
4928 case NCBI_PANFS_ERR_VERSION:
4931 string msg =
"Cannot get information for PANFS mount '"+ path +
"'";
4933 msg +=
string(
": ") + err_msg;
4951 const char* kPanDF =
"/opt/panfs/bin/pan_df";
4963 int status_pipe[2] = {-1,-1};
4964 int pipe_fd[2] = {-1,-1};
4969 if (::pipe(pipe_fd) < 0) {
4970 throw "failed to create pipe for stdout";
4974 if (::pipe(status_pipe) < 0) {
4975 throw "failed to create status pipe";
4977 if (::fcntl(status_pipe[1], F_SETFD,
4978 ::fcntl(status_pipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0) {
4979 throw "failed to set close-on-exec mode for status pipe";
4983 pid_t pid = ::fork();
4985 throw "fork() failed";
5003 int status = ::execl(kPanDF, kPanDF,
"--block-size=1", path.c_str(),
NULL);
5021 while ((
n = read(status_pipe[0], &errcode,
sizeof(errcode))) < 0) {
5028 ::waitpid(pid, 0, 0);
5029 errno = (size_t)
n >=
sizeof(errcode) ? errcode : 0;
5030 throw "failed to run pan_df";
5035 while ((
n = read(pipe_fd[0], &
buf,
sizeof(
buf)-1)) < 0) {
5041 throw "error reading from pipe";
5046 const char* kParseError =
"results parse error";
5047 const char* data = strchr(
buf,
'\n');
5051 vector<string> tokens;
5053 if ( tokens.size() != 6 ) {
5056 Uint8 x_total = 1, x_free = 2, x_used = 3;
5066 if ( x_free + x_used != x_total ) {
5069 info->total_space = x_total;
5070 info->free_space = x_free;
5071 info->used_space = x_used;
5074 catch (
const char* what) {
5085 "Cannot use any external method to get information about "
5086 "PANFS mount, fall back to use standard OS info "
5087 "(NOTE: it can be incorrect)");
5101 "s_GetFileSystemInfo(path, NULL) is not allowed");
5104 const char* msg =
"Cannot get system information for ";
5105 const char* fs_name_ptr = 0;
5107 #if defined(NCBI_OS_MSWIN)
5109 string xpath = path;
5125 TXChar fs_name[MAX_PATH+1];
5137 sizeof(fs_name)/
sizeof(fs_name[0])) ) {
5140 info->filename_max = filename_max;
5142 fs_name_ptr = ufs_name.c_str();
5148 (PULARGE_INTEGER)&
info->free_space,
5149 (PULARGE_INTEGER)&
info->total_space, 0) ) {
5156 DWORD dwSectPerClust;
5157 DWORD dwBytesPerSect;
5159 &dwSectPerClust, &dwBytesPerSect,
5163 info->block_size = dwBytesPerSect * dwSectPerClust;
5168 bool need_name_max =
true;
5169 # ifdef _PC_NAME_MAX
5170 long r_name_max = pathconf(path.c_str(), _PC_NAME_MAX);
5171 if (r_name_max != -1) {
5172 info->filename_max = (
unsigned long)r_name_max;
5173 need_name_max =
false;
5177 # if (defined(NCBI_OS_LINUX) || defined(NCBI_OS_CYGWIN)) && defined(HAVE_STATFS)
5181 switch (st.f_type) {
5249 if (need_name_max) {
5250 info->filename_max = (
unsigned long)st.f_namelen;
5253 # elif (defined(NCBI_OS_SOLARIS) || defined(NCBI_OS_IRIX) || defined(NCBI_OS_OSF1)) \
5254 && defined(HAVE_STATVFS)
5257 if (need_name_max) {
5258 info->filename_max = (
unsigned long)st.f_namemax;
5260 fs_name_ptr = st.f_basetype;
5262 # elif defined(NCBI_OS_DARWIN) && defined(HAVE_STATFS)
5268 if (need_name_max) {
5271 fs_name_ptr = st.f_fstypename;
5273 # elif defined(NCBI_OS_BSD) && defined(HAVE_STATFS)
5276 fs_name_ptr = st.f_fstypename;
5277 if (need_name_max) {
5278 info->filename_max = (
unsigned long)st.f_namemax;
5281 # elif defined(NCBI_OS_OSF1) && defined(HAVE_STATVFS)
5284 if (need_name_max) {
5285 info->filename_max = (
unsigned long)st.f_namelen;
5287 fs_name_ptr = st.f_fstypename;
5292 #if defined(HAVE_STATVFS)
5294 #elif defined(HAVE_STATFS)
5312 #if defined(SUPPORT_PANFS)
5332 return info.free_space;
5340 return info.used_space;
5348 return info.total_space;
5392 if ( m_FileName.empty() ) {
5395 m_RemoveOnDestruction = remove_file;
5400 m_RemoveOnDestruction(remove_file)