Commit 817d72272b9a49d54bf5f62fba24a733c35ad7a1

Authored by adam.b
1 parent 9451f0b7

fixed a svace error

Change-Id: I9a89e885e2ea1f239319b38c784441c2ea586cfa
Showing 1 changed file with 17 additions and 11 deletions
examples/fpp-game/game-utils.cpp
@@ -25,19 +25,25 @@ namespace GameUtils @@ -25,19 +25,25 @@ namespace GameUtils
25 bool LoadFile( const char* filename, ByteArray& bytes ) 25 bool LoadFile( const char* filename, ByteArray& bytes )
26 { 26 {
27 FILE* fin = fopen( filename, "rb" ); 27 FILE* fin = fopen( filename, "rb" );
28 - if( fseek( fin, 0, SEEK_END ) ) 28 + if( fin )
29 { 29 {
30 - return false; 30 + if( fseek( fin, 0, SEEK_END ) )
  31 + {
  32 + fclose(fin);
  33 + return false;
  34 + }
  35 + bytes.resize( ftell( fin ) );
  36 + std::fill( bytes.begin(), bytes.end(), 0 );
  37 + if( fseek( fin, 0, SEEK_SET ) )
  38 + {
  39 + fclose( fin );
  40 + return false;
  41 + }
  42 + size_t result = fread( bytes.data(), 1, bytes.size(), fin );
  43 + fclose( fin );
  44 + return ( result != 0 );
31 } 45 }
32 - bytes.resize( ftell( fin ) );  
33 - std::fill( bytes.begin(), bytes.end(), 0 );  
34 - if( fseek( fin, 0, SEEK_SET ) )  
35 - {  
36 - return false;  
37 - }  
38 - size_t result = fread( bytes.data(), 1, bytes.size(), fin );  
39 - fclose( fin );  
40 - return (result != 0); 46 + return false;
41 } 47 }
42 48
43 size_t HashString( const char* str ) 49 size_t HashString( const char* str )