aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorkaliki <kaliki@yandex-team.ru>2022-02-10 16:48:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:06 +0300
commita79404df3a1d90f4b37ac8a1ce0a2bfb5dfd06f1 (patch)
tree3302aab790ee7891a6ed0b4b9257ab4dd02ae4c1 /util
parentb552921bb1c7ea535f6e0e1706feb311c27d6036 (diff)
downloadydb-a79404df3a1d90f4b37ac8a1ce0a2bfb5dfd06f1.tar.gz
Restoring authorship annotation for <kaliki@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/datetime/base.h2
-rw-r--r--util/folder/dirent_win.c98
-rw-r--r--util/folder/dirent_win.h26
-rw-r--r--util/folder/fts.cpp240
-rw-r--r--util/folder/fts.h12
-rw-r--r--util/folder/fts_ut.cpp66
-rw-r--r--util/folder/lstat_win.c26
-rw-r--r--util/folder/lstat_win.h20
-rw-r--r--util/system/datetime.cpp44
-rw-r--r--util/system/datetime.h2
-rw-r--r--util/system/file.cpp10
11 files changed, 273 insertions, 273 deletions
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 5e902b8f63..58b6dca315 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -171,7 +171,7 @@ public:
return Value_;
}
-protected:
+protected:
TValue Value_; // microseconds count
};
diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c
index 7e6db74ce5..9e426b199a 100644
--- a/util/folder/dirent_win.c
+++ b/util/folder/dirent_win.c
@@ -1,13 +1,13 @@
#include <util/system/defaults.h>
-
-#ifdef _win_
-
+
+#ifdef _win_
+
#include <stdio.h>
#include "dirent_win.h"
-
+
#if defined(_MSC_VER) && (_MSC_VER < 1900)
-void __cdecl _dosmaperr(unsigned long);
-
+void __cdecl _dosmaperr(unsigned long);
+
static void SetErrno() {
_dosmaperr(GetLastError());
}
@@ -29,11 +29,11 @@ struct DIR* opendir(const char* dirname) {
dir->file_no = 0;
dir->readdir_buf = NULL;
- int len = strlen(dirname);
- //Remove trailing slashes
+ int len = strlen(dirname);
+ //Remove trailing slashes
while (len && (dirname[len - 1] == '\\' || dirname[len - 1] == '/')) {
--len;
- }
+ }
int len_converted = MultiByteToWideChar(CP_UTF8, 0, dirname, len, 0, 0);
if (len_converted == 0) {
closedir(dir);
@@ -53,42 +53,42 @@ struct DIR* opendir(const char* dirname) {
SetErrno();
closedir(dir);
return NULL;
- }
-
- return dir;
-}
+ }
+ return dir;
+}
+
int closedir(struct DIR* dir) {
if (dir->sh != INVALID_HANDLE_VALUE)
FindClose(dir->sh);
- free(dir->fff_templ);
- free(dir->readdir_buf);
- free(dir);
- return 0;
-}
-
+ free(dir->fff_templ);
+ free(dir->readdir_buf);
+ free(dir);
+ return 0;
+}
+
int readdir_r(struct DIR* dir, struct dirent* entry, struct dirent** result) {
if (!FindNextFileW(dir->sh, &dir->wfd)) {
- int err = GetLastError();
- *result = 0;
- if (err == ERROR_NO_MORE_FILES) {
- SetLastError(0);
- return 0;
- } else {
- return err;
- }
- }
- entry->d_fileno = dir->file_no++;
- entry->d_reclen = sizeof(struct dirent);
+ int err = GetLastError();
+ *result = 0;
+ if (err == ERROR_NO_MORE_FILES) {
+ SetLastError(0);
+ return 0;
+ } else {
+ return err;
+ }
+ }
+ entry->d_fileno = dir->file_no++;
+ entry->d_reclen = sizeof(struct dirent);
if (dir->wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
(dir->wfd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || dir->wfd.dwReserved0 == IO_REPARSE_TAG_SYMLINK))
{
- entry->d_type = DT_LNK;
+ entry->d_type = DT_LNK;
} else if (dir->wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- entry->d_type = DT_DIR;
- } else {
- entry->d_type = DT_REG;
- }
+ entry->d_type = DT_DIR;
+ } else {
+ entry->d_type = DT_REG;
+ }
int len = lstrlenW(dir->wfd.cFileName);
int conv_len = WideCharToMultiByte(CP_UTF8, 0, dir->wfd.cFileName, len, 0, 0, 0, 0);
if (conv_len == 0) {
@@ -101,25 +101,25 @@ int readdir_r(struct DIR* dir, struct dirent* entry, struct dirent** result) {
entry->d_namlen = conv_len;
WideCharToMultiByte(CP_UTF8, 0, dir->wfd.cFileName, len, entry->d_name, conv_len, 0, 0);
entry->d_name[conv_len] = 0;
- *result = entry;
- return 0;
-}
-
+ *result = entry;
+ return 0;
+}
+
struct dirent* readdir(struct DIR* dir) {
struct dirent* res;
if (!dir->readdir_buf) {
- dir->readdir_buf = (struct dirent*)malloc(sizeof(struct dirent));
+ dir->readdir_buf = (struct dirent*)malloc(sizeof(struct dirent));
if (dir->readdir_buf == 0)
return 0;
}
- readdir_r(dir, dir->readdir_buf, &res);
- return res;
-}
-
+ readdir_r(dir, dir->readdir_buf, &res);
+ return res;
+}
+
void rewinddir(struct DIR* dir) {
- FindClose(dir->sh);
+ FindClose(dir->sh);
dir->sh = FindFirstFileW(dir->fff_templ, &dir->wfd);
- dir->file_no = 0;
-}
-
-#endif //_win_
+ dir->file_no = 0;
+}
+
+#endif //_win_
diff --git a/util/folder/dirent_win.h b/util/folder/dirent_win.h
index ac11a64c04..a432fdf51a 100644
--- a/util/folder/dirent_win.h
+++ b/util/folder/dirent_win.h
@@ -1,15 +1,15 @@
#pragma once
-
+
#include <util/system/defaults.h>
-
-#ifdef _win_
-
+
+#ifdef _win_
+
#include <util/system/winint.h>
-
+
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-
+
struct DIR {
HANDLE sh;
WIN32_FIND_DATAW wfd;
@@ -17,14 +17,14 @@ extern "C" {
int file_no;
struct dirent* readdir_buf;
};
-
+
#define MAXNAMLEN (MAX_PATH - 1) * 2
#define MAXPATHLEN MAX_PATH
#define DT_DIR 4
#define DT_REG 8
#define DT_LNK 10
#define DT_UNKNOWN 0
-
+
struct dirent {
ui32 d_fileno; /* file number of entry */
ui16 d_reclen; /* length of this record */
@@ -32,15 +32,15 @@ extern "C" {
ui8 d_namlen; /* length of string in d_name */
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
};
-
+
struct DIR* opendir(const char* dirname);
int closedir(struct DIR* dir);
int readdir_r(struct DIR* dir, struct dirent* entry, struct dirent** result);
struct dirent* readdir(struct DIR* dir);
void rewinddir(struct DIR* dir);
-
+
#ifdef __cplusplus
-}
+}
#endif
-#endif //_win_
+#endif //_win_
diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp
index 0e6a6f86eb..2e9b22342e 100644
--- a/util/folder/fts.cpp
+++ b/util/folder/fts.cpp
@@ -38,58 +38,58 @@
#include <util/system/compiler.h>
#include <util/system/defaults.h>
#include <util/system/error.h>
-
+
#include <stdlib.h>
-#ifndef _win_
+#ifndef _win_
#include <inttypes.h>
#include <sys/param.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
-#else
+#else
#include <direct.h>
#include "dirent_win.h"
#include "lstat_win.h"
-#endif
+#endif
#include <sys/stat.h>
#include <fcntl.h>
-
+
#include "fts.h"
-#include <limits.h>
-
-#ifndef _win_
-
+#include <limits.h>
+
+#ifndef _win_
+
static const dird invalidDirD = -1;
-
-dird get_cwdd() {
- return open(".", O_RDONLY, 0);
-}
-
-dird get_dird(char* path) {
- return open(path, O_RDONLY, 0);
-}
-
-int valid_dird(dird fd) {
- return fd < 0;
-}
-
-void close_dird(dird fd) {
- (void)close(fd);
-}
-
-int chdir_dird(dird fd) {
- return fchdir(fd);
-}
-
-int cmp_dird(dird fd1, dird fd2) {
- return fd1 - fd2;
-}
-
+
+dird get_cwdd() {
+ return open(".", O_RDONLY, 0);
+}
+
+dird get_dird(char* path) {
+ return open(path, O_RDONLY, 0);
+}
+
+int valid_dird(dird fd) {
+ return fd < 0;
+}
+
+void close_dird(dird fd) {
+ (void)close(fd);
+}
+
+int chdir_dird(dird fd) {
+ return fchdir(fd);
+}
+
+int cmp_dird(dird fd1, dird fd2) {
+ return fd1 - fd2;
+}
+
#else // ndef _win_
-
+
int stat64UTF(const char* path, struct _stat64* _Stat) {
int len_converted = MultiByteToWideChar(CP_UTF8, 0, path, -1, 0, 0);
if (len_converted == 0) {
@@ -111,23 +111,23 @@ int stat64UTF(dird path, struct _stat64* _Stat) {
}
const dird invalidDirD = nullptr;
-
-dird get_cwdd() {
+
+dird get_cwdd() {
return _wgetcwd(nullptr, 0);
-}
-
-int valid_dird(dird fd) {
+}
+
+int valid_dird(dird fd) {
return fd == nullptr;
-}
-
-void close_dird(dird fd) {
- free(fd);
-}
-
-int chdir_dird(dird fd) {
+}
+
+void close_dird(dird fd) {
+ free(fd);
+}
+
+int chdir_dird(dird fd) {
return _wchdir(fd);
-}
-
+}
+
int chdir_dird(const char* path) {
int len_converted = MultiByteToWideChar(CP_UTF8, 0, path, -1, 0, 0);
if (len_converted == 0) {
@@ -143,11 +143,11 @@ int chdir_dird(const char* path) {
return ret;
}
-int cmp_dird(dird fd1, dird fd2) {
+int cmp_dird(dird fd1, dird fd2) {
return lstrcmpW(fd1, fd2);
-}
-
-dird get_dird(char* path) {
+}
+
+dird get_dird(char* path) {
int len_converted = MultiByteToWideChar(CP_UTF8, 0, path, -1, 0, 0);
if (len_converted == 0) {
return nullptr;
@@ -163,7 +163,7 @@ dird get_dird(char* path) {
free(buf);
return ret;
}
-
+
#endif // ndef _win_
#ifdef _win_
@@ -172,9 +172,9 @@ dird get_dird(char* path) {
#define S_ISLNK(st_mode) ((st_mode & _S_IFMT) == _S_IFLNK)
#define O_RDONLY _O_RDONLY
static int fts_safe_changedir(FTS*, FTSENT*, int, dird);
-#endif
-
-#if defined(__svr4__) || defined(__linux__) || defined(__CYGWIN__) || defined(_win_)
+#endif
+
+#if defined(__svr4__) || defined(__linux__) || defined(__CYGWIN__) || defined(_win_)
#ifdef MAX
#undef MAX
#endif
@@ -294,16 +294,16 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
/* Allocate/initialize root(s). */
for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) {
/* Don't allow zero-length paths. */
-
- len = strlen(*argv);
-
-//Any subsequent windows call will expect no trailing slashes so we will remove them here
-#ifdef _win_
+
+ len = strlen(*argv);
+
+//Any subsequent windows call will expect no trailing slashes so we will remove them here
+#ifdef _win_
while (len && ((*argv)[len - 1] == '\\' || (*argv)[len - 1] == '/')) {
--len;
}
-#endif
-
+#endif
+
if (len == 0) {
errno = ENOENT;
goto mem3;
@@ -361,7 +361,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
-
+
if (!ISSET(FTS_NOCHDIR) && valid_dird(sp->fts_rfd = get_cwdd())) {
SET(FTS_NOCHDIR);
}
@@ -432,9 +432,9 @@ int yfts_close(FTS* sp)
/* Return to original directory, save errno if necessary. */
if (!ISSET(FTS_NOCHDIR)) {
- saved_errno = chdir_dird(sp->fts_rfd) ? errno : 0;
- close_dird(sp->fts_rfd);
-
+ saved_errno = chdir_dird(sp->fts_rfd) ? errno : 0;
+ close_dird(sp->fts_rfd);
+
/* Set errno and return. */
if (saved_errno != 0) {
/* Free up the stream pointer. */
@@ -784,12 +784,12 @@ fts_build(FTS* sp, int type)
int nitems;
FTSENT *cur, *tail;
-#ifdef _win_
- dird dirpd;
+#ifdef _win_
+ dird dirpd;
struct DIR* dirp;
-#else
+#else
DIR* dirp;
-#endif
+#endif
void* oldaddr;
int cderrno, descend, len, level, maxlen, nlinks, saved_errno,
@@ -819,10 +819,10 @@ fts_build(FTS* sp, int type)
return nullptr;
}
-#ifdef _win_
- dirpd = get_dird(cur->fts_accpath);
-#endif
-
+#ifdef _win_
+ dirpd = get_dird(cur->fts_accpath);
+#endif
+
/*
* Nlinks is the number of possible entries of type directory in the
* directory if we're cheating on stat calls, 0 if we're not doing
@@ -857,11 +857,11 @@ fts_build(FTS* sp, int type)
*/
cderrno = 0;
if (nlinks || type == BREAD) {
-#ifndef _win_
+#ifndef _win_
if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) {
-#else
- if (fts_safe_changedir(sp, cur, -1, dirpd)) {
-#endif
+#else
+ if (fts_safe_changedir(sp, cur, -1, dirpd)) {
+#endif
if (nlinks && type == BREAD) {
cur->fts_errno = errno;
@@ -871,12 +871,12 @@ fts_build(FTS* sp, int type)
cderrno = errno;
(void)closedir(dirp);
dirp = nullptr;
-#ifdef _win_
- close_dird(dirpd);
+#ifdef _win_
+ close_dird(dirpd);
dirpd = invalidDirD;
#else
Y_UNUSED(invalidDirD);
-#endif
+#endif
} else {
descend = 1;
}
@@ -936,9 +936,9 @@ fts_build(FTS* sp, int type)
}
fts_lfree(head);
(void)closedir(dirp);
-#ifdef _win_
- close_dird(dirpd);
-#endif
+#ifdef _win_
+ close_dird(dirpd);
+#endif
cur->fts_info = FTS_ERR;
SET(FTS_STOP);
errno = saved_errno;
@@ -964,9 +964,9 @@ fts_build(FTS* sp, int type)
free(p);
fts_lfree(head);
(void)closedir(dirp);
-#ifdef _win_
- close_dird(dirpd);
-#endif
+#ifdef _win_
+ close_dird(dirpd);
+#endif
cur->fts_info = FTS_ERR;
SET(FTS_STOP);
errno = ENAMETOOLONG;
@@ -1038,12 +1038,12 @@ fts_build(FTS* sp, int type)
}
++nitems;
}
- if (dirp) {
+ if (dirp) {
(void)closedir(dirp);
-#ifdef _win_
- close_dird(dirpd);
-#endif
- }
+#ifdef _win_
+ close_dird(dirpd);
+#endif
+ }
/*
* If realloc() changed the address of the path, adjust the
@@ -1130,7 +1130,7 @@ fts_stat(FTS* sp, FTSENT* p, int follow)
}
p->fts_errno = saved_errno;
memset(sbp, 0, sizeof(stat_struct));
- return (FTS_NS);
+ return (FTS_NS);
}
} else if (lstat(p->fts_accpath, sbp)) {
p->fts_errno = errno;
@@ -1138,7 +1138,7 @@ fts_stat(FTS* sp, FTSENT* p, int follow)
return (FTS_NS);
}
- if (S_ISDIR(sbp->st_mode)) {
+ if (S_ISDIR(sbp->st_mode)) {
/*
* Set the device/inode. Used to find cycles and check for
* crossing mount points. Also remember the link count, used
@@ -1161,10 +1161,10 @@ fts_stat(FTS* sp, FTSENT* p, int follow)
* number of symbolic links to directories is high enough,
* something faster might be worthwhile.
*/
-
+
//There is no way to detect symlink or mount cycles on win32
-
-#ifndef _win_
+
+#ifndef _win_
FTSENT* t;
for (t = p->fts_parent;
t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) {
@@ -1173,7 +1173,7 @@ fts_stat(FTS* sp, FTSENT* p, int follow)
return (FTS_DC);
}
}
-#endif /*_win_*/
+#endif /*_win_*/
return (FTS_D);
}
if (S_ISLNK(sbp->st_mode)) {
@@ -1353,8 +1353,8 @@ fts_maxarglen(char* const* argv)
* tricked by someone changing the world out from underneath us.
* Assumes p->fts_dev and p->fts_ino are filled in.
*/
-
-#ifndef _win_
+
+#ifndef _win_
static int
fts_safe_changedir(FTS* sp, FTSENT* p, int fd, const char* path)
{
@@ -1386,28 +1386,28 @@ bail:
errno = oerrno;
return (ret);
}
-#else
-static int
+#else
+static int
fts_safe_changedir(FTS* sp, FTSENT* p, int /*fd*/, const char* path)
-{
- int ret;
+{
+ int ret;
stat_struct sb;
-
- if (ISSET(FTS_NOCHDIR))
- return (0);
+
+ if (ISSET(FTS_NOCHDIR))
+ return (0);
if (STAT_FUNC(path, &sb)) {
- ret = -1;
- goto bail;
- }
- if (p->fts_dev != sb.st_dev) {
+ ret = -1;
+ goto bail;
+ }
+ if (p->fts_dev != sb.st_dev) {
errno = ENOENT; /* disinformation */
- ret = -1;
- goto bail;
- }
+ ret = -1;
+ goto bail;
+ }
ret = chdir_dird(path);
-bail:
- return (ret);
-}
+bail:
+ return (ret);
+}
static int
fts_safe_changedir(FTS* sp, FTSENT* p, int /*fd*/, dird path) {
@@ -1429,4 +1429,4 @@ fts_safe_changedir(FTS* sp, FTSENT* p, int /*fd*/, dird path) {
bail:
return (ret);
}
-#endif
+#endif
diff --git a/util/folder/fts.h b/util/folder/fts.h
index f3c799e8c8..bd76bbb473 100644
--- a/util/folder/fts.h
+++ b/util/folder/fts.h
@@ -1,14 +1,14 @@
#pragma once
-#include <sys/types.h>
+#include <sys/types.h>
#include <util/system/defaults.h>
-
-#ifndef _win32_
+
+#ifndef _win32_
typedef int dird;
typedef struct stat stat_struct;
#define STAT_FUNC stat
-#else
+#else
#include <util/folder/dirent_win.h>
typedef WCHAR* dird;
typedef unsigned short u_short;
@@ -20,8 +20,8 @@ typedef struct _stat64 stat_struct;
int stat64UTF(const char* path, struct _stat64* _Stat);
int stat64UTF(dird path, struct _stat64* _Stat);
#endif
-#endif
-
+#endif
+
typedef struct {
struct _ftsent* fts_cur; /* current node */
struct _ftsent* fts_child; /* linked list of children */
diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp
index c5d59e35f4..51882b2317 100644
--- a/util/folder/fts_ut.cpp
+++ b/util/folder/fts_ut.cpp
@@ -4,60 +4,60 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/threading/future/async.h>
-
+
#include <util/system/file.h>
#include <util/system/tempfile.h>
#include <util/generic/string.h>
-
-class TFtsTest: public TTestBase {
+
+class TFtsTest: public TTestBase {
UNIT_TEST_SUITE(TFtsTest);
UNIT_TEST(TestSimple);
UNIT_TEST(TestNoLeakChangingAccessToFolder);
UNIT_TEST_SUITE_END();
-
+
public:
void TestSimple();
void TestNoLeakChangingAccessToFolder();
-};
-
+};
+
void MakeFile(const char* path) {
TFile(path, CreateAlways);
-}
-
-//There potentially could be problems in listing order on different platforms
+}
+
+//There potentially could be problems in listing order on different platforms
int FtsCmp(const FTSENT** ent1, const FTSENT** ent2) {
- return strcmp((*ent1)->fts_accpath, (*ent2)->fts_accpath);
-}
-
+ return strcmp((*ent1)->fts_accpath, (*ent2)->fts_accpath);
+}
+
void CheckEnt(FTSENT* ent, const char* name, int type) {
- UNIT_ASSERT(ent);
- UNIT_ASSERT_STRINGS_EQUAL(ent->fts_path, name);
- UNIT_ASSERT_EQUAL(ent->fts_info, type);
-}
-
+ UNIT_ASSERT(ent);
+ UNIT_ASSERT_STRINGS_EQUAL(ent->fts_path, name);
+ UNIT_ASSERT_EQUAL(ent->fts_info, type);
+}
+
class TFileTree {
-public:
+public:
TFileTree(char* const* argv, int options, int (*compar)(const FTSENT**, const FTSENT**)) {
Fts_ = yfts_open(argv, options, compar);
- }
-
+ }
+
~TFileTree() {
yfts_close(Fts_);
- }
-
- FTS* operator()() {
+ }
+
+ FTS* operator()() {
return Fts_;
- }
+ }
-private:
+private:
FTS* Fts_;
-};
-
+};
+
void TFtsTest::TestSimple() {
const char* dotPath[2] = {"." LOCSLASH_S, nullptr};
TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp);
- UNIT_ASSERT(currentDirTree());
- TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path);
+ UNIT_ASSERT(currentDirTree());
+ TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path);
MakeDirIfNotExist(tempDir().data());
MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir1").data());
MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data());
@@ -65,10 +65,10 @@ void TFtsTest::TestSimple() {
MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir2").data());
MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data());
MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data());
-
+
const char* path[2] = {tempDir().data(), nullptr};
TFileTree fileTree((char* const*)path, 0, FtsCmp);
- UNIT_ASSERT(fileTree());
+ UNIT_ASSERT(fileTree());
CheckEnt(yfts_read(fileTree()), tempDir().data(), FTS_D);
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_D);
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data(), FTS_F);
@@ -80,8 +80,8 @@ void TFtsTest::TestSimple() {
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP);
CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP);
UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr);
-}
-
+}
+
class TTempDirWithLostAccess: public TTempDir {
public:
~TTempDirWithLostAccess() {
diff --git a/util/folder/lstat_win.c b/util/folder/lstat_win.c
index cf94cec01a..0a1456a3e7 100644
--- a/util/folder/lstat_win.c
+++ b/util/folder/lstat_win.c
@@ -1,6 +1,6 @@
#include <util/system/defaults.h>
-
-#ifdef _win_
+
+#ifdef _win_
#include <util/system/winint.h>
#include "lstat_win.h"
@@ -14,22 +14,22 @@ int lstat(const char* fileName, stat_struct* fileStat) {
MultiByteToWideChar(CP_UTF8, 0, fileName, len, buf, convRes);
buf[convRes] = 0;
- HANDLE findHandle;
+ HANDLE findHandle;
WIN32_FIND_DATAW findBuf;
- int result;
+ int result;
result = _wstat64(buf, fileStat);
- if (result == 0) {
+ if (result == 0) {
SetLastError(0);
findHandle = FindFirstFileW(buf, &findBuf);
if (findBuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
(findBuf.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT || findBuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK))
{
- fileStat->st_mode = fileStat->st_mode & ~_S_IFMT | _S_IFLNK;
- }
- FindClose(findHandle);
- }
+ fileStat->st_mode = fileStat->st_mode & ~_S_IFMT | _S_IFLNK;
+ }
+ FindClose(findHandle);
+ }
free(buf);
- return result;
-}
-
-#endif //_win_
+ return result;
+}
+
+#endif //_win_
diff --git a/util/folder/lstat_win.h b/util/folder/lstat_win.h
index 0bf7c19055..10152db2b5 100644
--- a/util/folder/lstat_win.h
+++ b/util/folder/lstat_win.h
@@ -1,20 +1,20 @@
#pragma once
-
+
#include <util/system/defaults.h>
#include "fts.h"
-
-#ifdef _win_
+
+#ifdef _win_
#include <sys/stat.h>
-
+
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-
+
#define _S_IFLNK 0xA000
int lstat(const char* fileName, stat_struct* fileStat);
-
+
#ifdef __cplusplus
-}
+}
#endif
-
-#endif //_win_
+
+#endif //_win_
diff --git a/util/system/datetime.cpp b/util/system/datetime.cpp
index b07b50679a..0ea6c77ac2 100644
--- a/util/system/datetime.cpp
+++ b/util/system/datetime.cpp
@@ -40,38 +40,38 @@ ui64 MicroSeconds() noexcept {
ui64 ThreadCPUUserTime() noexcept {
#if defined(_win_)
- FILETIME creationTime, exitTime, kernelTime, userTime;
- GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
- return ToMicroSeconds(userTime);
-#else
- return 0;
-#endif
-}
-
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
+ return ToMicroSeconds(userTime);
+#else
+ return 0;
+#endif
+}
+
ui64 ThreadCPUSystemTime() noexcept {
#if defined(_win_)
- FILETIME creationTime, exitTime, kernelTime, userTime;
- GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
- return ToMicroSeconds(kernelTime);
-#else
- return 0;
-#endif
-}
-
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
+ return ToMicroSeconds(kernelTime);
+#else
+ return 0;
+#endif
+}
+
ui64 ThreadCPUTime() noexcept {
#if defined(_win_)
- FILETIME creationTime, exitTime, kernelTime, userTime;
- GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
- return ToMicroSeconds(userTime) + ToMicroSeconds(kernelTime);
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime);
+ return ToMicroSeconds(userTime) + ToMicroSeconds(kernelTime);
#elif defined(Y_HAS_CLOCK_GETTIME)
struct timespec ts;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
return ToMicroSeconds(ts);
#else
return 0;
-#endif
-}
-
+#endif
+}
+
ui32 Seconds() noexcept {
struct timeval tv;
gettimeofday(&tv, nullptr);
diff --git a/util/system/datetime.h b/util/system/datetime.h
index aa009974e0..1d502cac96 100644
--- a/util/system/datetime.h
+++ b/util/system/datetime.h
@@ -27,7 +27,7 @@ inline ui64 millisec() {
}
/// Current time in seconds since epoch
ui32 Seconds() noexcept;
-///Current thread time in microseconds
+///Current thread time in microseconds
ui64 ThreadCPUUserTime() noexcept;
ui64 ThreadCPUSystemTime() noexcept;
ui64 ThreadCPUTime() noexcept;
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 4a261d020c..c2ef13aae1 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -106,11 +106,11 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
faMode |= GENERIC_WRITE;
}
if (oMode & ::ForAppend) {
- faMode |= GENERIC_WRITE;
+ faMode |= GENERIC_WRITE;
faMode |= FILE_APPEND_DATA;
- faMode &= ~FILE_WRITE_DATA;
- }
-
+ faMode &= ~FILE_WRITE_DATA;
+ }
+
bool inheritHandle = !(oMode & CloseOnExec);
ui32 shMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
@@ -139,7 +139,7 @@ TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept {
if ((oMode & ::ForAppend) && (Fd_ != INVALID_FHANDLE)) {
::SetFilePointer(Fd_, 0, 0, FILE_END);
}
-
+
#elif defined(_unix_)
switch (createMode) {