| 106 | } |
| 107 | |
| 108 | FileInfo ParseArchiveFilename(std::string const & fileName) |
| 109 | { |
| 110 | std::string const metaData = base::GetNameFromFullPathWithoutExt(fileName); |
| 111 | size_t const indexFirstDelim = metaData.find(kDelimiter); |
| 112 | size_t const indexLastDelim = metaData.rfind(kDelimiter); |
| 113 | if (indexFirstDelim != 1 || indexLastDelim != 12) |
| 114 | { |
| 115 | LOG(LWARNING, ("Could not find delimiters in filename", fileName)); |
| 116 | return {}; |
| 117 | } |
| 118 | |
| 119 | try |
| 120 | { |
| 121 | FileInfo res; |
| 122 | res.m_protocolVersion = static_cast<uint32_t>(std::stoul(metaData.substr(0, indexFirstDelim))); |
| 123 | res.m_timestamp = std::stoul(metaData.substr(indexFirstDelim + 1, indexLastDelim - indexFirstDelim - 1)); |
| 124 | res.m_trackType = static_cast<routing::RouterType>(std::stoul(metaData.substr(indexLastDelim + 1))); |
| 125 | return res; |
| 126 | } |
| 127 | catch (std::exception const & e) |
| 128 | { |
| 129 | LOG(LWARNING, ("Error while parsing filename", e.what())); |
| 130 | } |
| 131 | return {}; |
| 132 | } |
| 133 | } // namespace archival_file |
| 134 | } // namespace tracking |