aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder
diff options
context:
space:
mode:
authorkakabba <kakabba@yandex-team.ru>2022-02-10 16:46:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:04 +0300
commitc8e3995898c443e78266f7420aac5fb3da15d413 (patch)
treea530e068cc107e227deccc80722204db63a4d75d /util/folder
parent110a978b66fe6c0916572df51cfead2a9b647174 (diff)
downloadydb-c8e3995898c443e78266f7420aac5fb3da15d413.tar.gz
Restoring authorship annotation for <kakabba@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r--util/folder/dirut.cpp14
-rw-r--r--util/folder/path.cpp24
-rw-r--r--util/folder/path.h4
-rw-r--r--util/folder/path_ut.cpp4
4 files changed, 23 insertions, 23 deletions
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index ffc9b09f96..1c261c9dd7 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -399,9 +399,9 @@ int mkpath(char* path, int mode) {
return NFs::MakeDirectoryRecursive(path, NFs::EFilePermission(mode)) ? 0 : -1;
}
-// Implementation of realpath in FreeBSD (version 9.0 and less) and GetFullPathName in Windows
-// did not require last component of the file name to exist (other implementations will fail
-// if it does not). Use RealLocation if that behaviour is required.
+// Implementation of realpath in FreeBSD (version 9.0 and less) and GetFullPathName in Windows
+// did not require last component of the file name to exist (other implementations will fail
+// if it does not). Use RealLocation if that behaviour is required.
TString RealPath(const TString& path) {
TTempBuf result;
Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH
@@ -416,13 +416,13 @@ TString RealPath(const TString& path) {
TString RealLocation(const TString& path) {
if (NFs::Exists(path))
- return RealPath(path);
+ return RealPath(path);
TString dirpath = GetDirName(path);
if (NFs::Exists(dirpath))
return RealPath(dirpath) + GetDirectorySeparatorS() + GetFileNameComponent(path.data());
- ythrow TFileError() << "RealLocation failed \"" << path << "\"";
-}
-
+ ythrow TFileError() << "RealLocation failed \"" << path << "\"";
+}
+
int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
int ret;
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index bfe0c67d68..c8f440d669 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -77,29 +77,29 @@ TFsPath TFsPath::RelativeTo(const TFsPath& root) const {
return TFsPath(split.Reconstruct());
}
-TFsPath TFsPath::RelativePath(const TFsPath& root) const {
- TSplit split = GetSplit();
- const TSplit& rsplit = root.GetSplit();
- size_t cnt = 0;
+TFsPath TFsPath::RelativePath(const TFsPath& root) const {
+ TSplit split = GetSplit();
+ const TSplit& rsplit = root.GetSplit();
+ size_t cnt = 0;
while (split.size() > cnt && rsplit.size() > cnt && split[cnt] == rsplit[cnt]) {
++cnt;
}
bool absboth = split.IsAbsolute && rsplit.IsAbsolute;
if (cnt == 0 && !absboth) {
- ythrow TIoException() << "No common parts in " << *this << " and " << root;
+ ythrow TIoException() << "No common parts in " << *this << " and " << root;
}
TString r;
for (size_t i = 0; i < rsplit.size() - cnt; i++) {
- r += i == 0 ? ".." : "/..";
+ r += i == 0 ? ".." : "/..";
}
for (size_t i = cnt; i < split.size(); i++) {
r += (i == 0 || i == cnt && rsplit.size() - cnt == 0 ? "" : "/");
r += split[i];
}
return r.size() ? TFsPath(r) : TFsPath();
-}
-
+}
+
TFsPath TFsPath::Parent() const {
if (!IsDefined()) {
return TFsPath();
@@ -314,11 +314,11 @@ TFsPath TFsPath::RealPath() const {
return ::RealPath(*this);
}
-TFsPath TFsPath::RealLocation() const {
- CheckDefined();
+TFsPath TFsPath::RealLocation() const {
+ CheckDefined();
return ::RealLocation(*this);
-}
-
+}
+
TFsPath TFsPath::ReadLink() const {
CheckDefined();
diff --git a/util/folder/path.h b/util/folder/path.h
index 2fb4d6b4ef..68a03bd85e 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -119,7 +119,7 @@ public:
/**
* @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
+ TFsPath RelativePath(const TFsPath& root) const; //..; for relative paths 1st component must be the same
/**
* Never fails. Returns this if already a root.
@@ -191,7 +191,7 @@ public:
void Touch() const;
TFsPath RealPath() const;
- TFsPath RealLocation() const;
+ TFsPath RealLocation() const;
TFsPath ReadLink() const;
/// always absolute
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index e6a3451016..1d6ce221aa 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -266,7 +266,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
Y_UNIT_TEST(Cwd) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath::Cwd().RealPath(), TFsPath(".").RealPath());
}
-
+
Y_UNIT_TEST(TestSubpathOf) {
UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b"));
@@ -344,7 +344,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_EXCEPTION(TFsPath("a/b/c").RelativePath(TFsPath("d/e")), TIoException);
}
-
+
Y_UNIT_TEST(TestUndefined) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath(""));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix());