X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/293f677cbfbaae984fc3063c62d4b9afa0067520..a1c6fe2d2428cb8a1b4a9e11a9a5075a4bccecd1:/Plugson/src/Core/ventoy_util_linux.c diff --git a/Plugson/src/Core/ventoy_util_linux.c b/Plugson/src/Core/ventoy_util_linux.c index 69b6022..c432f08 100644 --- a/Plugson/src/Core/ventoy_util_linux.c +++ b/Plugson/src/Core/ventoy_util_linux.c @@ -292,6 +292,41 @@ void ventoy_stop_writeback_thread(void) } + +int ventoy_read_file_to_buf(const char *FileName, int ExtLen, void **Bufer, int *BufLen) +{ + int FileSize; + FILE *fp = NULL; + void *Data = NULL; + + fp = fopen(FileName, "rb"); + if (fp == NULL) + { + vlog("Failed to open file %s", FileName); + return 1; + } + + fseek(fp, 0, SEEK_END); + FileSize = (int)ftell(fp); + + Data = malloc(FileSize + ExtLen); + if (!Data) + { + fclose(fp); + return 1; + } + + fseek(fp, 0, SEEK_SET); + fread(Data, 1, FileSize, fp); + + fclose(fp); + + *Bufer = Data; + *BufLen = FileSize; + + return 0; +} + int ventoy_copy_file(const char *a, const char *b) { int len = 0;