diff options
author | aosipenko <aosipenko@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 948fd24d47d4b3b7815aaef1686aea00ef3f4288 (patch) | |
tree | 8ad4c39c2a5f8b341bc02e3b0c5e8f26c40373cb /util/folder | |
parent | d2eb4aae699fa2f6901bf32d22eec019c8f29838 (diff) | |
download | ydb-948fd24d47d4b3b7815aaef1686aea00ef3f4288.tar.gz |
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r-- | util/folder/dirent_win.c | 34 | ||||
-rw-r--r-- | util/folder/dirut.cpp | 4 | ||||
-rw-r--r-- | util/folder/dirut_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/filelist_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/fts_ut.cpp | 2 | ||||
-rw-r--r-- | util/folder/path.cpp | 4 | ||||
-rw-r--r-- | util/folder/tempdir.cpp | 36 | ||||
-rw-r--r-- | util/folder/tempdir.h | 26 |
8 files changed, 55 insertions, 55 deletions
diff --git a/util/folder/dirent_win.c b/util/folder/dirent_win.c index 7e6db74ce5..b945630eaa 100644 --- a/util/folder/dirent_win.c +++ b/util/folder/dirent_win.c @@ -21,13 +21,13 @@ static void SetErrno() { struct DIR* opendir(const char* dirname) { struct DIR* dir = (struct DIR*)malloc(sizeof(struct DIR)); - if (!dir) { - return NULL; + if (!dir) { + return NULL; } - dir->sh = INVALID_HANDLE_VALUE; - dir->fff_templ = NULL; - dir->file_no = 0; - dir->readdir_buf = NULL; + dir->sh = INVALID_HANDLE_VALUE; + dir->fff_templ = NULL; + dir->file_no = 0; + dir->readdir_buf = NULL; int len = strlen(dirname); //Remove trailing slashes @@ -36,31 +36,31 @@ struct DIR* opendir(const char* dirname) { } int len_converted = MultiByteToWideChar(CP_UTF8, 0, dirname, len, 0, 0); if (len_converted == 0) { - closedir(dir); - return NULL; + closedir(dir); + return NULL; } dir->fff_templ = (WCHAR*)malloc((len_converted + 5) * sizeof(WCHAR)); - if (!dir->fff_templ) { - closedir(dir); - return NULL; + if (!dir->fff_templ) { + closedir(dir); + return NULL; } MultiByteToWideChar(CP_UTF8, 0, dirname, len, dir->fff_templ, len_converted); WCHAR append[] = {'\\', '*', '.', '*', 0}; memcpy(dir->fff_templ + len_converted, append, sizeof(append)); dir->sh = FindFirstFileW(dir->fff_templ, &dir->wfd); - if (dir->sh == INVALID_HANDLE_VALUE) { + if (dir->sh == INVALID_HANDLE_VALUE) { SetErrno(); - closedir(dir); - return NULL; + closedir(dir); + return NULL; } - + return dir; } int closedir(struct DIR* dir) { - if (dir->sh != INVALID_HANDLE_VALUE) - FindClose(dir->sh); + if (dir->sh != INVALID_HANDLE_VALUE) + FindClose(dir->sh); free(dir->fff_templ); free(dir->readdir_buf); free(dir); diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f96..c05a54831a 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -459,7 +459,7 @@ TString GetHomeDir() { #ifndef _win32_ passwd* pw = nullptr; s = getenv("USER"); - if (s) + if (s) pw = getpwnam(s.data()); else pw = getpwuid(getuid()); @@ -517,7 +517,7 @@ TString GetSystemTempDir() { const char* var = "TMPDIR"; const char* def = "/tmp"; const char* r = getenv(var); - const char* result = r ? r : def; + const char* result = r ? r : def; return result[0] == '/' ? result : ResolveDir(result); #endif } diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp index 45ebfc842c..fcdbc96d33 100644 --- a/util/folder/dirut_ut.cpp +++ b/util/folder/dirut_ut.cpp @@ -1,5 +1,5 @@ #include "dirut.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> diff --git a/util/folder/filelist_ut.cpp b/util/folder/filelist_ut.cpp index 0cdcdf3d00..b042dd1ff5 100644 --- a/util/folder/filelist_ut.cpp +++ b/util/folder/filelist_ut.cpp @@ -1,6 +1,6 @@ #include "dirut.h" #include "filelist.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp index c5d59e35f4..050aa467ad 100644 --- a/util/folder/fts_ut.cpp +++ b/util/folder/fts_ut.cpp @@ -1,6 +1,6 @@ #include "fts.h" #include "dirut.h" -#include "tempdir.h" +#include "tempdir.h" #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/threading/future/async.h> diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..96ebdc3dbe 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -335,7 +335,7 @@ bool TFsPath::Exists() const { void TFsPath::CheckExists() const { if (!Exists()) { - ythrow TIoException() << "path does not exist " << Path_; + ythrow TIoException() << "path does not exist " << Path_; } } @@ -452,7 +452,7 @@ void TFsPath::CopyTo(const TString& newPath, bool force) const { void TFsPath::ForceRenameTo(const TString& newPath) const { try { RenameTo(newPath); - } catch (const TIoSystemError& /* error */) { + } catch (const TIoSystemError& /* error */) { CopyTo(newPath, true); ForceDelete(); } diff --git a/util/folder/tempdir.cpp b/util/folder/tempdir.cpp index 6fdf8f753c..760cc03fa1 100644 --- a/util/folder/tempdir.cpp +++ b/util/folder/tempdir.cpp @@ -1,34 +1,34 @@ -#include "tempdir.h" +#include "tempdir.h" -#include "dirut.h" +#include "dirut.h" -#include <util/system/fs.h> -#include <util/system/maxlen.h> - -TTempDir::TTempDir() +#include <util/system/fs.h> +#include <util/system/maxlen.h> + +TTempDir::TTempDir() : TTempDir(nullptr, TCreationToken{}) { } TTempDir::TTempDir(const char* prefix, TCreationToken) - : TempDir() + : TempDir() , Remove(true) -{ - char tempDir[MAX_PATH]; +{ + char tempDir[MAX_PATH]; if (MakeTempDir(tempDir, prefix) != 0) { ythrow TSystemError() << "Can't create temporary directory"; } - TempDir = tempDir; -} - + TempDir = tempDir; +} + TTempDir::TTempDir(const TString& tempDir) - : TempDir(tempDir) + : TempDir(tempDir) , Remove(true) -{ +{ NFs::Remove(TempDir); MakeDirIfNotExist(TempDir.c_str()); -} - +} + TTempDir TTempDir::NewTempDir(const TString& root) { return {root.c_str(), TCreationToken{}}; } @@ -37,8 +37,8 @@ void TTempDir::DoNotRemove() { Remove = false; } -TTempDir::~TTempDir() { +TTempDir::~TTempDir() { if (Remove) { RemoveDirWithContents(TempDir); } -} +} diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h index ff458f83b9..1422669f02 100644 --- a/util/folder/tempdir.h +++ b/util/folder/tempdir.h @@ -1,19 +1,19 @@ -#pragma once - +#pragma once + #include "fwd.h" #include "path.h" #include <util/generic/string.h> - -class TTempDir { -public: + +class TTempDir { +public: /// Create new directory in system tmp folder. - TTempDir(); + TTempDir(); /// Create new directory with this fixed name. If it already exists, clear it. TTempDir(const TString& tempDir); - ~TTempDir(); - + ~TTempDir(); + /// Create new directory in given folder. static TTempDir NewTempDir(const TString& root); @@ -26,12 +26,12 @@ public: } const TFsPath& Path() const { - return TempDir; - } - + return TempDir; + } + void DoNotRemove(); -private: +private: struct TCreationToken {}; // Prevent people from confusing this ctor with the public one @@ -40,4 +40,4 @@ private: TFsPath TempDir; bool Remove; -}; +}; |