| 92 | } |
| 93 | |
| 94 | void 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 |
no test coverage detected