| 594 | } |
| 595 | |
| 596 | void CLocatorAPI::_initialize(u32 flags, LPCSTR fs_name) |
| 597 | { |
| 598 | if (m_Flags.is(flReady)) |
| 599 | return; |
| 600 | CTimer t; |
| 601 | t.Start(); |
| 602 | Log("Initializing File System..."); |
| 603 | u32 M1 = Memory.mem_usage(); |
| 604 | |
| 605 | m_Flags.set(flags, TRUE); |
| 606 | |
| 607 | // scan root directory |
| 608 | string4096 buf{}; |
| 609 | IReader* pFSltx{}; |
| 610 | // append working folder |
| 611 | LPCSTR fs_ltx{}; |
| 612 | |
| 613 | // append application path |
| 614 | append_path(fsgame::app_root, Core.ApplicationPath, nullptr, FALSE); |
| 615 | |
| 616 | { |
| 617 | // find nearest fs.ltx and set fs_root correctly |
| 618 | fs_ltx = (fs_name && fs_name[0]) ? fs_name : FSLTX; |
| 619 | pFSltx = r_open(fs_ltx); |
| 620 | |
| 621 | if (!pFSltx) |
| 622 | pFSltx = r_open(fsgame::app_root, fs_ltx); |
| 623 | |
| 624 | // находим где ж лежит fsgame.ltx |
| 625 | |
| 626 | if (!pFSltx) |
| 627 | { |
| 628 | if (strstr(Core.Params, "-use-work-dir")) |
| 629 | { |
| 630 | string_path currentDir; |
| 631 | GetCurrentDirectory(std::size(currentDir) - 1, currentDir); |
| 632 | currentDir[std::size(currentDir) - 1] = '\0'; |
| 633 | append_path(fsgame::fs_root, currentDir, nullptr, FALSE); |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | string_path tmpAppPath{}; |
| 638 | strcpy_s(tmpAppPath, Core.ApplicationPath); |
| 639 | if (xr_strlen(tmpAppPath)) |
| 640 | { |
| 641 | tmpAppPath[xr_strlen(tmpAppPath) - 1] = 0; |
| 642 | if (strrchr(tmpAppPath, '\\')) |
| 643 | *(strrchr(tmpAppPath, '\\') + 1) = 0; |
| 644 | |
| 645 | append_path(fsgame::fs_root, tmpAppPath, nullptr, FALSE); |
| 646 | } |
| 647 | else |
| 648 | append_path(fsgame::fs_root, "", nullptr, FALSE); |
| 649 | } |
| 650 | |
| 651 | pFSltx = r_open(fsgame::fs_root, fs_ltx); |
| 652 | } |
| 653 | else |
nothing calls this directly
no test coverage detected