MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / LoadFile

Method LoadFile

Source/Runtime/Private/IO/FileSystem.cpp:767–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765//-------------------------------------------------------------------------------
766
767size_t FileSystem::LoadFile(const char *path, bool searchDirs, void **buffer) {
768 if (!path || !path[0]) {
769 BE_ERRLOG("FileSystem::LoadFile: empty filename\n");
770 if (buffer) {
771 *buffer = nullptr;
772 }
773 return 0;
774 }
775
776 size_t size;
777 File *file = OpenFileRead(path, searchDirs, &size);
778 if (!file) {
779 if (buffer) {
780 *buffer = nullptr;
781 }
782 return 0;
783 }
784
785 if (!buffer) {
786 CloseFile(file);
787 return size;
788 }
789
790 *buffer = (byte *)Mem_Alloc(size + 1);
791
792 file->Read(*buffer, size);
793 (*(byte **)buffer)[size] = 0;
794
795 CloseFile(file);
796
797 return size;
798}
799
800void FileSystem::FreeFile(void *buffer) const {
801 if (!buffer) {

Callers 15

ReadDictMethod · 0.45
ChangeScriptMethod · 0.45
LoadBinaryAnimMethod · 0.45
LoadMethod · 0.45
LoadMethod · 0.45
LoadBinaryMeshMethod · 0.45
LoadMethod · 0.45
LoadMethod · 0.45
LoadTextureInfoMethod · 0.45
LoadMethod · 0.45
LoadMethod · 0.45

Calls 2

Mem_AllocFunction · 0.85
ReadMethod · 0.45

Tested by

no test coverage detected