| 277 | } |
| 278 | |
| 279 | LSError ParamFile::Parse(const char* name) |
| 280 | { |
| 281 | SetName(name); |
| 282 | |
| 283 | // Log full absolute path of file being parsed |
| 284 | char fullPath[512]; |
| 285 | #ifdef _WIN32 |
| 286 | ::GetFullPathNameA(name, sizeof(fullPath), fullPath, nullptr); |
| 287 | #else |
| 288 | if (!realpath(name, fullPath)) |
| 289 | strncpy(fullPath, name, sizeof(fullPath) - 1); |
| 290 | #endif |
| 291 | LOG_DEBUG(Core, "ParamFile::Parse() - Loading config file: {}", fullPath); |
| 292 | |
| 293 | if (!QIFStreamB::FileExist(name)) |
| 294 | { |
| 295 | LOG_DEBUG(Core, "ParamFile::Parse() - File does not exist: {}", fullPath); |
| 296 | return LSOK; |
| 297 | } |
| 298 | |
| 299 | #if OUTPUT_PREPROC |
| 300 | QOFStream out; |
| 301 | #else |
| 302 | QOStream out; |
| 303 | #endif |
| 304 | if (!Preprocess(out, name)) |
| 305 | { |
| 306 | return LSStructure; |
| 307 | } |
| 308 | #if OUTPUT_PREPROC |
| 309 | ::DeleteFile("bin/output.txt"); |
| 310 | out.export("bin/output.txt"); |
| 311 | #endif |
| 312 | QIStream in; |
| 313 | in.init(out.str(), out.pcount()); |
| 314 | Parse(in); |
| 315 | #if DIAG_OPEN |
| 316 | if (_entries.Size() > 0) |
| 317 | { |
| 318 | ParamFileOpen++; |
| 319 | LOG_DEBUG(Core, "{}: Parsed paramfile {}", ParamFileOpen, name); |
| 320 | } |
| 321 | #endif |
| 322 | return in.fail() ? in.error() : LSOK; |
| 323 | } |
| 324 | |
| 325 | void Indent(QOStream& f, int indent) |
| 326 | { |