MCPcopy Create free account
hub / github.com/Kitware/VTK / AddFileNames

Method AddFileNames

IO/Core/vtkGlobFileNames.cxx:62–118  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

60
61//------------------------------------------------------------------------------
62int vtkGlobFileNames::AddFileNames(const char* pattern)
63{
64 this->SetPattern(pattern);
65
66 vtksys::Glob glob;
67
68 if (this->Recurse)
69 {
70 glob.RecurseOn();
71 }
72 else
73 {
74 glob.RecurseOff();
75 }
76
77 if (!this->Pattern)
78 {
79 vtkErrorMacro(<< "FindFileNames: pattern string is null.");
80
81 return 0;
82 }
83
84 std::string fullPattern = this->Pattern;
85
86 if (this->Directory && this->Directory[0] != '\0')
87 {
88 std::vector<std::string> components;
89 vtksys::SystemTools::SplitPath(fullPattern, components);
90 // If Pattern is a relative path, prepend with Directory
91 if (components[0].empty())
92 {
93 components.insert(components.begin(), this->Directory);
94 fullPattern = vtksys::SystemTools::JoinPath(components);
95 }
96 }
97
98 if (!glob.FindFiles(fullPattern))
99 {
100 vtkErrorMacro(<< "FindFileNames: Glob action failed for \"" << fullPattern << "\"");
101
102 return 0;
103 }
104
105 // copy the filenames from glob
106 std::vector<std::string> files = glob.GetFiles();
107
108 // sort them lexicographically
109 std::sort(files.begin(), files.end());
110
111 // add them onto the list of filenames
112 for (std::vector<std::string>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
113 {
114 this->FileNames->InsertNextValue(iter->c_str());
115 }
116
117 return 1;
118}
119

Callers 4

testGlobFileNamesMethod · 0.80
testSortFileNamesMethod · 0.80
LoadRenderModelMappingFunction · 0.80

Calls 8

FindFilesMethod · 0.80
sortFunction · 0.50
emptyMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
InsertNextValueMethod · 0.45
c_strMethod · 0.45

Tested by 2

testGlobFileNamesMethod · 0.64
testSortFileNamesMethod · 0.64