blob: 5f79fda070f7762480b17d5e5641d9682c1076eb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "NamesProvider.h"
#include <IO/ReadBufferFromFile.h>
#include "NamesFormatReader.h"
#include <filesystem>
namespace fs = std::filesystem;
bool LanguageRegionsNamesDataSource::isModified() const
{
return updates_tracker.isModified();
}
size_t LanguageRegionsNamesDataSource::estimateTotalSize() const
{
return fs::file_size(path);
}
ILanguageRegionsNamesReaderPtr LanguageRegionsNamesDataSource::createReader()
{
updates_tracker.fixCurrentVersion();
auto file_reader = std::make_shared<DB::ReadBufferFromFile>(path);
return std::make_unique<LanguageRegionsNamesFormatReader>(std::move(file_reader));
}
std::string LanguageRegionsNamesDataSource::getLanguage() const
{
return language;
}
std::string LanguageRegionsNamesDataSource::getSourceName() const
{
return path;
}
RegionsNamesDataProvider::RegionsNamesDataProvider(const std::string & directory_) : directory(directory_)
{
}
ILanguageRegionsNamesDataSourcePtr RegionsNamesDataProvider::getLanguageRegionsNamesSource(const std::string & language) const
{
const auto data_file = getDataFilePath(language);
if (fs::exists(data_file))
return std::make_unique<LanguageRegionsNamesDataSource>(data_file, language);
else
return {};
}
std::string RegionsNamesDataProvider::getDataFilePath(const std::string & language) const
{
return directory + "/regions_names_" + language + ".txt";
}
|