aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder
diff options
context:
space:
mode:
authormowgli <mowgli@yandex-team.ru>2022-02-10 16:49:25 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:25 +0300
commit56c39b3cf908e7202b1f7551a1653681e8015607 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/folder
parent89afbbe4ca0e02e386dd4df08f7945f190dc1b84 (diff)
downloadydb-56c39b3cf908e7202b1f7551a1653681e8015607.tar.gz
Restoring authorship annotation for <mowgli@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r--util/folder/path.cpp34
-rw-r--r--util/folder/path.h10
-rw-r--r--util/folder/path_ut.cpp38
3 files changed, 41 insertions, 41 deletions
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index 8ee93ef621..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -26,13 +26,13 @@ bool TFsPath::IsSubpathOf(const TFsPath& that) const {
const TSplit& rsplit = that.GetSplit();
if (rsplit.IsAbsolute != split.IsAbsolute) {
- return false;
+ return false;
}
-
+
if (rsplit.Drive != split.Drive) {
- return false;
+ return false;
}
-
+
if (rsplit.size() >= split.size()) {
return false;
}
@@ -102,9 +102,9 @@ TFsPath TFsPath::RelativePath(const TFsPath& root) const {
TFsPath TFsPath::Parent() const {
if (!IsDefined()) {
- return TFsPath();
+ return TFsPath();
}
-
+
TSplit split = GetSplit();
if (split.size()) {
split.pop_back();
@@ -116,16 +116,16 @@ TFsPath TFsPath::Parent() const {
}
TFsPath& TFsPath::operator/=(const TFsPath& that) {
- if (!IsDefined()) {
- *this = that;
-
- } else if (that.IsDefined() && that.GetPath() != ".") {
+ if (!IsDefined()) {
+ *this = that;
+
+ } else if (that.IsDefined() && that.GetPath() != ".") {
if (!that.IsRelative()) {
ythrow TIoException() << "path should be relative: " << that.GetPath();
}
- TSplit split = GetSplit();
- const TSplit& rsplit = that.GetSplit();
+ TSplit split = GetSplit();
+ const TSplit& rsplit = that.GetSplit();
split.insert(split.end(), rsplit.begin(), rsplit.end());
*this = TFsPath(split.Reconstruct());
}
@@ -144,8 +144,8 @@ TString TFsPath::GetName() const {
return TString();
}
- const TSplit& split = GetSplit();
-
+ const TSplit& split = GetSplit();
+
if (split.size() > 0) {
if (split.back() != "..") {
return TString(split.back());
@@ -214,7 +214,7 @@ TFsPath TFsPath::Child(const TString& name) const {
if (!name) {
ythrow TIoException() << "child name must not be empty";
}
-
+
return *this / name;
}
@@ -353,9 +353,9 @@ bool TFsPath::IsSymlink() const {
void TFsPath::DeleteIfExists() const {
if (!IsDefined()) {
- return;
+ return;
}
-
+
::unlink(this->c_str());
::rmdir(this->c_str());
if (Exists()) {
diff --git a/util/folder/path.h b/util/folder/path.h
index 9bfc5a0416..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -39,11 +39,11 @@ public:
inline bool IsDefined() const {
return Path_.length() > 0;
}
-
- inline explicit operator bool() const {
- return IsDefined();
- }
-
+
+ inline explicit operator bool() const {
+ return IsDefined();
+ }
+
inline const char* c_str() const {
return Path_.c_str();
}
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index 9931d1ddf8..e6a3451016 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -1,5 +1,5 @@
#include "path.h"
-#include "pathsplit.h"
+#include "pathsplit.h"
#include "dirut.h"
#include "tempdir.h"
@@ -103,18 +103,18 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc/passwd").Parent(), TFsPath("/etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc").Parent(), TFsPath("/"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").Parent(), TFsPath("/"));
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc/passwd").Parent(), TFsPath("etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc").Parent(), TFsPath("."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc").Parent(), TFsPath("."));
#endif
-
-#if 0
+
+#if 0
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc/passwd").Parent(), TFsPath("./etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./").Parent(), TFsPath(".."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(".").Parent(), TFsPath(".."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("..").Parent(), TFsPath("../.."));
-#endif
+#endif
}
Y_UNIT_TEST(GetName) {
@@ -269,30 +269,30 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(TestSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b"));
-
+
UNIT_ASSERT(TFsPath("/a").IsSubpathOf("/"));
UNIT_ASSERT(!TFsPath("/").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a").IsSubpathOf("/a"));
-
+
UNIT_ASSERT(TFsPath("/a/b").IsSubpathOf("/a"));
UNIT_ASSERT(TFsPath("a/b").IsSubpathOf("a"));
UNIT_ASSERT(!TFsPath("/a/b").IsSubpathOf("/b"));
UNIT_ASSERT(!TFsPath("a/b").IsSubpathOf("b"));
-
+
// mixing absolute/relative
UNIT_ASSERT(!TFsPath("a").IsSubpathOf("/"));
UNIT_ASSERT(!TFsPath("a").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a").IsSubpathOf("a"));
UNIT_ASSERT(!TFsPath("a/b").IsSubpathOf("/a"));
UNIT_ASSERT(!TFsPath("/a/b").IsSubpathOf("a"));
-
-#ifdef _win_
+
+#ifdef _win_
UNIT_ASSERT(TFsPath("x:/a/b").IsSubpathOf("x:/a"));
UNIT_ASSERT(!TFsPath("x:/a/b").IsSubpathOf("y:/a"));
UNIT_ASSERT(!TFsPath("x:/a/b").IsSubpathOf("a"));
-#endif
+#endif
}
-
+
Y_UNIT_TEST(TestNonStrictSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsNonStrictSubpathOf("/a/b"));
@@ -348,7 +348,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(TestUndefined) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath(""));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix());
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath() / TFsPath(), TFsPath());
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a\\b"), TFsPath() / TString("a\\b"));
@@ -363,20 +363,20 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#endif
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), TFsPath() / ".");
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), "." / TFsPath());
-
+
UNIT_ASSERT(TFsPath().PathSplit().empty());
UNIT_ASSERT(!TFsPath().PathSplit().IsAbsolute);
UNIT_ASSERT(TFsPath().IsRelative()); // undefined path is relative
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetPath(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetName(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().GetExtension(), "");
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Parent(), TFsPath());
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Child("a"), TFsPath("a"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Basename(), "");
UNIT_ASSERT_VALUES_EQUAL(TFsPath().Dirname(), "");
-
+
UNIT_ASSERT(!TFsPath().IsSubpathOf("a/b"));
UNIT_ASSERT(TFsPath().IsContainerOf("a/b"));
UNIT_ASSERT(!TFsPath().IsContainerOf("/a/b"));
@@ -385,14 +385,14 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
#else
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a/b").RelativeTo(TFsPath()), TFsPath("a/b"));
#endif
-
+
UNIT_ASSERT(!TFsPath().Exists());
UNIT_ASSERT(!TFsPath().IsFile());
UNIT_ASSERT(!TFsPath().IsDirectory());
TFileStat stat;
UNIT_ASSERT(!TFsPath().Stat(stat));
}
-
+
Y_UNIT_TEST(TestJoinFsPaths) {
#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d");