aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/archive/directory_models_archive_reader.cpp
diff options
context:
space:
mode:
authoreshemchik <eshemchik@yandex-team.ru>2022-02-10 16:50:53 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:53 +0300
commit9905811fdc643c722d6464b8cf6661f931510f2f (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/archive/directory_models_archive_reader.cpp
parentface8a85ff3525043b92e692a9891cd1c19519c4 (diff)
downloadydb-9905811fdc643c722d6464b8cf6661f931510f2f.tar.gz
Restoring authorship annotation for <eshemchik@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/archive/directory_models_archive_reader.cpp')
-rw-r--r--library/cpp/archive/directory_models_archive_reader.cpp138
1 files changed, 69 insertions, 69 deletions
diff --git a/library/cpp/archive/directory_models_archive_reader.cpp b/library/cpp/archive/directory_models_archive_reader.cpp
index 6c85cecf67..6de9424c7c 100644
--- a/library/cpp/archive/directory_models_archive_reader.cpp
+++ b/library/cpp/archive/directory_models_archive_reader.cpp
@@ -1,37 +1,37 @@
-#include "directory_models_archive_reader.h"
+#include "directory_models_archive_reader.h"
#include "yarchive.h"
-
-#include <util/folder/dirut.h>
-#include <util/folder/filelist.h>
-#include <util/folder/path.h>
-#include <util/memory/blob.h>
-#include <util/stream/file.h>
-#include <util/stream/input.h>
-#include <util/stream/mem.h>
-
+
+#include <util/folder/dirut.h>
+#include <util/folder/filelist.h>
+#include <util/folder/path.h>
+#include <util/memory/blob.h>
+#include <util/stream/file.h>
+#include <util/stream/input.h>
+#include <util/stream/mem.h>
+
TDirectoryModelsArchiveReader::TDirectoryModelsArchiveReader(const TString& path, bool lockMemory, bool ownBlobs)
- : Path_(path)
-{
- Y_ENSURE(IsDir(path), "directory not found on this path");
-
+ : Path_(path)
+{
+ Y_ENSURE(IsDir(path), "directory not found on this path");
+
LoadFilesAndSubdirs("", lockMemory, ownBlobs);
-}
-
-TDirectoryModelsArchiveReader::~TDirectoryModelsArchiveReader() {}
-
-size_t TDirectoryModelsArchiveReader::Count() const noexcept {
- return Recs_.size();
-}
-
-TString TDirectoryModelsArchiveReader::KeyByIndex(size_t n) const {
- Y_ENSURE(n < Count(), "incorrect index " << n);
- return Recs_[n];
-}
-
-bool TDirectoryModelsArchiveReader::Has(const TStringBuf key) const {
+}
+
+TDirectoryModelsArchiveReader::~TDirectoryModelsArchiveReader() {}
+
+size_t TDirectoryModelsArchiveReader::Count() const noexcept {
+ return Recs_.size();
+}
+
+TString TDirectoryModelsArchiveReader::KeyByIndex(size_t n) const {
+ Y_ENSURE(n < Count(), "incorrect index " << n);
+ return Recs_[n];
+}
+
+bool TDirectoryModelsArchiveReader::Has(const TStringBuf key) const {
return BlobByKey_.contains(key) || PathByKey_.contains(key);
-}
-
+}
+
namespace {
struct TBlobOwningStream : public TMemoryInput {
TBlob Blob;
@@ -42,15 +42,15 @@ namespace {
};
}
-TAutoPtr<IInputStream> TDirectoryModelsArchiveReader::ObjectByKey(const TStringBuf key) const {
+TAutoPtr<IInputStream> TDirectoryModelsArchiveReader::ObjectByKey(const TStringBuf key) const {
return new TBlobOwningStream(BlobByKey(key));
-}
-
-TBlob TDirectoryModelsArchiveReader::ObjectBlobByKey(const TStringBuf key) const {
- return BlobByKey(key);
-}
-
-TBlob TDirectoryModelsArchiveReader::BlobByKey(const TStringBuf key) const {
+}
+
+TBlob TDirectoryModelsArchiveReader::ObjectBlobByKey(const TStringBuf key) const {
+ return BlobByKey(key);
+}
+
+TBlob TDirectoryModelsArchiveReader::BlobByKey(const TStringBuf key) const {
Y_ENSURE(Has(key), "key " << key << " not found");
if (auto ptr = BlobByKey_.FindPtr(key); ptr) {
return *ptr;
@@ -59,34 +59,34 @@ TBlob TDirectoryModelsArchiveReader::BlobByKey(const TStringBuf key) const {
return TBlob::FromFile(*ptr);
}
Y_UNREACHABLE();
-}
-
-bool TDirectoryModelsArchiveReader::Compressed() const {
- return false;
-}
-
-TString TDirectoryModelsArchiveReader::NormalizePath(TString path) const {
- path = "/" + path;
- for (size_t i = 0; i < path.size(); i++) {
- if (path[i] == '\\')
- path[i] = '/';
- }
- return path;
-}
-
+}
+
+bool TDirectoryModelsArchiveReader::Compressed() const {
+ return false;
+}
+
+TString TDirectoryModelsArchiveReader::NormalizePath(TString path) const {
+ path = "/" + path;
+ for (size_t i = 0; i < path.size(); i++) {
+ if (path[i] == '\\')
+ path[i] = '/';
+ }
+ return path;
+}
+
void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath, bool lockMemory, bool ownBlobs) {
- TFileList fileList;
- fileList.Fill(JoinFsPaths(Path_, subPath));
- const char* file;
- while ((file = fileList.Next()) != nullptr) {
- TString key = JoinFsPaths(subPath, TString(file));
+ TFileList fileList;
+ fileList.Fill(JoinFsPaths(Path_, subPath));
+ const char* file;
+ while ((file = fileList.Next()) != nullptr) {
+ TString key = JoinFsPaths(subPath, TString(file));
TString fullPath = JoinFsPaths(Path_, key);
TBlob fileBlob;
- if (lockMemory) {
+ if (lockMemory) {
fileBlob = TBlob::LockedFromFile(fullPath);
- } else {
+ } else {
fileBlob = TBlob::FromFile(fullPath);
- }
+ }
if (key.EndsWith(".archive")) {
TArchiveReader reader(fileBlob);
for (size_t i = 0, iEnd = reader.Count(); i < iEnd; ++i) {
@@ -104,12 +104,12 @@ void TDirectoryModelsArchiveReader::LoadFilesAndSubdirs(const TString& subPath,
}
Recs_.push_back(normalizedPath);
}
- }
-
- TDirsList dirsList;
- dirsList.Fill(JoinFsPaths(Path_, subPath));
- const char* dir;
- while ((dir = dirsList.Next()) != nullptr) {
+ }
+
+ TDirsList dirsList;
+ dirsList.Fill(JoinFsPaths(Path_, subPath));
+ const char* dir;
+ while ((dir = dirsList.Next()) != nullptr) {
LoadFilesAndSubdirs(JoinFsPaths(subPath, TString(dir)), lockMemory, ownBlobs);
- }
-}
+ }
+}