----------------------------------------------------------------------------- Purpose: reading and writing files in the vortex directory -----------------------------------------------------------------------------
| 614 | // Purpose: reading and writing files in the vortex directory |
| 615 | //----------------------------------------------------------------------------- |
| 616 | std::vector<uint8_t> Path_ReadBinaryFile( const std::string & strFilename ) |
| 617 | { |
| 618 | FILE *f; |
| 619 | #if defined( POSIX ) |
| 620 | f = fopen( strFilename.c_str(), "rb" ); |
| 621 | #else |
| 622 | std::wstring wstrFilename = UTF8to16( strFilename.c_str() ); |
| 623 | // the open operation needs to be sharable, therefore use of _wfsopen instead of _wfopen_s |
| 624 | f = _wfsopen( wstrFilename.c_str(), L"rb", _SH_DENYNO ); |
| 625 | #endif |
| 626 | |
| 627 | std::vector<uint8_t> vecFileContents; |
| 628 | |
| 629 | if ( f != NULL ) |
| 630 | { |
| 631 | fseek( f, 0, SEEK_END ); |
| 632 | int size = ftell( f ); |
| 633 | if ( size > 0 ) |
| 634 | { |
| 635 | fseek( f, 0, SEEK_SET ); |
| 636 | |
| 637 | vecFileContents.resize( size ); |
| 638 | if ( fread( &vecFileContents[ 0 ], size, 1, f ) == 1 ) |
| 639 | { |
| 640 | } |
| 641 | else |
| 642 | { |
| 643 | vecFileContents.clear(); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | fclose( f ); |
| 648 | } |
| 649 | |
| 650 | return vecFileContents ; |
| 651 | } |
| 652 | |
| 653 | |
| 654 | unsigned char * Path_ReadBinaryFile( const std::string &strFilename, int *pSize ) |
no test coverage detected