aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder
diff options
context:
space:
mode:
authorstanly <stanly@yandex-team.ru>2022-02-10 16:46:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:49 +0300
commit6170310e8721e225f64ddabf7a7358253d7a1249 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util/folder
parentcde218e65dfef5ce03a48d641fd8f7913cf17b2d (diff)
downloadydb-6170310e8721e225f64ddabf7a7358253d7a1249.tar.gz
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r--util/folder/fts.cpp56
-rw-r--r--util/folder/fts.h2
-rw-r--r--util/folder/iterator.h8
-rw-r--r--util/folder/iterator_ut.cpp80
-rw-r--r--util/folder/path.cpp16
-rw-r--r--util/folder/path.h10
6 files changed, 86 insertions, 86 deletions
diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp
index 314e8d6d58..0e6a6f86eb 100644
--- a/util/folder/fts.cpp
+++ b/util/folder/fts.cpp
@@ -215,18 +215,18 @@ static int fts_safe_changedir(FTS*, FTSENT*, int, const char*);
#define BNAMES 2 /* yfts_children, names only */
#define BREAD 3 /* yfts_read */
-static u_short
-yfts_type_from_info(u_short info) {
- if (info == FTS_D || info == FTS_DP || info == FTS_DOT) {
- return FTS_D;
- } else if (info == FTS_F) {
- return FTS_F;
- } else if (info == FTS_SL || info == FTS_SLNONE) {
- return FTS_SL;
- }
- return FTS_NSOK;
-}
-
+static u_short
+yfts_type_from_info(u_short info) {
+ if (info == FTS_D || info == FTS_DP || info == FTS_DOT) {
+ return FTS_D;
+ } else if (info == FTS_F) {
+ return FTS_F;
+ } else if (info == FTS_SL || info == FTS_SLNONE) {
+ return FTS_SL;
+ }
+ return FTS_NSOK;
+}
+
static void*
yreallocf(void* ptr, size_t size)
{
@@ -314,7 +314,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con
p->fts_parent = parent;
p->fts_accpath = p->fts_name;
p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW));
- p->fts_type = yfts_type_from_info(p->fts_info);
+ p->fts_type = yfts_type_from_info(p->fts_info);
/* Command-line "." and ".." are real directories. */
if (p->fts_info == FTS_DOT) {
@@ -482,7 +482,7 @@ yfts_read(FTS* sp) {
/* Any type of file may be re-visited; re-stat and re-turn. */
if (instr == FTS_AGAIN) {
p->fts_info = fts_stat(sp, p, 0);
- p->fts_type = yfts_type_from_info(p->fts_info);
+ p->fts_type = yfts_type_from_info(p->fts_info);
return (p);
}
@@ -495,7 +495,7 @@ yfts_read(FTS* sp) {
if (instr == FTS_FOLLOW &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
p->fts_info = fts_stat(sp, p, 1);
- p->fts_type = yfts_type_from_info(p->fts_info);
+ p->fts_type = yfts_type_from_info(p->fts_info);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if (valid_dird(p->fts_symfd = get_cwdd())) {
p->fts_errno = errno;
@@ -591,7 +591,7 @@ next:
}
if (p->fts_instr == FTS_FOLLOW) {
p->fts_info = fts_stat(sp, p, 1);
- p->fts_type = yfts_type_from_info(p->fts_info);
+ p->fts_type = yfts_type_from_info(p->fts_info);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if (valid_dird(p->fts_symfd =
get_cwdd())) {
@@ -981,16 +981,16 @@ fts_build(FTS* sp, int type)
p->fts_flags |= FTS_ISW;
#endif
-#ifdef _DIRENT_HAVE_D_TYPE
- if (dp->d_type == DT_DIR) {
- p->fts_type = FTS_D;
- } else if (dp->d_type == DT_REG) {
- p->fts_type = FTS_F;
- } else if (dp->d_type == DT_LNK) {
- p->fts_type = FTS_SL;
- }
-#endif
-
+#ifdef _DIRENT_HAVE_D_TYPE
+ if (dp->d_type == DT_DIR) {
+ p->fts_type = FTS_D;
+ } else if (dp->d_type == DT_REG) {
+ p->fts_type = FTS_F;
+ } else if (dp->d_type == DT_LNK) {
+ p->fts_type = FTS_SL;
+ }
+#endif
+
// coverity[dead_error_line]: false positive
if (cderrno) {
if (nlinks) {
@@ -1019,7 +1019,7 @@ fts_build(FTS* sp, int type)
}
/* Stat it. */
p->fts_info = fts_stat(sp, p, 0);
- p->fts_type = yfts_type_from_info(p->fts_info);
+ p->fts_type = yfts_type_from_info(p->fts_info);
/* Decrement link count if applicable. */
if (nlinks > 0 && (p->fts_info == FTS_D ||
@@ -1259,7 +1259,7 @@ fts_alloc(FTS* sp, const char* name, int namelen)
p->fts_instr = FTS_NOINSTR;
p->fts_number = 0;
p->fts_pointer = nullptr;
- p->fts_type = FTS_NSOK;
+ p->fts_type = FTS_NSOK;
return (p);
}
diff --git a/util/folder/fts.h b/util/folder/fts.h
index 6ee42fd803..f3c799e8c8 100644
--- a/util/folder/fts.h
+++ b/util/folder/fts.h
@@ -84,7 +84,7 @@ typedef struct _ftsent {
#define FTS_SLNONE 13 /* symbolic link without target */
#define FTS_W 14 /* whiteout object */
u_short fts_info; /* user flags for FTSENT structure */
- u_short fts_type; /* type of fs node; one of FTS_D, FTS_F, FTS_SL */
+ u_short fts_type; /* type of fs node; one of FTS_D, FTS_F, FTS_SL */
#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
diff --git a/util/folder/iterator.h b/util/folder/iterator.h
index f84cac2b99..69e025b9c4 100644
--- a/util/folder/iterator.h
+++ b/util/folder/iterator.h
@@ -97,10 +97,10 @@ public:
return ret;
}
- inline void Skip(FTSENT* ent) {
- yfts_set(FileTree_.Get(), ent, FTS_SKIP);
- }
-
+ inline void Skip(FTSENT* ent) {
+ yfts_set(FileTree_.Get(), ent, FTS_SKIP);
+ }
+
private:
TOptions Options_;
TString Path_;
diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp
index 9a3f92313f..936becd139 100644
--- a/util/folder/iterator_ut.cpp
+++ b/util/folder/iterator_ut.cpp
@@ -22,7 +22,7 @@ class TDirIteratorTest: public TTestBase {
UNIT_TEST(TestIt)
UNIT_TEST(TestError)
UNIT_TEST(TestLocal)
- UNIT_TEST(TestSkip)
+ UNIT_TEST(TestSkip)
UNIT_TEST(TestSort)
UNIT_TEST_SUITE_END();
@@ -134,45 +134,45 @@ private:
}
}
- inline void TestSkip() {
- TDirHier hier;
-
- const TString dir = "tmpdir";
- const TDirHier::TPath path = {dir, 1};
-
- hier.Add(path);
- hier.AddDir(dir + LOCSLASH_C + "dir1");
- hier.AddDir(dir + LOCSLASH_C + "dir1" + LOCSLASH_C + "dir2");
- //
- // Without skip
- //
- {
- TDirIterator di(dir);
-
- UNIT_ASSERT(di.Next());
- UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
- UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir2");
- UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir2");
- UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
- UNIT_ASSERT(di.Next());
- UNIT_ASSERT_EQUAL(di.Next(), nullptr);
- }
- //
- // With skip
- //
- {
- TDirIterator di(dir);
-
- UNIT_ASSERT(di.Next());
- auto ent = di.Next();
- UNIT_ASSERT_EQUAL(TStringBuf(ent->fts_name), "dir1");
- di.Skip(ent);
- UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
- UNIT_ASSERT(di.Next());
- UNIT_ASSERT_EQUAL(di.Next(), nullptr);
- }
- }
-
+ inline void TestSkip() {
+ TDirHier hier;
+
+ const TString dir = "tmpdir";
+ const TDirHier::TPath path = {dir, 1};
+
+ hier.Add(path);
+ hier.AddDir(dir + LOCSLASH_C + "dir1");
+ hier.AddDir(dir + LOCSLASH_C + "dir1" + LOCSLASH_C + "dir2");
+ //
+ // Without skip
+ //
+ {
+ TDirIterator di(dir);
+
+ UNIT_ASSERT(di.Next());
+ UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
+ UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir2");
+ UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir2");
+ UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
+ UNIT_ASSERT(di.Next());
+ UNIT_ASSERT_EQUAL(di.Next(), nullptr);
+ }
+ //
+ // With skip
+ //
+ {
+ TDirIterator di(dir);
+
+ UNIT_ASSERT(di.Next());
+ auto ent = di.Next();
+ UNIT_ASSERT_EQUAL(TStringBuf(ent->fts_name), "dir1");
+ di.Skip(ent);
+ UNIT_ASSERT_EQUAL(TStringBuf(di.Next()->fts_name), "dir1");
+ UNIT_ASSERT(di.Next());
+ UNIT_ASSERT_EQUAL(di.Next(), nullptr);
+ }
+ }
+
inline void TestSort() {
TDirHier dh;
const TString dir("tmpdir");
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index 0b5a1a83ae..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -367,14 +367,14 @@ void TFsPath::MkDir(const int mode) const {
CheckDefined();
if (!Exists()) {
int r = Mkdir(this->c_str(), mode);
- if (r != 0) {
- // TODO (stanly) will still fail on Windows because
- // LastSystemError() returns windows specific ERROR_ALREADY_EXISTS
- // instead of EEXIST.
- if (LastSystemError() != EEXIST) {
- ythrow TIoSystemError() << "could not create directory " << Path_;
- }
- }
+ if (r != 0) {
+ // TODO (stanly) will still fail on Windows because
+ // LastSystemError() returns windows specific ERROR_ALREADY_EXISTS
+ // instead of EEXIST.
+ if (LastSystemError() != EEXIST) {
+ ythrow TIoSystemError() << "could not create directory " << Path_;
+ }
+ }
}
}
diff --git a/util/folder/path.h b/util/folder/path.h
index 5ab77b2612..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -115,12 +115,12 @@ public:
}
TFsPath RelativeTo(const TFsPath& root) const; //must be subpath of root
-
- /**
- * @returns relative path or empty path if root equals to this.
- */
+
+ /**
+ * @returns relative path or empty path if root equals to this.
+ */
TFsPath RelativePath(const TFsPath& root) const; //..; for relative paths 1st component must be the same
-
+
/**
* Never fails. Returns this if already a root.
*/