37 std::ifstream attrListFile;
43 m_directory = directory;
45 loginfo(
"checking for extraction...");
47 std::filesystem::path attrListFilePath;
48 for (
const std::string attrListFilename : ATTRLIST_FILENAMES)
50 loginfo(
"trying attrlist file: [" + attrListFilename +
"]...");
53 if (exists(attrListFilePath) && is_regular_file(attrListFilePath))
55 loginfo(
"found attrlist file: [" + attrListFilePath.string() +
"]");
60 m_path = attrListFilePath;
62 loginfo(
"any extraction complete, parsing data...");
64 if (!std::filesystem::exists(m_path))
66 auto message =
"attrlist file does not exist: [" + m_directory.string() +
"]";
71 else if (!std::filesystem::is_regular_file(m_path))
73 auto message =
"attrlist is not a file: [" + m_path.string() +
"]";
77 attrListFile.open(m_path.string(), std::ios::in);
78 if (!attrListFile.is_open())
80 auto message =
"unable to open attrlist file: [" + m_path.string() +
"]";
84 while (std::getline(attrListFile, line))
92 std::stringstream lineStream(line);
103 if (!std::getline(lineStream, token,
'='))
107 else if (!std::getline(lineStream, token,
'='))
117 std::string attribute;
120 if (!std::getline(lineStream, attribute,
'='))
125 if (!std::getline(lineStream, value))
127 if (!attributeValueIsOptional(attribute))
129 logwarn(
"attrlist file: no value for non-optional attribute: " + attribute);
137 m_attributesByName[attribute] = value;
142 attrListFile.close();
146 auto m = pe.
toString(
"Parse Error:");
148 attrListFile.close();
151 catch (std::exception& e)
156 attrListFile.close();
std::string ToUtf8(std::string_view input)
Converts input to valid UTF-8.