}
/* read entire binary file */
-VG_STATIC void *vg_file_read( void *lin_alloc, const char *path )
+VG_STATIC void *vg_file_read( void *lin_alloc, const char *path, u32 *size )
{
FILE *f = fopen( path, "rb" );
if( f )
buffer = vg_linear_resize( lin_alloc, buffer, current );
fclose( f );
+
+ *size = (u32)current;
return buffer;
}
}
/* get the size of the file just loaded */
+#if 0
VG_STATIC u32 vg_linear_last_size( void *allocator ); /* ? */
VG_STATIC u32 vg_file_size( void *lin_alloc )
{
return vg_linear_last_size( lin_alloc );
}
+#endif
/* read entire file and append a null on the end */
-VG_STATIC char *vg_file_read_text( void *lin_alloc, const char *path )
+VG_STATIC char *vg_file_read_text( void *lin_alloc, const char *path, u32 *sz )
{
- char *str = vg_file_read( lin_alloc, path );
+ u32 size;
+ char *str = vg_file_read( lin_alloc, path, &size );
if( !str )
return NULL;
/* include null terminator */
str = vg_linear_extend( lin_alloc, str, 1 );
- str[ vg_file_size(lin_alloc) ] = '\0';
+ str[ size ] = '\0';
+ *sz = size+1;
return str;
}