diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /util/folder | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r-- | util/folder/dirent_win.c | 2 | ||||
-rw-r--r-- | util/folder/dirut.cpp | 36 | ||||
-rw-r--r-- | util/folder/dirut.h | 4 | ||||
-rw-r--r-- | util/folder/filelist.cpp | 2 | ||||
-rw-r--r-- | util/folder/filelist.h | 4 | ||||
-rw-r--r-- | util/folder/filelist_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/fts.cpp | 102 | ||||
-rw-r--r-- | util/folder/fts.h | 2 | ||||
-rw-r--r-- | util/folder/fts_ut.cpp | 4 | ||||
-rw-r--r-- | util/folder/iterator.h | 4 | ||||
-rw-r--r-- | util/folder/iterator_ut.cpp | 4 | ||||
-rw-r--r-- | util/folder/path.cpp | 64 | ||||
-rw-r--r-- | util/folder/path.h | 12 | ||||
-rw-r--r-- | util/folder/path_ut.cpp | 78 | ||||
-rw-r--r-- | util/folder/pathsplit.cpp | 14 | ||||
-rw-r--r-- | util/folder/pathsplit.h | 30 | ||||
-rw-r--r-- | util/folder/pathsplit_ut.cpp | 64 | ||||
-rw-r--r-- | util/folder/tempdir.cpp | 2 |
18 files changed, 215 insertions, 215 deletions
diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c index 7e6db74ce5..3eef8c9762 100644 --- a/util/folder/dirent_win.c +++ b/util/folder/dirent_win.c @@ -39,7 +39,7 @@ struct DIR* opendir(const char* dirname) { closedir(dir); return NULL; } - dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); + dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); if (!dir->fff_templ) { closedir(dir); return NULL; diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f96..ebb1854c28 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -5,8 +5,8 @@ #include "pathsplit.h" #include "path.h" -#include <util/generic/yexception.h> -#include <util/system/compiler.h> +#include <util/generic/yexception.h> +#include <util/system/compiler.h> #include <util/system/fs.h> #include <util/system/maxlen.h> #include <util/system/yassert.h> @@ -30,13 +30,13 @@ bool correctpath(TString& folder) { } bool resolvepath(TString& folder, const TString& home) { - Y_ASSERT(home && home.at(0) == '/'); + Y_ASSERT(home && home.at(0) == '/'); if (!folder) { return false; } // may be from windows char* ptr = folder.begin(); - while ((ptr = strchr(ptr, '\\')) != nullptr) + while ((ptr = strchr(ptr, '\\')) != nullptr) *ptr = '/'; if (folder.at(0) == '~') { @@ -383,14 +383,14 @@ void RemoveDirWithContents(TString dirName) { for (auto it = dir.begin(); it != dir.end(); ++it) { switch (it->fts_info) { - case FTS_F: - case FTS_DEFAULT: - case FTS_DP: - case FTS_SL: - case FTS_SLNONE: - if (!NFs::Remove(it->fts_path)) - ythrow TSystemError() << "error while removing " << it->fts_path; - break; + case FTS_F: + case FTS_DEFAULT: + case FTS_DP: + case FTS_SL: + case FTS_SLNONE: + if (!NFs::Remove(it->fts_path)) + ythrow TSystemError() << "error while removing " << it->fts_path; + break; } } } @@ -404,7 +404,7 @@ int mkpath(char* path, int mode) { // 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 + Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH #ifdef _win_ if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0) #else @@ -437,7 +437,7 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) { prefix = sysTmp.data(); } - if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0) + if ((ret = ResolvePath(prefix, nullptr, path, 1)) != 0) return ret; if (!TFileStat(path).IsDir()) return ENOENT; @@ -457,7 +457,7 @@ TString GetHomeDir() { TString s(getenv("HOME")); if (!s) { #ifndef _win32_ - passwd* pw = nullptr; + passwd* pw = nullptr; s = getenv("USER"); if (s) pw = getpwnam(s.data()); @@ -468,7 +468,7 @@ TString GetHomeDir() { else #endif { - char* cur_dir = getcwd(nullptr, 0); + char* cur_dir = getcwd(nullptr, 0); s = cur_dir; free(cur_dir); } @@ -477,8 +477,8 @@ TString GetHomeDir() { } void MakeDirIfNotExist(const char* path, int mode) { - if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { - ythrow TSystemError() << "failed to create directory " << path; + if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { + ythrow TSystemError() << "failed to create directory " << path; } } diff --git a/util/folder/dirut.h b/util/folder/dirut.h index 2537027b12..c2b870ae0c 100644 --- a/util/folder/dirut.h +++ b/util/folder/dirut.h @@ -106,11 +106,11 @@ public: const char* Check(const char* fname) const { if (!fname || !*fname) - return nullptr; + return nullptr; if (Strict) { NFs::EnsureExists(fname); } else if (!NFs::Exists(fname)) - fname = nullptr; + fname = nullptr; return fname; } diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp index b21fcdbf20..87f2c69b2d 100644 --- a/util/folder/filelist.cpp +++ b/util/folder/filelist.cpp @@ -26,7 +26,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB TStringBuf filename = file->fts_path + dirNameLength + 1; - if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) { + if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) { continue; } diff --git a/util/folder/filelist.h b/util/folder/filelist.h index 3f615fa4c2..a0f6e86ead 100644 --- a/util/folder/filelist.h +++ b/util/folder/filelist.h @@ -26,14 +26,14 @@ public: } void Clear() { - Cur = nullptr; + Cur = nullptr; FileNamesSize = CurName = 0; FileNames.Clear(); FileNames.Append("", 1); } const char* Next() { - return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr); + return Cur = (CurName++ < FileNamesSize ? strchr(Cur, 0) + 1 : nullptr); } size_t Size() { diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp index 0cdcdf3d00..ec023f5094 100644 --- a/util/folder/filelist_ut.cpp +++ b/util/folder/filelist_ut.cpp @@ -27,7 +27,7 @@ void TFileListTest::TestSimple() { fileList.Fill(tempDir().data(), "", "", 1000); TString fileName(fileList.Next()); UNIT_ASSERT_EQUAL(fileName, "subdir" LOCSLASH_S "file"); - UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); + UNIT_ASSERT_EQUAL(fileList.Next(), nullptr); } void TFileListTest::TestPrefix() { diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index 0e6a6f86eb..4ab22a94bf 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -33,9 +33,9 @@ * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ */ -#include <util/memory/tempbuf.h> -#include <util/system/compat.h> -#include <util/system/compiler.h> +#include <util/memory/tempbuf.h> +#include <util/system/compat.h> +#include <util/system/compiler.h> #include <util/system/defaults.h> #include <util/system/error.h> @@ -110,14 +110,14 @@ int stat64UTF(dird path, struct _stat64* _Stat) { return _wstat64(path, _Stat); } -const dird invalidDirD = nullptr; +const dird invalidDirD = nullptr; dird get_cwdd() { return _wgetcwd(nullptr, 0); } int valid_dird(dird fd) { - return fd == nullptr; + return fd == nullptr; } void close_dird(dird fd) { @@ -258,19 +258,19 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con /* Options check. */ if (options & ~FTS_OPTIONMASK) { errno = EINVAL; - return nullptr; + return nullptr; } /* Allocate/initialize the stream */ if ((sp = (FTS*)malloc(sizeof(FTS))) == nullptr) { - return nullptr; + return nullptr; } memset(sp, 0, sizeof(FTS)); sp->fts_compar = compar; sp->fts_options = options; /* Shush, GCC. */ - tmp = nullptr; + tmp = nullptr; /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ if (ISSET(FTS_LOGICAL)) { @@ -292,7 +292,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con parent->fts_level = FTS_ROOTPARENTLEVEL; /* Allocate/initialize root(s). */ - for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) { + for (root = nullptr, nitems = 0; *argv; ++argv, ++nitems) { /* Don't allow zero-length paths. */ len = strlen(*argv); @@ -329,7 +329,7 @@ FTS* yfts_open(char* const* argv, int options, int (*compar)(const FTSENT**, con p->fts_link = root; root = p; } else { - p->fts_link = nullptr; + p->fts_link = nullptr; if (root == nullptr) { tmp = root = p; } else { @@ -375,7 +375,7 @@ mem2: free(sp->fts_path); mem1: free(sp); - return nullptr; + return nullptr; } static void @@ -393,7 +393,7 @@ fts_load(FTS* sp, FTSENT* p) */ len = p->fts_pathlen = p->fts_namelen; memmove((void*)sp->fts_path, (void*)p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) { + if ((cp = strrchr(p->fts_name, LOCSLASH_C)) != nullptr && (cp != p->fts_name || cp[1])) { len = strlen(++cp); memmove((void*)p->fts_name, (void*)cp, len + 1); p->fts_namelen = (u_short)len; @@ -469,7 +469,7 @@ yfts_read(FTS* sp) { /* If finished or unrecoverable error, return NULL. */ if (sp->fts_cur == nullptr || ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } /* Set current node pointer. */ @@ -517,7 +517,7 @@ yfts_read(FTS* sp) { } if (sp->fts_child) { fts_lfree(sp->fts_child); - sp->fts_child = nullptr; + sp->fts_child = nullptr; } p->fts_info = FTS_DP; return (p); @@ -527,7 +527,7 @@ yfts_read(FTS* sp) { if (sp->fts_child && ISSET(FTS_NAMEONLY)) { CLR(FTS_NAMEONLY); fts_lfree(sp->fts_child); - sp->fts_child = nullptr; + sp->fts_child = nullptr; } /* @@ -551,21 +551,21 @@ yfts_read(FTS* sp) { p->fts_parent->fts_accpath; } } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) { + } else if ((sp->fts_child = fts_build(sp, BREAD)) == nullptr) { if (ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } return (p); } p = sp->fts_child; - sp->fts_child = nullptr; + sp->fts_child = nullptr; goto name; } /* Move to the next node on this level. */ next: tmp = p; - if ((p = p->fts_link) != nullptr) { + if ((p = p->fts_link) != nullptr) { free(tmp); /* @@ -575,7 +575,7 @@ next: if (p->fts_level == FTS_ROOTLEVEL) { if (FCHDIR(sp, sp->fts_rfd)) { SET(FTS_STOP); - return nullptr; + return nullptr; } fts_load(sp, p); return (sp->fts_cur = p); @@ -622,7 +622,7 @@ next: */ free(p); errno = 0; - return (sp->fts_cur = nullptr); + return (sp->fts_cur = nullptr); } /* NUL terminate the pathname. */ @@ -636,7 +636,7 @@ next: if (p->fts_level == FTS_ROOTLEVEL) { if (FCHDIR(sp, sp->fts_rfd)) { SET(FTS_STOP); - return nullptr; + return nullptr; } } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { @@ -644,7 +644,7 @@ next: close_dird(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); - return nullptr; + return nullptr; } close_dird(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR) && @@ -682,7 +682,7 @@ yfts_children(FTS* sp, int instr) dird fd; if (instr && instr != FTS_NAMEONLY) { errno = EINVAL; - return nullptr; + return nullptr; } /* Set current node pointer. */ @@ -696,7 +696,7 @@ yfts_children(FTS* sp, int instr) /* Fatal errors stop here. */ if (ISSET(FTS_STOP)) { - return nullptr; + return nullptr; } /* Return logical hierarchy of user's arguments. */ @@ -710,7 +710,7 @@ yfts_children(FTS* sp, int instr) * same effect is available with FTS_AGAIN. */ if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) { - return nullptr; + return nullptr; } /* Free up any previous child list. */ @@ -738,28 +738,28 @@ yfts_children(FTS* sp, int instr) } if (valid_dird(fd = get_cwdd())) { - return nullptr; + return nullptr; } sp->fts_child = fts_build(sp, instr); if (chdir_dird(fd)) { close_dird(fd); - return nullptr; + return nullptr; } close_dird(fd); return (sp->fts_child); } static inline struct dirent* yreaddir(DIR* dir, struct dirent* de) { - // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper - // alternative - Y_PRAGMA_DIAGNOSTIC_PUSH - Y_PRAGMA_NO_DEPRECATED + // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper + // alternative + Y_PRAGMA_DIAGNOSTIC_PUSH + Y_PRAGMA_NO_DEPRECATED if (readdir_r(dir, de, &de) == 0) { Y_PRAGMA_DIAGNOSTIC_POP return de; } - return nullptr; + return nullptr; } /* @@ -811,12 +811,12 @@ fts_build(FTS* sp, int type) #else #define __opendir2(path, flag) opendir(path) #endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) { + if ((dirp = __opendir2(cur->fts_accpath, oflag)) == nullptr) { if (type == BREAD) { cur->fts_info = FTS_DNR; cur->fts_errno = errno; } - return nullptr; + return nullptr; } #ifdef _win_ @@ -858,7 +858,7 @@ fts_build(FTS* sp, int type) cderrno = 0; if (nlinks || type == BREAD) { #ifndef _win_ - if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) { + if (fts_safe_changedir(sp, cur, dirfd(dirp), nullptr)) { #else if (fts_safe_changedir(sp, cur, -1, dirpd)) { #endif @@ -870,12 +870,12 @@ fts_build(FTS* sp, int type) descend = 0; cderrno = errno; (void)closedir(dirp); - dirp = nullptr; + dirp = nullptr; #ifdef _win_ close_dird(dirpd); dirpd = invalidDirD; #else - Y_UNUSED(invalidDirD); + Y_UNUSED(invalidDirD); #endif } else { descend = 1; @@ -900,7 +900,7 @@ fts_build(FTS* sp, int type) *cp++ = LOCSLASH_C; } else { /* GCC, you're too verbose. */ - cp = nullptr; + cp = nullptr; } ++len; maxlen = sp->fts_pathlen - len; @@ -913,7 +913,7 @@ fts_build(FTS* sp, int type) //to ensure enough buffer TTempBuf dpe; - for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) { + for (head = tail = nullptr, nitems = 0; dirp && (dp = yreaddir(dirp, (struct dirent*)dpe.Data())) != nullptr;) { if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) { continue; } @@ -942,7 +942,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); errno = saved_errno; - return nullptr; + return nullptr; } /* Did realloc() change the pointer? */ if (oldaddr != sp->fts_path) { @@ -970,7 +970,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); errno = ENAMETOOLONG; - return nullptr; + return nullptr; } p->fts_level = (short)level; p->fts_parent = sp->fts_cur; @@ -1029,7 +1029,7 @@ fts_build(FTS* sp, int type) } /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = nullptr; + p->fts_link = nullptr; if (head == nullptr) { head = tail = p; } else { @@ -1076,7 +1076,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_ERR; SET(FTS_STOP); fts_lfree(head); - return nullptr; + return nullptr; } /* If didn't find anything, return NULL. */ @@ -1085,7 +1085,7 @@ fts_build(FTS* sp, int type) cur->fts_info = FTS_DP; } fts_lfree(head); - return nullptr; + return nullptr; } /* Sort the entries. */ @@ -1206,7 +1206,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems) if (sp->fts_array) { free(sp->fts_array); } - sp->fts_array = nullptr; + sp->fts_array = nullptr; sp->fts_nitems = 0; return (head); } @@ -1219,7 +1219,7 @@ fts_sort(FTS* sp, FTSENT* head, int nitems) for (head = *(ap = sp->fts_array); --nitems; ++ap) { ap[0]->fts_link = ap[1]; } - ap[0]->fts_link = nullptr; + ap[0]->fts_link = nullptr; return (head); } @@ -1242,7 +1242,7 @@ fts_alloc(FTS* sp, const char* name, int namelen) len += sizeof(stat_struct) + ALIGNBYTES; } if ((p = (FTSENT*)malloc(len)) == nullptr) { - return nullptr; + return nullptr; } /* Copy the name and guarantee NUL termination. */ @@ -1258,7 +1258,7 @@ fts_alloc(FTS* sp, const char* name, int namelen) p->fts_flags = 0; p->fts_instr = FTS_NOINSTR; p->fts_number = 0; - p->fts_pointer = nullptr; + p->fts_pointer = nullptr; p->fts_type = FTS_NSOK; return (p); } @@ -1269,7 +1269,7 @@ fts_lfree(FTSENT* head) FTSENT* p; /* Free a linked list of structures. */ - while ((p = head) != nullptr) { + while ((p = head) != nullptr) { head = head->fts_link; free(p); } @@ -1286,7 +1286,7 @@ fts_palloc(FTS* sp, size_t more) { sp->fts_pathlen += more + 256; sp->fts_path = (char*)yreallocf(sp->fts_path, (size_t)sp->fts_pathlen); - return (sp->fts_path == nullptr); + return (sp->fts_path == nullptr); } static void diff --git a/util/folder/fts.h b/util/folder/fts.h index f3c799e8c8..8b25d9eacd 100644 --- a/util/folder/fts.h +++ b/util/folder/fts.h @@ -17,7 +17,7 @@ typedef struct _stat64 stat_struct; #define STAT_FUNC stat64UTF //TODO: remove from global scope stat64UTF stat64UTF #ifdef __cplusplus -int stat64UTF(const char* path, struct _stat64* _Stat); +int stat64UTF(const char* path, struct _stat64* _Stat); int stat64UTF(dird path, struct _stat64* _Stat); #endif #endif diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp index c5d59e35f4..7fffa5ecb0 100644 --- a/util/folder/fts_ut.cpp +++ b/util/folder/fts_ut.cpp @@ -54,7 +54,7 @@ private: }; void TFtsTest::TestSimple() { - const char* dotPath[2] = {"." LOCSLASH_S, nullptr}; + 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); @@ -79,7 +79,7 @@ void TFtsTest::TestSimple() { 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); + UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr); } class TTempDirWithLostAccess: public TTempDir { diff --git a/util/folder/iterator.h b/util/folder/iterator.h index 69e025b9c4..04a254c3bb 100644 --- a/util/folder/iterator.h +++ b/util/folder/iterator.h @@ -58,7 +58,7 @@ public: inline void Init(int opts) noexcept { FtsOptions = opts | FTS_NOCHDIR; MaxLevel = Max<size_t>(); - Cmp = nullptr; + Cmp = nullptr; } }; @@ -67,7 +67,7 @@ public: , Path_(path) { Trees_[0] = Path_.begin(); - Trees_[1] = nullptr; + Trees_[1] = nullptr; ClearLastSystemError(); FileTree_.Reset(yfts_open(Trees_, Options_.FtsOptions, Options_.Cmp)); diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp index 936becd139..2dccaadff1 100644 --- a/util/folder/iterator_ut.cpp +++ b/util/folder/iterator_ut.cpp @@ -11,8 +11,8 @@ static TString JoinWithNewline(const TVector<TString>& strings) { TStringStream ss; - for (const auto& string : strings) { - ss << string << "\n"; + for (const auto& string : strings) { + ss << string << "\n"; } return ss.Str(); } diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..309fed0446 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -1,15 +1,15 @@ -#include "dirut.h" +#include "dirut.h" #include "path.h" #include "pathsplit.h" -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> #include <util/string/cast.h> -#include <util/system/compiler.h> -#include <util/system/file.h> +#include <util/system/compiler.h> +#include <util/system/file.h> #include <util/system/fs.h> struct TFsPath::TSplit: public TAtomicRefCount<TSplit>, public TPathSplit { - inline TSplit(const TStringBuf path) + inline TSplit(const TStringBuf path) : TPathSplit(path) { } @@ -187,7 +187,7 @@ TFsPath::TSplit& TFsPath::GetSplit() const { } static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { - Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); + Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); } TFsPath::TFsPath() { @@ -199,7 +199,7 @@ TFsPath::TFsPath(const TString& path) VerifyPath(Path_); } -TFsPath::TFsPath(const TStringBuf path) +TFsPath::TFsPath(const TStringBuf path) : Path_(ToString(path)) { VerifyPath(Path_); @@ -231,19 +231,19 @@ struct TClosedir { void TFsPath::ListNames(TVector<TString>& children) const { CheckDefined(); THolder<DIR, TClosedir> dir(opendir(this->c_str())); - if (!dir) { + if (!dir) { ythrow TIoSystemError() << "failed to opendir " << Path_; - } - + } + for (;;) { struct dirent de; struct dirent* ok; - // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper - // alternative - Y_PRAGMA_DIAGNOSTIC_PUSH - Y_PRAGMA_NO_DEPRECATED + // TODO(yazevnul|IGNIETFERRO-1070): remove these macroses by replacing `readdir_r` with proper + // alternative + Y_PRAGMA_DIAGNOSTIC_PUSH + Y_PRAGMA_NO_DEPRECATED int r = readdir_r(dir.Get(), &de, &ok); - Y_PRAGMA_DIAGNOSTIC_POP + Y_PRAGMA_DIAGNOSTIC_POP if (r != 0) { ythrow TIoSystemError() << "failed to readdir " << Path_; } @@ -278,8 +278,8 @@ bool TFsPath::Contains(const TString& component) const { void TFsPath::List(TVector<TFsPath>& files) const { TVector<TString> names; ListNames(names); - for (auto& name : names) { - files.push_back(Child(name)); + for (auto& name : names) { + files.push_back(Child(name)); } } @@ -409,8 +409,8 @@ void TFsPath::ForceDelete() const { if (stat.IsDir()) { TVector<TFsPath> children; List(children); - for (auto& i : children) { - i.ForceDelete(); + for (auto& i : children) { + i.ForceDelete(); } ::rmdir(this->c_str()); } else { @@ -467,21 +467,21 @@ const TPathSplit& TFsPath::PathSplit() const { } template <> -void Out<TFsPath>(IOutputStream& os, const TFsPath& f) { +void Out<TFsPath>(IOutputStream& os, const TFsPath& f) { os << f.GetPath(); } template <> -TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) { - return TFsPath{TStringBuf{s, len}}; -} - -template <> -bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) { - try { - result = TStringBuf{s, len}; - return true; +TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) { + return TFsPath{TStringBuf{s, len}}; +} + +template <> +bool TryFromStringImpl(const char* s, size_t len, TFsPath& result) { + try { + result = TStringBuf{s, len}; + return true; } catch (std::exception&) { - return false; - } -} + return false; + } +} diff --git a/util/folder/path.h b/util/folder/path.h index 2fb4d6b4ef..9a85acc637 100644 --- a/util/folder/path.h +++ b/util/folder/path.h @@ -3,15 +3,15 @@ #include "fwd.h" #include "pathsplit.h" -#include <util/generic/ptr.h> -#include <util/generic/strbuf.h> +#include <util/generic/ptr.h> +#include <util/generic/strbuf.h> #include <util/generic/string.h> -#include <util/generic/vector.h> -#include <util/string/cast.h> +#include <util/generic/vector.h> +#include <util/string/cast.h> #include <util/system/fstat.h> #include <util/system/platform.h> #include <util/system/sysstat.h> -#include <util/system/yassert.h> +#include <util/system/yassert.h> #include <utility> @@ -26,7 +26,7 @@ private: public: TFsPath(); TFsPath(const TString& path); - TFsPath(const TStringBuf path); + TFsPath(const TStringBuf path); TFsPath(const char* path); TFsPath(const std::string& path) diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp index e6a3451016..7c8f12865a 100644 --- a/util/folder/path_ut.cpp +++ b/util/folder/path_ut.cpp @@ -39,7 +39,7 @@ namespace { }; TTestDirectory::TTestDirectory(const TString& name) { - Y_VERIFY(name.length() > 0, "have to specify name"); + Y_VERIFY(name.length() > 0, "have to specify name"); Y_VERIFY(name.find('.') == TString::npos, "must be simple name"); Y_VERIFY(name.find('/') == TString::npos, "must be simple name"); Y_VERIFY(name.find('\\') == TString::npos, "must be simple name"); @@ -54,8 +54,8 @@ namespace { } } -Y_UNIT_TEST_SUITE(TFsPathTests) { - Y_UNIT_TEST(TestMkDirs) { +Y_UNIT_TEST_SUITE(TFsPathTests) { + Y_UNIT_TEST(TestMkDirs) { const TFsPath path = "a/b/c/d/e/f"; path.ForceDelete(); TFsPath current = path; @@ -77,7 +77,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } } - Y_UNIT_TEST(MkDirFreak) { + Y_UNIT_TEST(MkDirFreak) { TFsPath path; UNIT_ASSERT_EXCEPTION(path.MkDir(), TIoException); UNIT_ASSERT_EXCEPTION(path.MkDirs(), TIoException); @@ -86,7 +86,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { path.MkDirs(); } - Y_UNIT_TEST(Parent) { + Y_UNIT_TEST(Parent) { #ifdef _win_ UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc/passwd").Parent(), TFsPath("\\etc")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc").Parent(), TFsPath("\\")); @@ -117,7 +117,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(GetName) { + Y_UNIT_TEST(GetName) { TTestDirectory d("GetName"); UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName()); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(GetExtension) { + Y_UNIT_TEST(GetExtension) { TTestDirectory d("GetExtension"); UNIT_ASSERT_VALUES_EQUAL("", d.Child("a").GetExtension()); UNIT_ASSERT_VALUES_EQUAL("", d.Child(".a").GetExtension()); @@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL("zlib", d.Child("file.ylib.zlib").GetExtension()); } - Y_UNIT_TEST(TestRename) { + Y_UNIT_TEST(TestRename) { TTestDirectory xx("TestRename"); TFsPath f1 = xx.Child("f1"); TFsPath f2 = xx.Child("f2"); @@ -148,7 +148,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(f2.Exists()); } - Y_UNIT_TEST(TestForceRename) { + Y_UNIT_TEST(TestForceRename) { TTestDirectory xx("TestForceRename"); TFsPath fMain = xx.Child("main"); @@ -168,12 +168,12 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(xx.Child("main1").Child("f1").Child("f1child").Exists()); } - Y_UNIT_TEST(TestRenameFail) { + Y_UNIT_TEST(TestRenameFail) { UNIT_ASSERT_EXCEPTION(TFsPath("sfsfsfsdfsfsdfdf").RenameTo("sdfsdf"), TIoException); } #ifndef _win_ - Y_UNIT_TEST(TestRealPath) { + Y_UNIT_TEST(TestRealPath) { UNIT_ASSERT(TFsPath(".").RealPath().IsDirectory()); TTestDirectory td("TestRealPath"); @@ -190,7 +190,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #endif - Y_UNIT_TEST(TestSlashesAndBasename) { + Y_UNIT_TEST(TestSlashesAndBasename) { TFsPath p("/db/BASE/primus121-025-1380131338//"); UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338")); TFsPath testP = p / "test"; @@ -201,7 +201,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestSlashesAndBasenameWin) { + Y_UNIT_TEST(TestSlashesAndBasenameWin) { TFsPath p("\\db\\BASE\\primus121-025-1380131338\\\\"); TFsPath testP = p / "test"; #ifdef _win_ @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) { + Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) { TFsPath p("C:\\db\\BASE\\primus121-025-1380131338\\\\"); TFsPath testP = p / "test"; #ifdef _win_ @@ -225,7 +225,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestList) { + Y_UNIT_TEST(TestList) { TTestDirectory td("TestList-dir"); TFsPath dir = td.GetFsPath(); @@ -249,7 +249,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #ifdef _unix_ - Y_UNIT_TEST(MkDirMode) { + Y_UNIT_TEST(MkDirMode) { TTestDirectory td("MkDirMode"); TFsPath subDir = td.Child("subdir"); const int mode = MODE0775; @@ -263,11 +263,11 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { } #endif - Y_UNIT_TEST(Cwd) { + Y_UNIT_TEST(Cwd) { UNIT_ASSERT_VALUES_EQUAL(TFsPath::Cwd().RealPath(), TFsPath(".").RealPath()); } - Y_UNIT_TEST(TestSubpathOf) { + Y_UNIT_TEST(TestSubpathOf) { UNIT_ASSERT(TFsPath("/a/b/c/d").IsSubpathOf("/a/b")); UNIT_ASSERT(TFsPath("/a").IsSubpathOf("/")); @@ -334,7 +334,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { #endif } - Y_UNIT_TEST(TestRelativePath) { + Y_UNIT_TEST(TestRelativePath) { UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b")), TFsPath("c/d")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b/c/d").RelativePath(TFsPath("/a/b/e/f")), TFsPath("../../c/d")); UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").RelativePath(TFsPath("/")), TFsPath()); @@ -345,7 +345,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_EXCEPTION(TFsPath("a/b/c").RelativePath(TFsPath("d/e")), TIoException); } - Y_UNIT_TEST(TestUndefined) { + Y_UNIT_TEST(TestUndefined) { UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath("")); UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix()); @@ -393,7 +393,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(!TFsPath().Stat(stat)); } - Y_UNIT_TEST(TestJoinFsPaths) { + Y_UNIT_TEST(TestJoinFsPaths) { #ifdef _win_ UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d"); UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "..\\c"), "a\\b\\..\\c"); @@ -410,23 +410,23 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", ""), "a/b"); #endif } - - Y_UNIT_TEST(TestStringCast) { - TFsPath pathOne; - UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne)); - UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"}); - - TFsPath pathTwo; - UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo)); - - UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"}); - - TFsPath pathThree{"/a/b"}; - UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b"); - } + + Y_UNIT_TEST(TestStringCast) { + TFsPath pathOne; + UNIT_ASSERT(TryFromString<TFsPath>("/a/b", pathOne)); + UNIT_ASSERT_VALUES_EQUAL(pathOne, TFsPath{"/a/b"}); + + TFsPath pathTwo; + UNIT_ASSERT_NO_EXCEPTION(TryFromString<TFsPath>("/a/b", pathTwo)); + + UNIT_ASSERT_VALUES_EQUAL(FromString<TFsPath>("/a/b"), TFsPath{"/a/b"}); + + TFsPath pathThree{"/a/b"}; + UNIT_ASSERT_VALUES_EQUAL(ToString(pathThree), "/a/b"); + } #ifdef _unix_ - Y_UNIT_TEST(TestRemoveSymlinkToDir) { + Y_UNIT_TEST(TestRemoveSymlinkToDir) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -449,7 +449,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveSymlinkToFile) { + Y_UNIT_TEST(TestRemoveSymlinkToFile) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -472,7 +472,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) { + Y_UNIT_TEST(TestRemoveDirWithSymlinkToDir) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); @@ -499,7 +499,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(NFs::Exists(originDir)); } - Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) { + Y_UNIT_TEST(TestRemoveDirWithSymlinkToFile) { TTempDir tempDir; TFsPath tempDirPath(tempDir()); diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp index 81d439a727..c2abc13141 100644 --- a/util/folder/pathsplit.cpp +++ b/util/folder/pathsplit.cpp @@ -16,7 +16,7 @@ static inline size_t ToReserve(const T& t) { return ret; } -void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { +void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { if (part == TStringBuf(".")) { push_back(TStringBuf(".")); @@ -30,7 +30,7 @@ void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { DoParsePart(part); } -void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { +void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { DoAppendHint(part0.size() / 8); TStringBuf next(part0); @@ -43,7 +43,7 @@ void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { AppendComponent(next); } -void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { +void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { TStringBuf part(part0); if (part == TStringBuf(".")) { @@ -64,7 +64,7 @@ void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { DoParsePart(part); } -void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) { +void TPathSplitTraitsWindows::DoParsePart(const TStringBuf part0) { DoAppendHint(part0.size() / 8); size_t pos = 0; @@ -106,7 +106,7 @@ TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const { return r; } -void TPathSplitStore::AppendComponent(const TStringBuf comp) { +void TPathSplitStore::AppendComponent(const TStringBuf comp) { if (!comp || comp == TStringBuf(".")) { ; // ignore } else if (comp == TStringBuf("..") && !empty() && back() != TStringBuf("..")) { @@ -122,7 +122,7 @@ TStringBuf TPathSplitStore::Extension() const { } template <> -void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) { +void Out<TPathSplit>(IOutputStream& o, const TPathSplit& ps) { o << ps.Reconstruct(); } @@ -134,7 +134,7 @@ TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2) { return TPathSplit(p1).AppendMany(p2.begin(), p2.end()).Reconstruct(); } -TStringBuf CutExtension(const TStringBuf fileName) { +TStringBuf CutExtension(const TStringBuf fileName) { if (fileName.empty()) { return fileName; } diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h index d134338e35..c7f5d55197 100644 --- a/util/folder/pathsplit.h +++ b/util/folder/pathsplit.h @@ -10,7 +10,7 @@ struct TPathSplitStore: public TVector<TStringBuf> { TStringBuf Drive; bool IsAbsolute = false; - void AppendComponent(const TStringBuf comp); + void AppendComponent(const TStringBuf comp); TStringBuf Extension() const; protected: @@ -22,41 +22,41 @@ protected: }; struct TPathSplitTraitsUnix: public TPathSplitStore { - static constexpr char MainPathSep = '/'; + static constexpr char MainPathSep = '/'; inline TString Reconstruct() const { return DoReconstruct(TStringBuf("/")); } - static constexpr bool IsPathSep(const char c) noexcept { + static constexpr bool IsPathSep(const char c) noexcept { return c == '/'; } - static inline bool IsAbsolutePath(const TStringBuf path) noexcept { + static inline bool IsAbsolutePath(const TStringBuf path) noexcept { return path && IsPathSep(path[0]); } - void DoParseFirstPart(const TStringBuf part); - void DoParsePart(const TStringBuf part); + void DoParseFirstPart(const TStringBuf part); + void DoParsePart(const TStringBuf part); }; struct TPathSplitTraitsWindows: public TPathSplitStore { - static constexpr char MainPathSep = '\\'; + static constexpr char MainPathSep = '\\'; inline TString Reconstruct() const { return DoReconstruct(TStringBuf("\\")); } - static constexpr bool IsPathSep(char c) noexcept { + static constexpr bool IsPathSep(char c) noexcept { return c == '/' || c == '\\'; } - static inline bool IsAbsolutePath(const TStringBuf path) noexcept { + 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])))); } - void DoParseFirstPart(const TStringBuf part); - void DoParsePart(const TStringBuf part); + void DoParseFirstPart(const TStringBuf part); + void DoParsePart(const TStringBuf part); }; #if defined(_unix_) @@ -70,7 +70,7 @@ class TPathSplitBase: public TTraits { public: inline TPathSplitBase() = default; - inline TPathSplitBase(const TStringBuf part) { + inline TPathSplitBase(const TStringBuf part) { this->ParseFirstPart(part); } @@ -80,13 +80,13 @@ public: return *this; } - inline TPathSplitBase& ParseFirstPart(const TStringBuf part) { + inline TPathSplitBase& ParseFirstPart(const TStringBuf part) { this->DoParseFirstPart(part); return *this; } - inline TPathSplitBase& ParsePart(const TStringBuf part) { + inline TPathSplitBase& ParsePart(const TStringBuf part) { this->DoParsePart(part); return *this; @@ -110,4 +110,4 @@ using TPathSplitWindows = TPathSplitBase<TPathSplitTraitsWindows>; TString JoinPaths(const TPathSplit& p1, const TPathSplit& p2); -TStringBuf CutExtension(const TStringBuf fileName); +TStringBuf CutExtension(const TStringBuf fileName); diff --git a/util/folder/pathsplit_ut.cpp b/util/folder/pathsplit_ut.cpp index 0e97afd0d0..baa23c9f77 100644 --- a/util/folder/pathsplit_ut.cpp +++ b/util/folder/pathsplit_ut.cpp @@ -63,50 +63,50 @@ #define TRUE_ONLY_WIN false #endif -Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { - Y_UNIT_TEST(Empty) { +Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { + Y_UNIT_TEST(Empty) { PSUF(TPathSplit) ps; PS_CHECK(ps); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Relative) { + Y_UNIT_TEST(Relative) { PSUF(TPathSplit) ps("some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Absolute) { + Y_UNIT_TEST(Absolute) { PSUF(TPathSplit) ps("/some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(Self) { + Y_UNIT_TEST(Self) { PSUF(TPathSplit) ps("."); PS_CHECK(ps, "."); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Parent) { + Y_UNIT_TEST(Parent) { PSUF(TPathSplit) ps(".."); PS_CHECK(ps, ".."); UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(Root) { + Y_UNIT_TEST(Root) { PSUF(TPathSplit) ps("/"); PS_CHECK(ps); UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(Reconstruct) { + Y_UNIT_TEST(Reconstruct) { PSUF(TPathSplit) ps("some/usual/path/../../other/././//path"); #ifdef _win_ @@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(ParseFirstPart) { + Y_UNIT_TEST(ParseFirstPart) { PSUF(TPathSplit) ps; ps.ParseFirstPart("some/usual/path"); @@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(ParsePart) { + Y_UNIT_TEST(ParsePart) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("sub/path"); @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(ParsePartSelf) { + Y_UNIT_TEST(ParsePartSelf) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("."); @@ -160,7 +160,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { PS_CHECK(ps, "some", "usual", "path"); } - Y_UNIT_TEST(ParsePartParent) { + Y_UNIT_TEST(ParsePartParent) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart(".."); @@ -181,7 +181,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(ParsePartOverflow) { + Y_UNIT_TEST(ParsePartOverflow) { PSUF(TPathSplit) ps("some/usual/path"); ps.ParsePart("../../../../.."); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, true); } - Y_UNIT_TEST(WinRelative) { + Y_UNIT_TEST(WinRelative) { PSUF(TPathSplit) ps("some\\usual\\path"); #ifdef _win_ @@ -205,7 +205,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(WinAbsolute) { + Y_UNIT_TEST(WinAbsolute) { PSUF(TPathSplit) ps("\\some\\usual\\path"); #ifdef _win_ @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(psDrive2.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinRoot) { + Y_UNIT_TEST(WinRoot) { PSUF(TPathSplit) ps("\\"); #ifdef _win_ @@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinReconstruct) { + Y_UNIT_TEST(WinReconstruct) { PSUF(TPathSplit) ps("some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path"); #ifdef _win_ @@ -274,7 +274,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(WinParseFirstPart) { + Y_UNIT_TEST(WinParseFirstPart) { PSUF(TPathSplit) ps; ps.ParseFirstPart("some\\usual\\path"); @@ -295,7 +295,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN); } - Y_UNIT_TEST(WinParsePart) { + Y_UNIT_TEST(WinParsePart) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("sub\\path"); @@ -317,7 +317,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } #ifdef _win_ - Y_UNIT_TEST(WinParsePartSelf) { + Y_UNIT_TEST(WinParsePartSelf) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("."); @@ -328,7 +328,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { PS_CHECK(ps, "some", "usual", "path"); } - Y_UNIT_TEST(WinParsePartParent) { + Y_UNIT_TEST(WinParsePartParent) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart(".."); @@ -355,7 +355,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.Drive, "C:"); } - Y_UNIT_TEST(WinParsePartOverflow) { + Y_UNIT_TEST(WinParsePartOverflow) { PSUF(TPathSplit) ps("some\\usual\\path"); ps.ParsePart("..\\..\\..\\..\\.."); @@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } #endif - Y_UNIT_TEST(WinMixed) { + Y_UNIT_TEST(WinMixed) { PSUF(TPathSplit) ps("some\\usual/path"); #ifdef _win_ @@ -386,7 +386,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(WinParsePartMixed) { + Y_UNIT_TEST(WinParsePartMixed) { PSUF(TPathSplit) ps("some\\usual/path"); ps.ParsePart("sub/sub\\path"); @@ -398,7 +398,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { UNIT_ASSERT_EQUAL(ps.IsAbsolute, false); } - Y_UNIT_TEST(BeginWithSelf) { + Y_UNIT_TEST(BeginWithSelf) { PSUF(TPathSplit) ps("./some/usual/path"); PS_CHECK(ps, "some", "usual", "path"); @@ -409,7 +409,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(BeginWithParent) { + Y_UNIT_TEST(BeginWithParent) { PSUF(TPathSplit) ps("../some/usual/path"); PS_CHECK(ps, "..", "some", "usual", "path"); @@ -420,14 +420,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { #endif } - Y_UNIT_TEST(InOut) { + Y_UNIT_TEST(InOut) { PSUF(TPathSplit) ps("path/.."); PS_CHECK(ps); UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), ""); } - Y_UNIT_TEST(OutIn) { + Y_UNIT_TEST(OutIn) { PSUF(TPathSplit) ps("../path"); PS_CHECK(ps, "..", "path"); @@ -439,14 +439,14 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) { } } -Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { - Y_UNIT_TEST(IsPathSep) { +Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { + Y_UNIT_TEST(IsPathSep) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('/'), true); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('\\'), TRUE_ONLY_WIN); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep(' '), false); } - Y_UNIT_TEST(IsAbsolutePath) { + Y_UNIT_TEST(IsAbsolutePath) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(""), false); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/"), true); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("some/usual/path"), false); @@ -457,7 +457,7 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/.."), true); } - Y_UNIT_TEST(WinIsAbsolutePath) { + Y_UNIT_TEST(WinIsAbsolutePath) { UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("somepath"), false); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\"), TRUE_ONLY_WIN); UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\somepath"), TRUE_ONLY_WIN); diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 6fdf8f753c..fdf66d5de3 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -16,7 +16,7 @@ TTempDir::TTempDir(const char* prefix, TCreationToken) { char tempDir[MAX_PATH]; if (MakeTempDir(tempDir, prefix) != 0) { - ythrow TSystemError() << "Can't create temporary directory"; + ythrow TSystemError() << "Can't create temporary directory"; } TempDir = tempDir; } |