MCPcopy Create free account
hub / github.com/catboost/catboost / Fill

Method Fill

util/folder/filelist.cpp:7–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <util/system/defaults.h>
6
7void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringBuf suffix, int depth, bool sort) {
8 TDirIterator::TOptions opts;
9 opts.SetMaxLevel(depth);
10 if (sort) {
11 opts.SetSortByName();
12 }
13
14 TDirIterator dir(dirname, opts);
15 Clear();
16
17 size_t dirNameLength = dirname.length();
18 while (dirNameLength && (dirname[dirNameLength - 1] == '\\' || dirname[dirNameLength - 1] == '/')) {
19 --dirNameLength;
20 }
21
22 for (auto file = dir.begin(); file != dir.end(); ++file) {
23 if (file->fts_pathlen == file->fts_namelen || file->fts_pathlen <= dirNameLength) {
24 continue;
25 }
26
27 TStringBuf filename = file->fts_path + dirNameLength + 1;
28
29 if (filename.empty() || !filename.StartsWith(prefix) || !filename.EndsWith(suffix)) {
30 continue;
31 }
32
33 if (((Mask & EM_FILES) && file->fts_info == FTS_F) || ((Mask & EM_DIRS) && file->fts_info == FTS_D) || ((Mask & EM_SLINKS) && file->fts_info == FTS_SL)) {
34 ++FileNamesSize;
35 FileNames.Append(filename.data(), filename.size() + 1);
36 }
37 }
38
39 Restart();
40}

Callers 2

TestSimpleMethod · 0.45
TestPrefixMethod · 0.45

Calls 10

ClearFunction · 0.50
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
StartsWithMethod · 0.45
EndsWithMethod · 0.45
AppendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by 2

TestSimpleMethod · 0.36
TestPrefixMethod · 0.36