MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ParsePlayedTimeLine

Method ParsePlayedTimeLine

pcsx2/GameList.cpp:982–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

980}
981
982bool GameList::ParsePlayedTimeLine(char* line, std::string& serial, PlayedTimeEntry& entry)
983{
984 size_t len = std::strlen(line);
985 if (len != (PLAYED_TIME_LINE_LENGTH + 1)) // \n
986 {
987 Console.Warning("(ParsePlayedTimeLine) Malformed line: '%s'", line);
988 return false;
989 }
990
991 const std::string_view serial_tok(StringUtil::StripWhitespace(std::string_view(line, PLAYED_TIME_SERIAL_LENGTH)));
992 const std::string_view total_played_time_tok(
993 StringUtil::StripWhitespace(std::string_view(line + PLAYED_TIME_SERIAL_LENGTH + 1, PLAYED_TIME_LAST_TIME_LENGTH)));
994 const std::string_view last_played_time_tok(StringUtil::StripWhitespace(
995 std::string_view(line + PLAYED_TIME_SERIAL_LENGTH + 1 + PLAYED_TIME_LAST_TIME_LENGTH + 1, PLAYED_TIME_TOTAL_TIME_LENGTH)));
996
997 const std::optional<u64> total_played_time(StringUtil::FromChars<u64>(total_played_time_tok));
998 const std::optional<u64> last_played_time(StringUtil::FromChars<u64>(last_played_time_tok));
999 if (serial_tok.empty() || !last_played_time.has_value() || !total_played_time.has_value())
1000 {
1001 Console.Warning("(ParsePlayedTimeLine) Malformed line: '%s'", line);
1002 return false;
1003 }
1004
1005 serial = serial_tok;
1006 entry.last_played_time = static_cast<std::time_t>(last_played_time.value());
1007 entry.total_played_time = static_cast<std::time_t>(total_played_time.value());
1008 return true;
1009}
1010
1011std::string GameList::MakePlayedTimeLine(const std::string& serial, const PlayedTimeEntry& entry)
1012{

Callers

nothing calls this directly

Calls 4

StripWhitespaceFunction · 0.85
WarningMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected