MCPcopy Create free account
hub / github.com/Kitware/CMake / Load

Method Load

Source/kwsys/Directory.cxx:157–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155namespace KWSYS_NAMESPACE {
156
157Status Directory::Load(std::string const& name, std::string* errorMessage)
158{
159 this->Clear();
160 HANDLE srchHandle;
161 char* buf;
162 size_t bufLength;
163 size_t n = name.size();
164 if (name.back() == '/' || name.back() == '\\') {
165 bufLength = n + 1 + 1;
166 buf = new char[bufLength];
167 snprintf(buf, bufLength, "%s*", name.c_str());
168 } else {
169 // Make sure the slashes in the wildcard suffix are consistent with the
170 // rest of the path
171 bufLength = n + 2 + 1;
172 buf = new char[bufLength];
173 if (name.find('\\') != std::string::npos) {
174 snprintf(buf, bufLength, "%s\\*", name.c_str());
175 } else {
176 snprintf(buf, bufLength, "%s/*", name.c_str());
177 }
178 }
179 WIN32_FIND_DATAW data; // data of current file
180
181 // Now put them into the file array
182 srchHandle =
183 FindFirstFileW(Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
184 delete[] buf;
185
186 if (srchHandle == INVALID_HANDLE_VALUE) {
187 Status status = Status::Windows_GetLastError();
188 if (errorMessage) {
189 *errorMessage = status.GetString();
190 }
191 return status;
192 }
193
194 // Loop through names
195 do {
196 this->Internal->Files.emplace_back(Encoding::ToNarrow(data.cFileName),
197 data);
198 } while (FindNextFileW(srchHandle, &data));
199 this->Internal->Path = name;
200 if (!FindClose(srchHandle)) {
201 Status status = Status::Windows_GetLastError();
202 if (errorMessage) {
203 *errorMessage = status.GetString();
204 }
205 return status;
206 }
207 return Status::Success();
208}
209
210unsigned long Directory::GetNumberOfFilesInDirectory(std::string const& name,
211 std::string* errorMessage)

Callers 15

LoadCoverageDataMethod · 0.45
LoadCoverageDataMethod · 0.45
GenerateXMLLaunchedMethod · 0.45
RunMakeCommandMethod · 0.45
CopyADirectoryMethod · 0.45
RemoveADirectoryMethod · 0.45

Calls 8

c_strMethod · 0.80
emplace_backMethod · 0.80
snprintfFunction · 0.50
ClearMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45
findMethod · 0.45
GetStringMethod · 0.45

Tested by 7

GenerateXMLLaunchedMethod · 0.36
RunMakeCommandMethod · 0.36
doLongPathTestFunction · 0.36
nonExistentDirectoryTestFunction · 0.36