mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 01:45:19 +01:00
filesystem: add new API function LoadFileMalloc that returns a pointer that can be freed using standard free()
This commit is contained in:
parent
bb03e2597c
commit
636a2228f6
@ -2490,6 +2490,10 @@ static byte *FS_LoadFile_( const char *path, fs_offset_t *filesizeptr, const qbo
|
||||
return buf;
|
||||
}
|
||||
|
||||
byte *FS_LoadFileMalloc( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||
{
|
||||
return FS_LoadFile_( path, filesizeptr, gamedironly, false );
|
||||
}
|
||||
|
||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
|
||||
{
|
||||
@ -3042,6 +3046,7 @@ fs_api_t g_api =
|
||||
(void *)FS_MountArchive_Fullpath,
|
||||
|
||||
FS_GetFullDiskPath,
|
||||
FS_LoadFileMalloc,
|
||||
};
|
||||
|
||||
int EXPORT GetFSAPI( int version, fs_api_t *api, fs_globals_t **globals, fs_interface_t *engfuncs );
|
||||
|
@ -196,6 +196,9 @@ typedef struct fs_api_t
|
||||
void *(*MountArchive_Fullpath)( const char *path, int flags );
|
||||
|
||||
qboolean (*GetFullDiskPath)( char *buffer, size_t size, const char *name, qboolean gamedironly );
|
||||
|
||||
// like LoadFile but returns pointer that can be free'd using standard library function
|
||||
byte *(*LoadFileMalloc)( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
|
||||
} fs_api_t;
|
||||
|
||||
typedef struct fs_interface_t
|
||||
|
@ -103,7 +103,7 @@ typedef struct searchpath_s
|
||||
int (*pfnFileTime)( struct searchpath_s *search, const char *filename );
|
||||
int (*pfnFindFile)( struct searchpath_s *search, const char *path, char *fixedname, size_t len );
|
||||
void (*pfnSearch)( struct searchpath_s *search, stringlist_t *list, const char *pattern, int caseinsensitive );
|
||||
byte *(*pfnLoadFile)( struct searchpath_s *search, const char *path, int pack_ind, fs_offset_t *filesize );
|
||||
byte *(*pfnLoadFile)( struct searchpath_s *search, const char *path, int pack_ind, fs_offset_t *filesize, void *( *pfnAlloc )( size_t ), void ( *pfnFree )( void * ));
|
||||
} searchpath_t;
|
||||
|
||||
typedef searchpath_t *(*FS_ADDARCHIVE_FULLPATH)( const char *path, int flags );
|
||||
@ -181,6 +181,7 @@ qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
|
||||
|
||||
// file buffer ops
|
||||
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
|
||||
byte *FS_LoadFileMalloc( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
|
||||
byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr );
|
||||
qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user