MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / loadFromConfig

Method loadFromConfig

src/openboardview/PDFBridge/PDFFile.cpp:27–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void PDFFile::loadFromConfig(const filesystem::path &filepath) {
28 configFilepath = filepath; // save filepath for latter use with writeToConfig
29
30 // Use boardview file path as default PDF file path, with ext replaced with .pdf
31 path = filepath;
32 path.replace_extension("pdf");
33
34 if (!filesystem::exists(filepath)) { // Config file doesn't exist, do not attempt to read or write it and load images
35 SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Board configuration file %s does not exist", filepath.generic_string().c_str());
36 return;
37 }
38
39 SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading PDF file path from board configuration file: %s", filepath.generic_string().c_str());
40
41 auto configDir = filesystem::weakly_canonical(filepath).parent_path();
42
43 Confparse confparse{};
44 confparse.Load(filepath);
45
46
47 std::string pdfFilePathStr{confparse.ParseStr("PDFFilePath", "")};
48 if (!pdfFilePathStr.empty())
49 path = configDir/filesystem::u8path(pdfFilePathStr);
50
51 writeToConfig(filepath);
52}
53
54void PDFFile::writeToConfig(const filesystem::path &filepath) {
55 if (filepath.empty()) // No destination file to save to

Callers 1

LoadFileMethod · 0.45

Calls 2

ParseStrMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected