| 558 | } |
| 559 | |
| 560 | std::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 | |
| 584 | std::unique_ptr<sfh::FontDatabase> sfh::FontDatabase::ReadFromFile(const std::wstring& path) |
| 585 | { |
nothing calls this directly
no test coverage detected