| 139 | } |
| 140 | |
| 141 | void FUnrealEnginePythonModule::RunFile(char *filename) { |
| 142 | FScopePythonGIL gil; |
| 143 | char *full_path = filename; |
| 144 | if (!FPaths::FileExists(filename)) |
| 145 | { |
| 146 | full_path = TCHAR_TO_UTF8(*FPaths::Combine(*FPaths::GameContentDir(), UTF8_TO_TCHAR("Scripts"), *FString("/"), UTF8_TO_TCHAR(filename))); |
| 147 | } |
| 148 | FILE *fd = nullptr; |
| 149 | |
| 150 | #if PLATFORM_WINDOWS |
| 151 | if (fopen_s(&fd, full_path, "r") != 0) { |
| 152 | UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); |
| 153 | return; |
| 154 | } |
| 155 | #else |
| 156 | fd = fopen(full_path, "r"); |
| 157 | if (!fd) { |
| 158 | UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); |
| 159 | return; |
| 160 | } |
| 161 | #endif |
| 162 | PyObject *eval_ret = PyRun_File(fd, full_path, Py_file_input, (PyObject *)main_dict, (PyObject *)local_dict); |
| 163 | fclose(fd); |
| 164 | if (!eval_ret) { |
| 165 | unreal_engine_py_log_error(); |
| 166 | return; |
| 167 | } |
| 168 | Py_DECREF(eval_ret); |
| 169 | } |
| 170 | |
| 171 | #undef LOCTEXT_NAMESPACE |
| 172 |
no test coverage detected