antithing
(antithing)
1
I need to find all files with a .fbx extension in a given folder.
I have found this function:
IFileManager::FindFilesRecursive()
and i have this:
IFileManager *x = NULL;
const TCHAR* RootPath = _T("D:/assets/test");
TArray<FString> Files;
const TCHAR* extension = _T("*.fbx");
x->FindFilesRecursive(Files, RootPath, extension, true, false, false);
when I run the code, it breaks on:
x->FindFilesRecursive(Files, RootPath, extension, true, false, false);
with an ‘unhandled exception / access violation reading location’.
Where am I going wrong here?
Thanks.
Jambax
(Jambax)
2
You’re never initializing ‘x’, so it’s a nullptr dereference by the looks of it.
Ignore creating the pointer to IFileManager, just call IFileManager::FindFilesRecursive instead.
antithing
(antithing)
3
Thanks for your reply.
IFileManager::FindFilesRecursive(Files, RootPath, extension, true, false, false);
gives me the error:
‘a nonstatic member reference must be relative to a specific object’.
Jambax
(Jambax)
4
Okay yeah scratch my previous post then, FindFilesRecursive isn’t static so you need an IFileManager. Try this:
IFileManager* _FileManager = IFileManager::Get();
const TCHAR* RootPath = _T("D:/assets/test");
TArray<FString> Files;
const TCHAR* extension = _T("*.fbx");
_FileManager->FindFilesRecursive(Files, RootPath, extension, true, false, false);
1 Like
antithing
(antithing)
5
Works like a dream. Many thanks yet again!
rgoldblum
(rgoldblum)
7
I tried this and got an error "error C2440: ‘initializing’: cannot convert from ‘IFileManager’ to ‘IFileManager *’ ". How do I fix this?
Jambax
(Jambax)
8
If you look at the code in VS you will find that the static getter returns a ref now, so:
IFileManager::Get().FindFilesRecursive()