Fix T62707: opening blend files over 2gb on win32 fails
Regression in 358e07f447
for ms-windows since off_t is an int32_t
even on 64bit systems causing files over 2gb not to load.
Poison off_t so this doesn't happen again.
This commit is contained in:
parent
4db7842a72
commit
7ba82f3f0a
Notes:
blender-bot
2023-02-14 03:19:10 +01:00
Referenced by issue #62741, Large point cache saved in blend file causes Blender to exit when opened Referenced by issue #62707, Blender crashes when opening file - Older beta opens the file normal
|
@ -264,7 +264,7 @@ typedef struct BHeadN {
|
|||
struct BHeadN *next, *prev;
|
||||
#ifdef USE_BHEAD_READ_ON_DEMAND
|
||||
/** Use to read the data from the file directly into memory as needed. */
|
||||
off_t file_offset;
|
||||
off64_t file_offset;
|
||||
/** When set, the remainder of this allocation is the data, otherwise it needs to be read. */
|
||||
bool has_data;
|
||||
#endif
|
||||
|
@ -838,7 +838,7 @@ static BHeadN *get_bhead(FileData *fd)
|
|||
new_bhead->file_offset = fd->file_offset;
|
||||
new_bhead->has_data = false;
|
||||
new_bhead->bhead = bhead;
|
||||
off_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
|
||||
off64_t seek_new = fd->seek(fd, bhead.len, SEEK_CUR);
|
||||
if (seek_new == -1) {
|
||||
fd->is_eof = true;
|
||||
MEM_freeN(new_bhead);
|
||||
|
@ -946,7 +946,7 @@ static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
|
|||
bool success = true;
|
||||
BHeadN *new_bhead = BHEADN_FROM_BHEAD(thisblock);
|
||||
BLI_assert(new_bhead->has_data == false && new_bhead->file_offset != 0);
|
||||
off_t offset_backup = fd->file_offset;
|
||||
off64_t offset_backup = fd->file_offset;
|
||||
if (UNLIKELY(fd->seek(fd, new_bhead->file_offset, SEEK_SET) == -1)) {
|
||||
success = false;
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ static int fd_read_data_from_file(FileData *filedata, void *buffer, uint size)
|
|||
return (readsize);
|
||||
}
|
||||
|
||||
static off_t fd_seek_data_from_file(FileData *filedata, off_t offset, int whence)
|
||||
static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence)
|
||||
{
|
||||
filedata->file_offset = lseek(filedata->filedes, offset, whence);
|
||||
return filedata->file_offset;
|
||||
|
|
|
@ -48,10 +48,17 @@ enum eFileDataFlag {
|
|||
FD_FLAGS_NOT_MY_LIBMAP = 1 << 5,
|
||||
};
|
||||
|
||||
/* Disallow since it's 32bit on ms-windows. */
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC poison off_t
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
typedef int64_t off64_t;
|
||||
#endif
|
||||
|
||||
typedef int (FileDataReadFn)(struct FileData *filedata, void *buffer, unsigned int size);
|
||||
typedef off_t (FileDataSeekFn)(struct FileData *filedata, off_t offset, int whence);
|
||||
typedef off64_t (FileDataSeekFn)(struct FileData *filedata, off64_t offset, int whence);
|
||||
|
||||
typedef struct FileData {
|
||||
/** Linked list of BHeadN's. */
|
||||
|
@ -59,7 +66,7 @@ typedef struct FileData {
|
|||
enum eFileDataFlag flags;
|
||||
bool is_eof;
|
||||
int buffersize;
|
||||
off_t file_offset;
|
||||
int64_t file_offset;
|
||||
|
||||
FileDataReadFn *read;
|
||||
FileDataSeekFn *seek;
|
||||
|
|
Loading…
Reference in New Issue