Changeset 438 for trunk/src/io
- Timestamp:
- 07/23/15 17:29:49 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/io/c_file_system.cc
r395 r438 11 11 using namespace nv; 12 12 13 13 14 c_file_system::c_file_system() 14 15 { … … 21 22 } 22 23 23 bool c_file_system::exists( const char*fpath )24 bool c_file_system::exists( const string_view& fpath ) 24 25 { 25 FILE* file = ::fopen( fpath , "rb" );26 FILE* file = ::fopen( fpath.data(), "rb" ); 26 27 if ( !file ) 27 28 { … … 32 33 } 33 34 34 stream* c_file_system::open( const char* fpath, const char*fmode /*= "rb" */ )35 stream* c_file_system::open( const string_view& fpath, const string_view& fmode /*= "rb" */ ) 35 36 { 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() ); 38 39 if ( !file ) 39 40 { 40 41 return nullptr; 41 42 } 42 return new c_stream( file, fpath );43 return new c_stream( file, fpath.data() ); 43 44 } 45 46 nv::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.