| 60 | } |
| 61 | |
| 62 | std::string Xtc::getTitle() const { |
| 63 | if (!loaded || !parser) { |
| 64 | return ""; |
| 65 | } |
| 66 | |
| 67 | // Try to get title from XTC metadata first |
| 68 | std::string title = parser->getTitle(); |
| 69 | if (!title.empty()) { |
| 70 | return title; |
| 71 | } |
| 72 | |
| 73 | // Fallback: extract filename from path as title |
| 74 | size_t lastSlash = filepath.find_last_of('/'); |
| 75 | size_t lastDot = filepath.find_last_of('.'); |
| 76 | |
| 77 | if (lastSlash == std::string::npos) { |
| 78 | lastSlash = 0; |
| 79 | } else { |
| 80 | lastSlash++; |
| 81 | } |
| 82 | |
| 83 | if (lastDot == std::string::npos || lastDot <= lastSlash) { |
| 84 | return filepath.substr(lastSlash); |
| 85 | } |
| 86 | |
| 87 | return filepath.substr(lastSlash, lastDot - lastSlash); |
| 88 | } |
| 89 | |
| 90 | std::string Xtc::getAuthor() const { |
| 91 | if (!loaded || !parser) { |
no test coverage detected