| 6637 | } |
| 6638 | |
| 6639 | void Script::InitFuncLibrary(FuncLibrary &aLib, LPTSTR aPathBase, LPTSTR aPathSuffix) |
| 6640 | { |
| 6641 | TCHAR buf[T_MAX_PATH + 1]; // +1 to ensure truncated paths are filtered out due to being too long for GetFileAttributes(). It would probably have to be intentional due to MAX_PATH limits elsewhere, but this +1 costs nothing. |
| 6642 | int length = sntprintf(buf, _countof(buf), _T("%s%s"), aPathBase, aPathSuffix); |
| 6643 | DWORD attr = GetFileAttributes(buf); // Seems to accept directories that have a trailing backslash, which is good because it simplifies the code. |
| 6644 | if (attr == 0xFFFFFFFF || !(attr & FILE_ATTRIBUTE_DIRECTORY)) // Directory doesn't exist or it's a file vs. directory. Relies on short-circuit boolean order. |
| 6645 | { |
| 6646 | aLib.path = _T(""); |
| 6647 | return; |
| 6648 | } |
| 6649 | // Allow room for appending each candidate file/function name. This could be exactly |
| 6650 | // MAX_PATH on ANSI builds since no path longer than that would work, but doing it this |
| 6651 | // way simplifies length checks later (and Unicode builds support much longer paths). |
| 6652 | size_t buf_size = length + MAX_VAR_NAME_LENGTH + FUNC_LIB_EXT_LENGTH + 1; |
| 6653 | aLib.path = SimpleHeap::Alloc<TCHAR>(buf_size); |
| 6654 | tmemcpy(aLib.path, buf, length + 1); |
| 6655 | aLib.length = length; |
| 6656 | } |
| 6657 | |
| 6658 | void Script::IncludeLibrary(LPTSTR aFuncName, size_t aFuncNameLength, bool &aErrorWasShown, bool &aFileWasFound) |
| 6659 | // Caller must ensure that aFuncName doesn't already exist as a defined function. |
nothing calls this directly
no test coverage detected