mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-16 19:05:39 +00:00
dep/libchdr: Add option to transfer file ownership
This commit is contained in:
parent
62c5e3af2f
commit
bd1cf91030
|
@ -256,6 +256,7 @@ extern "C" {
|
||||||
/* CHD open values */
|
/* CHD open values */
|
||||||
#define CHD_OPEN_READ 1
|
#define CHD_OPEN_READ 1
|
||||||
#define CHD_OPEN_READWRITE 2
|
#define CHD_OPEN_READWRITE 2
|
||||||
|
#define CHD_OPEN_TRANSFER_FILE 4 /* Freeing of the FILE* is now libchdr's responsibility if open was successful */
|
||||||
|
|
||||||
/* error types */
|
/* error types */
|
||||||
enum _chd_error
|
enum _chd_error
|
||||||
|
|
|
@ -1528,7 +1528,13 @@ CHD_EXPORT chd_error chd_open_file(FILE *file, int mode, chd_file *parent, chd_f
|
||||||
stream->fclose = core_stdio_fclose_nonowner;
|
stream->fclose = core_stdio_fclose_nonowner;
|
||||||
stream->fseek = core_stdio_fseek;
|
stream->fseek = core_stdio_fseek;
|
||||||
|
|
||||||
return chd_open_core_file(stream, mode, parent, chd);
|
chd_error err = chd_open_core_file(stream, mode, parent, chd);
|
||||||
|
if (err != CHDERR_NONE)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
// swap out the fclose so that we close it on chd clost
|
||||||
|
stream->fclose = core_stdio_fclose;
|
||||||
|
return CHDERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue