MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / ReadFromFile

Method ReadFromFile

PersistantDataLib/PersistantData.cpp:560–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560std::unique_ptr<sfh::ConfigFile> sfh::ConfigFile::ReadFromFile(const std::wstring& path)
561{
562 auto com = wil::CoInitializeEx();
563
564 wil::unique_variant pathVariant;
565 wil::com_ptr<IStream> stream;
566 THROW_IF_FAILED_MSG(
567 SHCreateStreamOnFileEx(
568 path.c_str(),
569 STGM_FAILIFTHERE | STGM_READ | STGM_SHARE_EXCLUSIVE,
570 FILE_ATTRIBUTE_NORMAL,
571 FALSE,
572 nullptr,
573 stream.put()), "CANNOT OPEN CONFIG FILE: %ws", path.c_str());
574 InitVariantFromUnknown(stream.query<IUnknown>().get(), pathVariant.addressof());
575
576 auto saxReader = wil::CoCreateInstance<ISAXXMLReader>(CLSID_SAXXMLReader30);
577 wil::com_ptr<ConfigSAXContentHandler> handler(new ConfigSAXContentHandler);
578 THROW_IF_FAILED(saxReader->putContentHandler(handler.get()));
579 THROW_IF_FAILED_MSG(saxReader->parse(pathVariant), "BAD CONFIG: %ws", path.c_str());
580
581 return handler->GetConfigFile();
582}
583
584std::unique_ptr<sfh::FontDatabase> sfh::FontDatabase::ReadFromFile(const std::wstring& path)
585{

Callers

nothing calls this directly

Calls 2

GetConfigFileMethod · 0.80
GetFontDatabaseMethod · 0.80

Tested by

no test coverage detected