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

Method LoadFile

src/openboardview/BoardView.cpp:85–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int BoardView::LoadFile(const filesystem::path &filepath) {
86 m_lastFileOpenWasInvalid = true;
87 m_validBoard = false;
88 if (!filepath.empty()) {
89 // clean up the previous file.
90 if (m_file && m_board) {
91 m_pinHighlighted.clear();
92 m_partHighlighted.clear();
93 m_annotations.Close();
94 m_board->Nets().clear();
95 m_board->Pins().clear();
96 m_board->Components().clear();
97 m_board->OutlinePoints().clear();
98 m_board->OutlineSegments().clear();
99 // delete m_file;
100 // delete m_board;
101 }
102 delete m_file;
103 m_file = nullptr;
104 m_validBoard = false;
105 m_error_msg.clear();
106 pdfBridge.CloseDocument();
107
108 SetLastFileOpenName(filepath.string());
109 std::vector<char> buffer = file_as_buffer(filepath, m_error_msg);
110 if (!buffer.empty()) {
111 if (check_fileext(filepath, ".fz")) { // Since it is encrypted we cannot use the below logic. Trust the ext.
112 FZFile *fzfile = new FZFile();
113 fzfile->parse(buffer, config.FZKey);
114 m_file = fzfile;
115 } else if (check_fileext(filepath, ".cae")) { // Since it is encrypted we cannot use the below logic. Trust the ext.
116 CAEFile *caefile = new CAEFile();
117 caefile->parse(buffer, config.CAEKey);
118 m_file = caefile;
119 } else if (check_fileext(filepath, ".bom") || check_fileext(filepath, ".asc"))
120 m_file = new ASCFile(buffer, filepath);
121 else if (GenCADFile::verifyFormat(buffer))
122 m_file = new GenCADFile(buffer);
123 else if (ADFile::verifyFormat(buffer))
124 m_file = new ADFile(buffer);
125 else if (CADFile::verifyFormat(buffer))
126 m_file = new CADFile(buffer);
127 else if (check_fileext(filepath, ".cst"))
128 m_file = new CSTFile(buffer);
129 else if (BRDFile::verifyFormat(buffer))
130 m_file = new BRDFile(buffer);
131 else if (BRD2File::verifyFormat(buffer))
132 m_file = new BRD2File(buffer);
133 else if (BDVFile::verifyFormat(buffer))
134 m_file = new BDVFile(buffer);
135 else if (BVRFile::verifyFormat(buffer))
136 m_file = new BVRFile(buffer);
137 else if (BVR3File::verifyFormat(buffer))
138 m_file = new BVR3File(buffer);
139 else if (BRDAllegroFile::verifyFormat(buffer))
140 m_file = new BRDAllegroFile(buffer);
141 else if (XZZPCBFile::verifyFormat(buffer))
142 m_file = new XZZPCBFile(buffer, config.XZZPCBKey);

Callers 1

mainFunction · 0.80

Calls 11

file_as_bufferFunction · 0.85
check_fileextFunction · 0.85
CloseMethod · 0.80
parseMethod · 0.80
Prepend_saveMethod · 0.80
SetFilenameMethod · 0.80
clearMethod · 0.45
CloseDocumentMethod · 0.45
LoadMethod · 0.45
loadFromConfigMethod · 0.45
OpenDocumentMethod · 0.45

Tested by

no test coverage detected