MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / ReadFile

Function ReadFile

Engine/source/core/volume.cpp:923–975  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923bool ReadFile(const Path &inPath, void *&outData, U32 &outSize, bool inNullTerminate )
924{
925 FileRef fileR = OpenFile( inPath, File::Read );
926
927 outData = NULL;
928 outSize = 0;
929
930 // We'll get a NULL file reference if
931 // the file failed to open.
932 if ( fileR == NULL )
933 return false;
934
935 outSize = fileR->getSize();
936
937 // Its not a failure to read an empty
938 // file... but we can exit early.
939 if ( outSize == 0 )
940 return true;
941
942 U32 sizeRead = 0;
943
944 if ( inNullTerminate )
945 {
946 outData = new char [outSize+1];
947 if( !outData )
948 {
949 // out of memory
950 return false;
951 }
952 sizeRead = fileR->read(outData, outSize);
953 static_cast<char *>(outData)[outSize] = '\0';
954 }
955 else
956 {
957 outData = new char [outSize];
958 if( !outData )
959 {
960 // out of memory
961 return false;
962 }
963 sizeRead = fileR->read(outData, outSize);
964 }
965
966 if ( sizeRead != outSize )
967 {
968 delete static_cast<char *>(outData);
969 outData = NULL;
970 outSize = 0;
971 return false;
972 }
973
974 return true;
975}
976
977DirectoryRef OpenDirectory(const Path &path)
978{

Callers 11

windows_file_readFunction · 0.85
executeFileFunction · 0.85
loadProfileScriptMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85
readMemoryMethod · 0.85
openFileMethod · 0.85
readMethod · 0.85
VerifyWriteAccessMethod · 0.85
readMethod · 0.85

Calls 3

OpenFileFunction · 0.85
getSizeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected