diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /util/folder | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r-- | util/folder/dirut.cpp | 106 | ||||
-rw-r--r-- | util/folder/dirut.h | 4 | ||||
-rw-r--r-- | util/folder/dirut_ut.cpp | 10 | ||||
-rw-r--r-- | util/folder/fts.cpp | 2 | ||||
-rw-r--r-- | util/folder/iterator.h | 4 | ||||
-rw-r--r-- | util/folder/iterator_ut.cpp | 10 | ||||
-rw-r--r-- | util/folder/path.cpp | 216 | ||||
-rw-r--r-- | util/folder/path.h | 120 | ||||
-rw-r--r-- | util/folder/path_ut.cpp | 36 |
9 files changed, 254 insertions, 254 deletions
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f96..1f22c0e261 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -403,17 +403,17 @@ int mkpath(char* path, int mode) { // 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; + TTempBuf result; Y_ASSERT(result.Size() > MAX_PATH); //TMP_BUF_LEN > MAX_PATH -#ifdef _win_ +#ifdef _win_ if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0) -#else +#else if (realpath(path.data(), result.Data()) == nullptr) -#endif +#endif ythrow TFileError() << "RealPath failed \"" << path << "\""; - return result.Data(); -} - + return result.Data(); +} + TString RealLocation(const TString& path) { if (NFs::Exists(path)) return RealPath(path); @@ -451,37 +451,37 @@ int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix) { bool IsDir(const TString& path) { return TFileStat(path).IsDir(); -} - +} + TString GetHomeDir() { TString s(getenv("HOME")); - if (!s) { -#ifndef _win32_ + if (!s) { +#ifndef _win32_ passwd* pw = nullptr; - s = getenv("USER"); + s = getenv("USER"); if (s) pw = getpwnam(s.data()); - else - pw = getpwuid(getuid()); - if (pw) - s = pw->pw_dir; - else -#endif - { + else + pw = getpwuid(getuid()); + if (pw) + s = pw->pw_dir; + else +#endif + { char* cur_dir = getcwd(nullptr, 0); - s = cur_dir; - free(cur_dir); - } - } - return s; -} - + s = cur_dir; + free(cur_dir); + } + } + return s; +} + void MakeDirIfNotExist(const char* path, int mode) { if (!NFs::MakeDirectory(path, NFs::EFilePermission(mode)) && !NFs::Exists(path)) { ythrow TSystemError() << "failed to create directory " << path; - } -} - + } +} + void MakePathIfNotExist(const char* path, int mode) { NFs::MakeDirectoryRecursive(path, NFs::EFilePermission(mode)); if (!NFs::Exists(path) || !TFileStat(path).IsDir()) { @@ -489,22 +489,22 @@ void MakePathIfNotExist(const char* path, int mode) { } } -const char* GetFileNameComponent(const char* f) { - const char* p = strrchr(f, LOCSLASH_C); +const char* GetFileNameComponent(const char* f) { + const char* p = strrchr(f, LOCSLASH_C); #ifdef _win_ // "/" is also valid char separator on Windows const char* p2 = strrchr(f, '/'); if (p2 > p) p = p2; #endif - - if (p) { - return p + 1; - } - - return f; -} - + + if (p) { + return p + 1; + } + + return f; +} + TString GetSystemTempDir() { #ifdef _win_ char buffer[1024]; @@ -513,19 +513,19 @@ TString GetSystemTempDir() { ythrow TSystemError() << "failed to get system temporary directory"; } return TString(buffer, size); -#else - const char* var = "TMPDIR"; - const char* def = "/tmp"; - const char* r = getenv(var); +#else + const char* var = "TMPDIR"; + const char* def = "/tmp"; + const char* r = getenv(var); const char* result = r ? r : def; return result[0] == '/' ? result : ResolveDir(result); #endif -} - +} + TString ResolveDir(const char* path) { - return ResolvePath(path, true); -} - + return ResolvePath(path, true); +} + bool SafeResolveDir(const char* path, TString& result) { try { result = ResolvePath(path, true); @@ -537,10 +537,10 @@ bool SafeResolveDir(const char* path, TString& result) { TString GetDirName(const TString& path) { return TFsPath(path).Dirname(); -} - -#ifdef _win32_ - +} + +#ifdef _win32_ + char* realpath(const char* pathname, char resolved_path[MAXPATHLEN]) { // partial implementation: no path existence check return _fullpath(resolved_path, pathname, MAXPATHLEN - 1); @@ -607,7 +607,7 @@ TString ResolvePath(const char* rel, const char* abs, bool isdir) { ythrow yexception() << "cannot resolve path: \"" << rel << "\""; return buf; } - + TString ResolvePath(const char* path, bool isDir) { return ResolvePath(path, nullptr, isDir); } diff --git a/util/folder/dirut.h b/util/folder/dirut.h index 2537027b12..b2794d337a 100644 --- a/util/folder/dirut.h +++ b/util/folder/dirut.h @@ -61,7 +61,7 @@ const char* GetDirectorySeparatorS(); void RemoveDirWithContents(TString dirName); -const char* GetFileNameComponent(const char* f); +const char* GetFileNameComponent(const char* f); inline TString GetFileNameComponent(const TString& f) { return GetFileNameComponent(f.data()); @@ -70,7 +70,7 @@ inline TString GetFileNameComponent(const TString& f) { /// RealPath doesn't guarantee trailing separator to be stripped or left in place for directories. TString RealPath(const TString& path); // throws TString RealLocation(const TString& path); /// throws; last file name component doesn't need to exist - + TString GetSystemTempDir(); int MakeTempDir(char path[/*FILENAME_MAX*/], const char* prefix); diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp index 45ebfc842c..2353e7a6e2 100644 --- a/util/folder/dirut_ut.cpp +++ b/util/folder/dirut_ut.cpp @@ -1,18 +1,18 @@ #include "dirut.h" #include "tempdir.h" - + #include <library/cpp/testing/unittest/registar.h> - + #include <util/generic/string.h> #include <util/memory/tempbuf.h> #include <util/stream/file.h> #include <util/system/platform.h> - + Y_UNIT_TEST_SUITE(TDirutTest) { Y_UNIT_TEST(TestRealPath) { - UNIT_ASSERT(IsDir(RealPath("."))); + UNIT_ASSERT(IsDir(RealPath("."))); } - + Y_UNIT_TEST(TestRealLocation) { UNIT_ASSERT(IsDir(RealLocation("."))); diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index 0e6a6f86eb..0a658d9916 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -39,7 +39,7 @@ #include <util/system/defaults.h> #include <util/system/error.h> -#include <stdlib.h> +#include <stdlib.h> #ifndef _win_ #include <inttypes.h> #include <sys/param.h> diff --git a/util/folder/iterator.h b/util/folder/iterator.h index 69e025b9c4..cf8a621b9b 100644 --- a/util/folder/iterator.h +++ b/util/folder/iterator.h @@ -7,8 +7,8 @@ #include <util/generic/iterator.h> #include <util/generic/yexception.h> -/// Note this magic API traverses directory hierarchy - +/// Note this magic API traverses directory hierarchy + class TDirIterator: public TInputRangeAdaptor<TDirIterator> { struct TFtsDestroy { static inline void Destroy(FTS* f) noexcept { diff --git a/util/folder/iterator_ut.cpp b/util/folder/iterator_ut.cpp index 936becd139..15fdda8713 100644 --- a/util/folder/iterator_ut.cpp +++ b/util/folder/iterator_ut.cpp @@ -10,13 +10,13 @@ #include <util/random/mersenne.h> static TString JoinWithNewline(const TVector<TString>& strings) { - TStringStream ss; + TStringStream ss; for (const auto& string : strings) { ss << string << "\n"; - } - return ss.Str(); -} - + } + return ss.Str(); +} + class TDirIteratorTest: public TTestBase { UNIT_TEST_SUITE(TDirIteratorTest); UNIT_TEST(TestIt) diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..60a14b3fe7 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -7,14 +7,14 @@ #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) : TPathSplit(path) { } -}; - +}; + void TFsPath::CheckDefined() const { if (!IsDefined()) { ythrow TIoException() << TStringBuf("must be defined"); @@ -143,62 +143,62 @@ TString TFsPath::GetName() const { if (!IsDefined()) { return TString(); } - + const TSplit& split = GetSplit(); if (split.size() > 0) { if (split.back() != "..") { return TString(split.back()); - } else { - // cannot just drop last component, because path itself may be a symlink - return RealPath().GetName(); - } - } else { + } else { + // cannot just drop last component, because path itself may be a symlink + return RealPath().GetName(); + } + } else { if (split.IsAbsolute) { - return split.Reconstruct(); - } else { - return Cwd().GetName(); - } - } -} - + return split.Reconstruct(); + } else { + return Cwd().GetName(); + } + } +} + TString TFsPath::GetExtension() const { return TString(GetSplit().Extension()); } -bool TFsPath::IsAbsolute() const { +bool TFsPath::IsAbsolute() const { return GetSplit().IsAbsolute; -} - -bool TFsPath::IsRelative() const { - return !IsAbsolute(); -} - -void TFsPath::InitSplit() const { +} + +bool TFsPath::IsRelative() const { + return !IsAbsolute(); +} + +void TFsPath::InitSplit() const { Split_ = new TSplit(Path_); -} - -TFsPath::TSplit& TFsPath::GetSplit() const { - // XXX: race condition here +} + +TFsPath::TSplit& TFsPath::GetSplit() const { + // XXX: race condition here if (!Split_) { - InitSplit(); + InitSplit(); } return *Split_; -} - +} + static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); } -TFsPath::TFsPath() { -} - +TFsPath::TFsPath() { +} + TFsPath::TFsPath(const TString& path) : Path_(path) { VerifyPath(Path_); -} - +} + TFsPath::TFsPath(const TStringBuf path) : Path_(ToString(path)) { @@ -208,56 +208,56 @@ TFsPath::TFsPath(const TStringBuf path) TFsPath::TFsPath(const char* path) : Path_(path) { -} - +} + TFsPath TFsPath::Child(const TString& name) const { if (!name) { ythrow TIoException() << "child name must not be empty"; } return *this / name; -} - -struct TClosedir { - static void Destroy(DIR* dir) { +} + +struct TClosedir { + static void Destroy(DIR* dir) { if (dir) { if (0 != closedir(dir)) { ythrow TIoSystemError() << "failed to closedir"; } } - } -}; - + } +}; + void TFsPath::ListNames(TVector<TString>& children) const { - CheckDefined(); + CheckDefined(); THolder<DIR, TClosedir> dir(opendir(this->c_str())); if (!dir) { ythrow TIoSystemError() << "failed to opendir " << Path_; } - for (;;) { - struct dirent de; - struct dirent* ok; + 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 - int r = readdir_r(dir.Get(), &de, &ok); + int r = readdir_r(dir.Get(), &de, &ok); Y_PRAGMA_DIAGNOSTIC_POP if (r != 0) { ythrow TIoSystemError() << "failed to readdir " << Path_; } if (ok == nullptr) { - return; + return; } TString name(de.d_name); if (name == "." || name == "..") { - continue; + continue; } - children.push_back(name); - } -} - + children.push_back(name); + } +} + bool TFsPath::Contains(const TString& component) const { if (!IsDefined()) { return false; @@ -277,43 +277,43 @@ bool TFsPath::Contains(const TString& component) const { void TFsPath::List(TVector<TFsPath>& files) const { TVector<TString> names; - ListNames(names); + ListNames(names); for (auto& name : names) { files.push_back(Child(name)); - } -} - + } +} + void TFsPath::RenameTo(const TString& newPath) const { - CheckDefined(); + CheckDefined(); if (!newPath) { - ythrow TIoException() << "bad new file name"; + ythrow TIoException() << "bad new file name"; } if (!NFs::Rename(Path_, newPath)) { ythrow TIoSystemError() << "failed to rename " << Path_ << " to " << newPath; } -} - -void TFsPath::RenameTo(const char* newPath) const { +} + +void TFsPath::RenameTo(const char* newPath) const { RenameTo(TString(newPath)); -} - -void TFsPath::RenameTo(const TFsPath& newPath) const { - RenameTo(newPath.GetPath()); -} - -void TFsPath::Touch() const { - CheckDefined(); - if (!TFile(*this, OpenAlways).IsOpen()) { - ythrow TIoException() << "failed to touch " << *this; - } -} - -// XXX: move implementation to util/somewhere. -TFsPath TFsPath::RealPath() const { - CheckDefined(); +} + +void TFsPath::RenameTo(const TFsPath& newPath) const { + RenameTo(newPath.GetPath()); +} + +void TFsPath::Touch() const { + CheckDefined(); + if (!TFile(*this, OpenAlways).IsOpen()) { + ythrow TIoException() << "failed to touch " << *this; + } +} + +// XXX: move implementation to util/somewhere. +TFsPath TFsPath::RealPath() const { + CheckDefined(); return ::RealPath(*this); -} - +} + TFsPath TFsPath::RealLocation() const { CheckDefined(); return ::RealLocation(*this); @@ -329,20 +329,20 @@ TFsPath TFsPath::ReadLink() const { return NFs::ReadLink(*this); } -bool TFsPath::Exists() const { +bool TFsPath::Exists() const { return IsDefined() && NFs::Exists(*this); -} - +} + void TFsPath::CheckExists() const { if (!Exists()) { ythrow TIoException() << "path does not exist " << Path_; } } -bool TFsPath::IsDirectory() const { +bool TFsPath::IsDirectory() const { return IsDefined() && TFileStat(GetPath().data()).IsDir(); -} - +} + bool TFsPath::IsFile() const { return IsDefined() && TFileStat(GetPath().data()).IsFile(); } @@ -351,20 +351,20 @@ bool TFsPath::IsSymlink() const { return IsDefined() && TFileStat(GetPath().data(), true).IsSymlink(); } -void TFsPath::DeleteIfExists() const { +void TFsPath::DeleteIfExists() const { if (!IsDefined()) { return; } ::unlink(this->c_str()); ::rmdir(this->c_str()); - if (Exists()) { + if (Exists()) { ythrow TIoException() << "failed to delete " << Path_; - } -} - + } +} + void TFsPath::MkDir(const int mode) const { - CheckDefined(); + CheckDefined(); if (!Exists()) { int r = Mkdir(this->c_str(), mode); if (r != 0) { @@ -376,8 +376,8 @@ void TFsPath::MkDir(const int mode) const { } } } -} - +} + void TFsPath::MkDirs(const int mode) const { CheckDefined(); if (!Exists()) { @@ -386,7 +386,7 @@ void TFsPath::MkDirs(const int mode) const { } } -void TFsPath::ForceDelete() const { +void TFsPath::ForceDelete() const { if (!IsDefined()) { return; } @@ -408,20 +408,20 @@ void TFsPath::ForceDelete() const { ClearLastSystemError(); if (stat.IsDir()) { TVector<TFsPath> children; - List(children); + List(children); for (auto& i : children) { i.ForceDelete(); - } + } ::rmdir(this->c_str()); } else { ::unlink(this->c_str()); - } + } if (LastSystemError()) { ythrow TIoException() << "failed to delete " << Path_; } -} - +} + void TFsPath::CopyTo(const TString& newPath, bool force) const { if (IsDirectory()) { if (force) { @@ -458,18 +458,18 @@ void TFsPath::ForceRenameTo(const TString& newPath) const { } } -TFsPath TFsPath::Cwd() { +TFsPath TFsPath::Cwd() { return TFsPath(::NFs::CurrentWorkingDirectory()); -} - +} + const TPathSplit& TFsPath::PathSplit() const { return GetSplit(); } template <> void Out<TFsPath>(IOutputStream& os, const TFsPath& f) { - os << f.GetPath(); -} + os << f.GetPath(); +} template <> TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) { diff --git a/util/folder/path.h b/util/folder/path.h index 2fb4d6b4ef..01d41df1d2 100644 --- a/util/folder/path.h +++ b/util/folder/path.h @@ -1,5 +1,5 @@ #pragma once - + #include "fwd.h" #include "pathsplit.h" @@ -9,7 +9,7 @@ #include <util/generic/vector.h> #include <util/string/cast.h> #include <util/system/fstat.h> -#include <util/system/platform.h> +#include <util/system/platform.h> #include <util/system/sysstat.h> #include <util/system/yassert.h> @@ -19,26 +19,26 @@ * Class behaviour is platform-dependent. * It uses platform-dependent separators for path-reconstructing operations. */ -class TFsPath { +class TFsPath { private: - struct TSplit; - -public: - TFsPath(); + struct TSplit; + +public: + TFsPath(); TFsPath(const TString& path); TFsPath(const TStringBuf path); - TFsPath(const char* path); - + TFsPath(const char* path); + TFsPath(const std::string& path) : TFsPath(TStringBuf(path)) { } void CheckDefined() const; - - inline bool IsDefined() const { + + inline bool IsDefined() const { return Path_.length() > 0; - } + } inline explicit operator bool() const { return IsDefined(); @@ -50,16 +50,16 @@ public: inline operator const TString&() const { return Path_; - } + } - inline bool operator==(const TFsPath& that) const { + inline bool operator==(const TFsPath& that) const { return Path_ == that.Path_; - } + } inline bool operator!=(const TFsPath& that) const { return Path_ != that.Path_; } - + TFsPath& operator/=(const TFsPath& that); friend TFsPath operator/(const TFsPath& s, const TFsPath& p) { @@ -73,11 +73,11 @@ public: inline const TString& GetPath() const { return Path_; - } - - /// last component of path, or "/" if root + } + + /// last component of path, or "/" if root TString GetName() const; - + /** * "a.b.tmp" -> "tmp" * "a.tmp" -> "tmp" @@ -85,8 +85,8 @@ public: */ TString GetExtension() const; - bool IsAbsolute() const; - bool IsRelative() const; + bool IsAbsolute() const; + bool IsRelative() const; /** * TFsPath("/a/b").IsSubpathOf("/a") -> true @@ -113,7 +113,7 @@ public: bool IsContainerOf(const TFsPath& that) const { return that.IsSubpathOf(*this); } - + TFsPath RelativeTo(const TFsPath& root) const; //must be subpath of root /** @@ -121,10 +121,10 @@ public: */ TFsPath RelativePath(const TFsPath& root) const; //..; for relative paths 1st component must be the same - /** - * Never fails. Returns this if already a root. - */ - TFsPath Parent() const; + /** + * Never fails. Returns this if already a root. + */ + TFsPath Parent() const; TString Basename() const { return GetName(); @@ -132,9 +132,9 @@ public: TString Dirname() const { return Parent(); } - + TFsPath Child(const TString& name) const; - + /** * @brief create this directory * @@ -143,7 +143,7 @@ public: * Nothing to do if dir exists. */ void MkDir(const int mode = MODE0777) const; - + /** * @brief create this directory and all parent directories as needed * @@ -151,66 +151,66 @@ public: */ void MkDirs(const int mode = MODE0777) const; - // XXX: rewrite to return iterator + // XXX: rewrite to return iterator void List(TVector<TFsPath>& children) const; void ListNames(TVector<TString>& children) const; - + // Check, if path contains at least one component with a specific name. bool Contains(const TString& component) const; - // fails to delete non-empty directory - void DeleteIfExists() const; - // delete recursively. Does nothing if not exists - void ForceDelete() const; - - // XXX: ino - + // fails to delete non-empty directory + void DeleteIfExists() const; + // delete recursively. Does nothing if not exists + void ForceDelete() const; + + // XXX: ino + inline bool Stat(TFileStat& stat) const { stat = TFileStat(Path_.data()); return stat.Mode; } - bool Exists() const; - /// false if not exists - bool IsDirectory() const; + bool Exists() const; + /// false if not exists + bool IsDirectory() const; /// false if not exists bool IsFile() const; /// false if not exists - bool IsSymlink() const; - /// throw TIoException if not exists - void CheckExists() const; - + bool IsSymlink() const; + /// throw TIoException if not exists + void CheckExists() const; + void RenameTo(const TString& newPath) const; - void RenameTo(const char* newPath) const; - void RenameTo(const TFsPath& newFile) const; + void RenameTo(const char* newPath) const; + void RenameTo(const TFsPath& newFile) const; void ForceRenameTo(const TString& newPath) const; - + void CopyTo(const TString& newPath, bool force) const; - void Touch() const; - - TFsPath RealPath() const; + void Touch() const; + + TFsPath RealPath() const; TFsPath RealLocation() const; TFsPath ReadLink() const; - - /// always absolute - static TFsPath Cwd(); - + + /// always absolute + static TFsPath Cwd(); + inline void Swap(TFsPath& p) noexcept { DoSwap(Path_, p.Path_); Split_.Swap(p.Split_); } -private: - void InitSplit() const; - TSplit& GetSplit() const; +private: + void InitSplit() const; + TSplit& GetSplit() const; private: TString Path_; /// cache mutable TSimpleIntrusivePtr<TSplit> Split_; -}; +}; namespace NPrivate { inline void AppendToFsPath(TFsPath&) { diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp index e6a3451016..81ecf0e034 100644 --- a/util/folder/path_ut.cpp +++ b/util/folder/path_ut.cpp @@ -6,12 +6,12 @@ #include <library/cpp/testing/unittest/registar.h> #include <util/generic/scope.h> -#include <util/system/platform.h> +#include <util/system/platform.h> #include <util/system/yassert.h> -#include <util/stream/output.h> +#include <util/stream/output.h> #include <util/stream/file.h> #include <util/system/fs.h> - + #include <algorithm> #ifdef _win_ @@ -116,19 +116,19 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL(TFsPath("..").Parent(), TFsPath("../..")); #endif } - + Y_UNIT_TEST(GetName) { TTestDirectory d("GetName"); UNIT_ASSERT_VALUES_EQUAL(TString("dfgh"), d.Child("dfgh").GetName()); - + // check does not fail TFsPath(".").GetName(); - -#ifdef _unix_ + +#ifdef _unix_ UNIT_ASSERT_VALUES_EQUAL(TString("/"), TFsPath("/").GetName()); -#endif +#endif } - + Y_UNIT_TEST(GetExtension) { TTestDirectory d("GetExtension"); UNIT_ASSERT_VALUES_EQUAL("", d.Child("a").GetExtension()); @@ -147,7 +147,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT(!f1.Exists()); UNIT_ASSERT(f2.Exists()); } - + Y_UNIT_TEST(TestForceRename) { TTestDirectory xx("TestForceRename"); TFsPath fMain = xx.Child("main"); @@ -171,7 +171,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { Y_UNIT_TEST(TestRenameFail) { UNIT_ASSERT_EXCEPTION(TFsPath("sfsfsfsdfsfsdfdf").RenameTo("sdfsdf"), TIoException); } - + #ifndef _win_ Y_UNIT_TEST(TestRealPath) { UNIT_ASSERT(TFsPath(".").RealPath().IsDirectory()); @@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_VALUES_EQUAL(link.RealPath(), target2.RealPath()); // must not cache old value } #endif - + Y_UNIT_TEST(TestSlashesAndBasename) { TFsPath p("/db/BASE/primus121-025-1380131338//"); UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338")); @@ -227,27 +227,27 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { Y_UNIT_TEST(TestList) { TTestDirectory td("TestList-dir"); - + TFsPath dir = td.GetFsPath(); dir.Child("a").Touch(); dir.Child("b").MkDir(); dir.Child("b").Child("b-1").Touch(); dir.Child("c").MkDir(); dir.Child("d").Touch(); - + TVector<TString> children; dir.ListNames(children); std::sort(children.begin(), children.end()); - + TVector<TString> expected; expected.push_back("a"); expected.push_back("b"); expected.push_back("c"); expected.push_back("d"); - + UNIT_ASSERT_VALUES_EQUAL(expected, children); } - + #ifdef _unix_ Y_UNIT_TEST(MkDirMode) { TTestDirectory td("MkDirMode"); @@ -809,4 +809,4 @@ Y_UNIT_TEST_SUITE(TFsPathTests) { UNIT_ASSERT_EXCEPTION_CONTAINS(testSymlink.ForceDelete(), TIoException, "failed to delete"); } #endif -} +} |