Ignore:
Timestamp:
07/23/15 17:29:49 (10 years ago)
Author:
epyon
Message:
  • massive amount of std::string removal
  • removed slurp, use filesystem::slurp instead
  • lua_values const_string support
  • several bugfixes
  • program_manager and shader loading without std::string/std::stream
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/io/c_file_system.cc

    r395 r438  
    1111using namespace nv;
    1212
     13
    1314c_file_system::c_file_system()
    1415{
     
    2122}
    2223
    23 bool c_file_system::exists( const char* fpath )
     24bool c_file_system::exists( const string_view& fpath )
    2425{
    25         FILE* file = ::fopen( fpath, "rb" );
     26        FILE* file = ::fopen( fpath.data(), "rb" );
    2627        if ( !file )
    2728        {
     
    3233}
    3334
    34 stream* c_file_system::open( const char* fpath, const char* fmode /*= "rb" */ )
     35stream* c_file_system::open( const string_view& fpath, const string_view& fmode /*= "rb" */ )
    3536{
    36         NV_ASSERT( fpath != nullptr && fmode != nullptr, "Bad parameters passed to open" );
    37         FILE* file = ::fopen( fpath, fmode );
     37        NV_ASSERT( !fpath.empty() && !fmode.empty(), "Bad parameters passed to open" );
     38        FILE* file = ::fopen( fpath.data(), fmode.data() );
    3839        if ( !file )
    3940        {
    4041                return nullptr;
    4142        }
    42         return new c_stream( file, fpath );
     43        return new c_stream( file, fpath.data() );
    4344}
     45
     46nv::const_string c_file_system::slurp( const string_view& path )
     47{
     48        stream* fstream = open( path, "rb" );
     49        if ( !fstream ) return const_string();
     50        uint32 size = fstream->size();
     51        const_string result( nullptr, size );
     52        fstream->read( const_cast<char*>( result.data() ), size, 1 );
     53        delete fstream;
     54        return result;
     55}
Note: See TracChangeset for help on using the changeset viewer.