aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder
diff options
context:
space:
mode:
authordanlark <danlark@yandex-team.ru>2022-02-10 16:46:10 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:10 +0300
commitbaa58daefa91fde4b4769facdbd2903763b9c6a8 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/folder
parent3426a9bc7f169ae9da54cef557ad2a33f6e8eee0 (diff)
downloadydb-baa58daefa91fde4b4769facdbd2903763b9c6a8.tar.gz
Restoring authorship annotation for <danlark@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r--util/folder/dirut.cpp34
-rw-r--r--util/folder/dirut.h4
-rw-r--r--util/folder/filelist.cpp2
-rw-r--r--util/folder/filelist_ut.cpp18
-rw-r--r--util/folder/fts_ut.cpp38
-rw-r--r--util/folder/iterator_ut.cpp2
-rw-r--r--util/folder/path.cpp20
-rw-r--r--util/folder/path.h6
-rw-r--r--util/folder/pathsplit.cpp20
-rw-r--r--util/folder/pathsplit.h2
-rw-r--r--util/folder/tempdir.cpp2
11 files changed, 74 insertions, 74 deletions
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index 57bc56003f..ffc9b09f96 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -19,7 +19,7 @@ void SlashFolderLocal(TString& folder) {
while ((pos = folder.find('/')) != TString::npos)
folder.replace(pos, 1, LOCSLASH_S);
#endif
- if (folder[folder.size() - 1] != LOCSLASH_C)
+ if (folder[folder.size() - 1] != LOCSLASH_C)
folder.append(LOCSLASH_S);
}
@@ -41,10 +41,10 @@ bool resolvepath(TString& folder, const TString& home) {
if (folder.at(0) == '~') {
if (folder.length() == 1 || folder.at(1) == '/') {
- folder = GetHomeDir() + (folder.data() + 1);
+ folder = GetHomeDir() + (folder.data() + 1);
} else {
char* buf = (char*)alloca(folder.length() + 1);
- strcpy(buf, folder.data() + 1);
+ strcpy(buf, folder.data() + 1);
char* p = strchr(buf, '/');
if (p)
*p++ = 0;
@@ -62,10 +62,10 @@ bool resolvepath(TString& folder, const TString& home) {
int len = folder.length() + home.length() + 1;
char* path = (char*)alloca(len);
if (folder.at(0) != '/') {
- strcpy(path, home.data());
- strcpy(strrchr(path, '/') + 1, folder.data()); // the last char must be '/' if it's a dir
+ strcpy(path, home.data());
+ strcpy(strrchr(path, '/') + 1, folder.data()); // the last char must be '/' if it's a dir
} else {
- strcpy(path, folder.data());
+ strcpy(path, folder.data());
}
len = strlen(path) + 1;
// grabbed from url.cpp
@@ -349,8 +349,8 @@ int resolvepath(char* apath, const char* rpath, const char* cpath) {
}
bool correctpath(TString& filename) {
- char* ptr = (char*)alloca(filename.size() + 2);
- if (correctpath(ptr, filename.data())) {
+ char* ptr = (char*)alloca(filename.size() + 2);
+ if (correctpath(ptr, filename.data())) {
filename = ptr;
return true;
}
@@ -358,8 +358,8 @@ bool correctpath(TString& filename) {
}
bool resolvepath(TString& folder, const TString& home) {
- char* ptr = (char*)alloca(folder.size() + 3 + home.size());
- if (resolvepath(ptr, folder.data(), home.data())) {
+ char* ptr = (char*)alloca(folder.size() + 3 + home.size());
+ if (resolvepath(ptr, folder.data(), home.data())) {
folder = ptr;
return true;
}
@@ -406,9 +406,9 @@ TString RealPath(const TString& path) {
TTempBuf result;
Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH
#ifdef _win_
- if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0)
+ if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0)
#else
- if (realpath(path.data(), result.Data()) == nullptr)
+ if (realpath(path.data(), result.Data()) == nullptr)
#endif
ythrow TFileError() << "RealPath failed \"" << path << "\"";
return result.Data();
@@ -419,7 +419,7 @@ TString RealLocation(const TString& path) {
return RealPath(path);
TString dirpath = GetDirName(path);
if (NFs::Exists(dirpath))
- return RealPath(dirpath) + GetDirectorySeparatorS() + GetFileNameComponent(path.data());
+ return RealPath(dirpath) + GetDirectorySeparatorS() + GetFileNameComponent(path.data());
ythrow TFileError() << "RealLocation failed \"" << path << "\"";
}
@@ -434,7 +434,7 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) {
if (!prefix) {
#endif
sysTmp = GetSystemTempDir();
- prefix = sysTmp.data();
+ prefix = sysTmp.data();
}
if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0)
@@ -460,7 +460,7 @@ TString GetHomeDir() {
passwd* pw = nullptr;
s = getenv("USER");
if (s)
- pw = getpwnam(s.data());
+ pw = getpwnam(s.data());
else
pw = getpwuid(getuid());
if (pw)
@@ -580,13 +580,13 @@ int ResolvePath(const char* rel, const char* abs, char res[/*MAXPATHLEN*/], bool
t[len] = 0;
}
if (!realpath(t, res)) {
- if (!isdir && realpath(GetDirName(t).data(), res)) {
+ if (!isdir && realpath(GetDirName(t).data(), res)) {
len = strlen(res);
if (res[len - 1] != LOCSLASH_C) {
res[len++] = LOCSLASH_C;
res[len] = 0;
}
- strcpy(res + len, GetBaseName(t).data());
+ strcpy(res + len, GetBaseName(t).data());
return 0;
}
return errno ? errno : ENOENT;
diff --git a/util/folder/dirut.h b/util/folder/dirut.h
index c707838d81..2537027b12 100644
--- a/util/folder/dirut.h
+++ b/util/folder/dirut.h
@@ -46,7 +46,7 @@ TString GetHomeDir();
void MakeDirIfNotExist(const char* path, int mode = 0777);
inline void MakeDirIfNotExist(const TString& path, int mode = 0777) {
- MakeDirIfNotExist(path.data(), mode);
+ MakeDirIfNotExist(path.data(), mode);
}
/// Create path making parent directories as needed
@@ -64,7 +64,7 @@ void RemoveDirWithContents(TString dirName);
const char* GetFileNameComponent(const char* f);
inline TString GetFileNameComponent(const TString& f) {
- return GetFileNameComponent(f.data());
+ return GetFileNameComponent(f.data());
}
/// RealPath doesn't guarantee trailing separator to be stripped or left in place for directories.
diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp
index 9e33b567e7..b21fcdbf20 100644
--- a/util/folder/filelist.cpp
+++ b/util/folder/filelist.cpp
@@ -32,7 +32,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB
if (((Mask & EM_FILES) && file->fts_info == FTS_F) || ((Mask & EM_DIRS) && file->fts_info == FTS_D) || ((Mask & EM_SLINKS) && file->fts_info == FTS_SL)) {
++FileNamesSize;
- FileNames.Append(filename.data(), filename.size() + 1);
+ FileNames.Append(filename.data(), filename.size() + 1);
}
}
diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp
index f06a5ba332..0cdcdf3d00 100644
--- a/util/folder/filelist_ut.cpp
+++ b/util/folder/filelist_ut.cpp
@@ -20,11 +20,11 @@ public:
void TFileListTest::TestSimple() {
TTempDir tempDir("nonexistingdir");
- MakeDirIfNotExist((tempDir() + LOCSLASH_S "subdir").data());
- TFile((tempDir() + LOCSLASH_S "subdir" LOCSLASH_S "file").data(), CreateAlways);
+ MakeDirIfNotExist((tempDir() + LOCSLASH_S "subdir").data());
+ TFile((tempDir() + LOCSLASH_S "subdir" LOCSLASH_S "file").data(), CreateAlways);
TFileList fileList;
- fileList.Fill(tempDir().data(), "", "", 1000);
+ fileList.Fill(tempDir().data(), "", "", 1000);
TString fileName(fileList.Next());
UNIT_ASSERT_EQUAL(fileName, "subdir" LOCSLASH_S "file");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
@@ -32,21 +32,21 @@ void TFileListTest::TestSimple() {
void TFileListTest::TestPrefix() {
TTempDir tempDir("nonexistingdir");
- TFile((tempDir() + LOCSLASH_S "good_file1").data(), CreateAlways);
- TFile((tempDir() + LOCSLASH_S "good_file2").data(), CreateAlways);
- TFile((tempDir() + LOCSLASH_S "bad_file1").data(), CreateAlways);
- TFile((tempDir() + LOCSLASH_S "bad_file2").data(), CreateAlways);
+ TFile((tempDir() + LOCSLASH_S "good_file1").data(), CreateAlways);
+ TFile((tempDir() + LOCSLASH_S "good_file2").data(), CreateAlways);
+ TFile((tempDir() + LOCSLASH_S "bad_file1").data(), CreateAlways);
+ TFile((tempDir() + LOCSLASH_S "bad_file2").data(), CreateAlways);
const bool SORT = true;
TFileList fileList;
{
- fileList.Fill(tempDir().data(), "good_file", SORT);
+ fileList.Fill(tempDir().data(), "good_file", SORT);
UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file1");
UNIT_ASSERT_EQUAL(TString(fileList.Next()), "good_file2");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
}
{
- fileList.Fill(tempDir().data(), "bad_file", SORT);
+ fileList.Fill(tempDir().data(), "bad_file", SORT);
UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file1");
UNIT_ASSERT_EQUAL(TString(fileList.Next()), "bad_file2");
UNIT_ASSERT_EQUAL(fileList.Next(), nullptr);
diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp
index 02622aff4e..c5d59e35f4 100644
--- a/util/folder/fts_ut.cpp
+++ b/util/folder/fts_ut.cpp
@@ -58,27 +58,27 @@ void TFtsTest::TestSimple() {
TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp);
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());
- MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data());
- 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};
+ MakeDirIfNotExist(tempDir().data());
+ MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir1").data());
+ MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data());
+ MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data());
+ 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());
- 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);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data(), FTS_F);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_DP);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_D);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data(), FTS_F);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data(), FTS_F);
- CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP);
- CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP);
+ 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);
+ CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file2").data(), FTS_F);
+ CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_DP);
+ CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_D);
+ CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data(), FTS_F);
+ CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data(), FTS_F);
+ 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);
}
diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp
index c6c756b999..936becd139 100644
--- a/util/folder/iterator_ut.cpp
+++ b/util/folder/iterator_ut.cpp
@@ -56,7 +56,7 @@ private:
break;
case 1:
- MakeDirIfNotExist(path.Path.data());
+ MakeDirIfNotExist(path.Path.data());
break;
case 2:
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index 0d5400fd14..bfe0c67d68 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -93,11 +93,11 @@ TFsPath TFsPath::RelativePath(const TFsPath& root) const {
for (size_t i = 0; i < rsplit.size() - cnt; i++) {
r += i == 0 ? ".." : "/..";
}
- for (size_t i = cnt; i < split.size(); i++) {
- r += (i == 0 || i == cnt && rsplit.size() - cnt == 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();
+ return r.size() ? TFsPath(r) : TFsPath();
}
TFsPath TFsPath::Parent() const {
@@ -230,7 +230,7 @@ struct TClosedir {
void TFsPath::ListNames(TVector<TString>& children) const {
CheckDefined();
- THolder<DIR, TClosedir> dir(opendir(this->c_str()));
+ THolder<DIR, TClosedir> dir(opendir(this->c_str()));
if (!dir) {
ythrow TIoSystemError() << "failed to opendir " << Path_;
}
@@ -340,15 +340,15 @@ void TFsPath::CheckExists() const {
}
bool TFsPath::IsDirectory() const {
- return IsDefined() && TFileStat(GetPath().data()).IsDir();
+ return IsDefined() && TFileStat(GetPath().data()).IsDir();
}
bool TFsPath::IsFile() const {
- return IsDefined() && TFileStat(GetPath().data()).IsFile();
+ return IsDefined() && TFileStat(GetPath().data()).IsFile();
}
bool TFsPath::IsSymlink() const {
- return IsDefined() && TFileStat(GetPath().data(), true).IsSymlink();
+ return IsDefined() && TFileStat(GetPath().data(), true).IsSymlink();
}
void TFsPath::DeleteIfExists() const {
@@ -356,8 +356,8 @@ void TFsPath::DeleteIfExists() const {
return;
}
- ::unlink(this->c_str());
- ::rmdir(this->c_str());
+ ::unlink(this->c_str());
+ ::rmdir(this->c_str());
if (Exists()) {
ythrow TIoException() << "failed to delete " << Path_;
}
@@ -366,7 +366,7 @@ void TFsPath::DeleteIfExists() const {
void TFsPath::MkDir(const int mode) const {
CheckDefined();
if (!Exists()) {
- int r = Mkdir(this->c_str(), mode);
+ 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
diff --git a/util/folder/path.h b/util/folder/path.h
index f90f0b70e9..2fb4d6b4ef 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -44,8 +44,8 @@ public:
return IsDefined();
}
- inline const char* c_str() const {
- return Path_.c_str();
+ inline const char* c_str() const {
+ return Path_.c_str();
}
inline operator const TString&() const {
@@ -166,7 +166,7 @@ public:
// XXX: ino
inline bool Stat(TFileStat& stat) const {
- stat = TFileStat(Path_.data());
+ stat = TFileStat(Path_.data());
return stat.Mode;
}
diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp
index e24ca90203..81d439a727 100644
--- a/util/folder/pathsplit.cpp
+++ b/util/folder/pathsplit.cpp
@@ -31,7 +31,7 @@ void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) {
}
void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) {
- DoAppendHint(part0.size() / 8);
+ DoAppendHint(part0.size() / 8);
TStringBuf next(part0);
TStringBuf part;
@@ -55,7 +55,7 @@ void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) {
if (IsAbsolutePath(part)) {
IsAbsolute = true;
- if (part.size() > 1 && part[1] == ':') {
+ if (part.size() > 1 && part[1] == ':') {
Drive = part.SubStr(0, 2);
part = part.SubStr(2);
}
@@ -65,23 +65,23 @@ void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) {
}
void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) {
- DoAppendHint(part0.size() / 8);
+ DoAppendHint(part0.size() / 8);
size_t pos = 0;
TStringBuf part(part0);
- while (pos < part.size()) {
- while (pos < part.size() && this->IsPathSep(part[pos])) {
+ while (pos < part.size()) {
+ while (pos < part.size() && this->IsPathSep(part[pos])) {
++pos;
}
- const char* begin = part.data() + pos;
+ const char* begin = part.data() + pos;
- while (pos < part.size() && !this->IsPathSep(part[pos])) {
+ while (pos < part.size() && !this->IsPathSep(part[pos])) {
++pos;
}
- AppendComponent(TStringBuf(begin, part.data() + pos));
+ AppendComponent(TStringBuf(begin, part.data() + pos));
}
}
@@ -135,14 +135,14 @@ TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) {
}
TStringBuf CutExtension(const TStringBuf fileName) {
- if (fileName.empty()) {
+ if (fileName.empty()) {
return fileName;
}
TStringBuf name;
TStringBuf extension;
fileName.RSplit('.', name, extension);
- if (name.empty()) {
+ if (name.empty()) {
// dot at a start or not found
return name;
} else {
diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h
index 94eacb49a7..d134338e35 100644
--- a/util/folder/pathsplit.h
+++ b/util/folder/pathsplit.h
@@ -52,7 +52,7 @@ struct TPathSplitTraitsWindows: public TPathSplitStore {
}
static inline bool IsAbsolutePath(const TStringBuf path) noexcept {
- return path && (IsPathSep(path[0]) || (path.size() > 1 && path[1] == ':' && IsAsciiAlpha(path[0]) && (path.size() == 2 || IsPathSep(path[2]))));
+ return path && (IsPathSep(path[0]) || (path.size() > 1 && path[1] == ':' && IsAsciiAlpha(path[0]) && (path.size() == 2 || IsPathSep(path[2]))));
}
void DoParseFirstPart(const TStringBuf part);
diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp
index f66d41bf5f..6fdf8f753c 100644
--- a/util/folder/tempdir.cpp
+++ b/util/folder/tempdir.cpp
@@ -26,7 +26,7 @@ TTempDir::TTempDir(const TString& tempDir)
, Remove(true)
{
NFs::Remove(TempDir);
- MakeDirIfNotExist(TempDir.c_str());
+ MakeDirIfNotExist(TempDir.c_str());
}
TTempDir TTempDir::NewTempDir(const TString& root) {