MCPcopy Create free account
hub / github.com/comaps/comaps / ForEachTrackFile

Function ForEachTrackFile

tools/track_analyzing/utils.cpp:94–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void ForEachTrackFile(std::string const & filepath, std::string const & extension,
95 shared_ptr<routing::NumMwmIds> numMwmIds,
96 std::function<void(std::string const & filename, MwmToMatchedTracks const &)> && toDo)
97{
98 Platform::EFileType fileType = Platform::EFileType::Unknown;
99 Platform::EError const result = Platform::GetFileType(filepath, fileType);
100
101 if (result == Platform::ERR_FILE_DOES_NOT_EXIST)
102 MYTHROW(MessageException, ("File doesn't exist", filepath));
103
104 if (result != Platform::ERR_OK)
105 MYTHROW(MessageException, ("Can't get file type for", filepath, "result:", result));
106
107 if (fileType == Platform::EFileType::Regular)
108 {
109 MwmToMatchedTracks mwmToMatchedTracks;
110 ReadTracks(numMwmIds, filepath, mwmToMatchedTracks);
111 toDo(filepath, mwmToMatchedTracks);
112 return;
113 }
114
115 if (fileType == Platform::EFileType::Directory)
116 {
117 Platform::FilesList filesList;
118 Platform::GetFilesRecursively(filepath, filesList);
119
120 for (string const & file : filesList)
121 {
122 if (base::GetFileExtension(file) != extension)
123 continue;
124
125 MwmToMatchedTracks mwmToMatchedTracks;
126 ReadTracks(numMwmIds, file, mwmToMatchedTracks);
127 toDo(file, mwmToMatchedTracks);
128 }
129
130 return;
131 }
132
133 MYTHROW(MessageException, (filepath, "is neither a regular file nor a directory't exist"));
134}
135} // namespace track_analyzing

Callers 2

CmdTracksFunction · 0.85
CmdTagsTableFunction · 0.85

Calls 2

ReadTracksFunction · 0.85
GetFileExtensionFunction · 0.85

Tested by

no test coverage detected