MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / project_load

Function project_load

TheForceEngine/TFE_Editor/editorProject.cpp:125–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123 }
124
125 bool project_load(const char* filepath)
126 {
127 FileStream projectFile;
128 if (!projectFile.open(filepath, Stream::MODE_READ))
129 {
130 return false;
131 }
132 resources_clear();
133
134 const u32 len = (u32)projectFile.getSize();
135 WorkBuffer& buffer = getWorkBuffer();
136 buffer.resize(len);
137 projectFile.readBuffer(buffer.data(), len);
138 projectFile.close();
139
140 TFE_Parser parser;
141 parser.init((char*)buffer.data(), len);
142 parser.addCommentString(";");
143 parser.addCommentString("#");
144
145 s_curProject = Project{};
146 s_curStringOut = nullptr;
147 size_t bufferPos = 0;
148 bool inResource = false;
149 while (bufferPos < len)
150 {
151 const char* line = parser.readLine(bufferPos);
152 if (!line) { break; }
153
154 if (s_curStringOut)
155 {
156 if (line[0] == '}')
157 {
158 // Done.
159 s_curStringOut = nullptr;
160 }
161 else
162 {
163 *s_curStringOut += line;
164 *s_curStringOut += "\n";
165 }
166 continue;
167 }
168 else if (strcasecmp(line, "[Resource]") == 0)
169 {
170 resources_createExternalEmpty();
171 inResource = true;
172 continue;
173 }
174
175 TokenList tokens;
176 parser.tokenizeLine(line, tokens);
177 if (tokens.size() < 1) { continue; }
178
179 if (tokens.size() == 2)
180 {
181 if (inResource)
182 {

Callers 2

menuFunction · 0.85

Calls 15

resources_clearFunction · 0.85
resources_parseFunction · 0.85
parseProjectValueFunction · 0.85
logWriteFunction · 0.85
removeFromRecentsFunction · 0.85
addToRecentsFunction · 0.85
rebuildAssetsFunction · 0.85
dataMethod · 0.80
addCommentStringMethod · 0.80
readLineMethod · 0.80
tokenizeLineMethod · 0.80

Tested by

no test coverage detected