MCPcopy Create free account
hub / github.com/20tab/UnrealEnginePython / RunFile

Method RunFile

Source/UnrealEnginePython/Private/UnrealEnginePython.cpp:141–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141void 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

Callers 3

py_unreal_engine_execFunction · 0.80
MainMethod · 0.80
ExecutePythonScriptMethod · 0.80

Calls 1

Tested by

no test coverage detected