commit de4f216635ade797d2226a37354930daf8e142cd parent e579314d26473e21cab6ea8aaafa2f332450bbe3 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Jan 18 20:18:13 +0200 Add file_get_array Diffstat:
array.h | | | 9 | +++++++++ |
diff --git a/array.h b/array.h @@ -146,3 +146,12 @@ inline void visit( const array< T > & a, F f ) { f( a.n ); for( const T & x : a ) f( x ); } + +template< typename T > +inline array< T > file_get_array( const char * path ) { + size_t len; + u8 * mem = file_get_contents( path, &len ); + + ASSERT( len % sizeof( T ) == 0 ); + return array< T >( ( T * ) mem, len / sizeof( T ) ); +}