MCPcopy Create free account
hub / github.com/BobbyAnguelov/FbxFormatConverter / GetFileFormat

Function GetFileFormat

main.cpp:82–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 }
81
82 static FileFormat GetFileFormat( std::string const& filePath )
83 {
84 FileFormat fileFormat = FileFormat::Unknown;
85
86 FILE* fp = nullptr;
87 int errcode = fopen_s( &fp, filePath.c_str(), "r" );
88 if ( errcode != 0 )
89 {
90 return fileFormat;
91 }
92
93 //-------------------------------------------------------------------------
94
95 fseek( fp, 0, SEEK_END );
96 size_t filesize = (size_t) ftell( fp );
97 fseek( fp, 0, SEEK_SET );
98
99 void* pFileData = malloc( filesize );
100 size_t readLength = fread( pFileData, 1, filesize, fp );
101 fclose( fp );
102
103 //-------------------------------------------------------------------------
104
105 // Ascii files cannot contain the null character
106 if ( memchr( pFileData, '\0', readLength ) != NULL )
107 {
108 fileFormat = FileFormat::Binary;
109 }
110 else
111 {
112 fileFormat = FileFormat::Ascii;
113 }
114
115 return fileFormat;
116 }
117
118 static void GetDirectoryContents( std::string const& directoryPath, std::vector<std::string>& directoryContents )
119 {

Callers 1

PrintFileFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected