From 5f006a5aa87bcd1777ae4448d80f9b67e94253b4 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Fri, 30 Jun 2023 09:55:28 +0900 Subject: [PATCH] Fix IMGMAKE large size image error (MinGW) --- CHANGELOG | 1 + src/dos/dos_programs.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 296b708a833..ec176603d73 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ Next allocated block position. (maxpat78) - Enhanced Dynamic and Differencing VHD support #4273 (maxpat78) - Imported IBM Music Feature Card support from DOSBox Staging. (Allofich) + - Fix IMGMAKE large size image error on MinGW builds (maron2000) 2023.05.01 - IMGMAKE will choose LBA partition types for 2GB or larger disk images, but the user can also use -chs and -lba options to override diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 5ce58de5634..182878dd1f2 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -3542,7 +3542,7 @@ class IMGMAKE : public Program { return; } -#if defined (_MSC_VER) && (_MSC_VER >= 1400) +#if (defined (_MSC_VER) && (_MSC_VER >= 1400)) || defined(__MINGW32__) if(fseeko64(f, (__int64)(size - 1ull), SEEK_SET)) { #else if(fseeko64(f, static_cast(size - 1ull), SEEK_SET)) { @@ -3568,8 +3568,8 @@ class IMGMAKE : public Program { unsigned int sectors_per_cluster = 0; unsigned int vol_sectors = 0; unsigned int fat_copies = 2; /* number of copies of the FAT. always 2. TODO: Allow the user to specify */ - unsigned int fatlimitmin; - unsigned int fatlimit; + uint32_t fatlimitmin; + uint32_t fatlimit; int FAT = -1; /* FAT filesystem, user choice */ @@ -3655,16 +3655,16 @@ class IMGMAKE : public Program { /* highest cluster number + 1 */ switch (FAT) { case 32: - fatlimit = 0x0FFFFFF6; - fatlimitmin = 0xFFF6; + fatlimit = 0x0FFFFFF6u; + fatlimitmin = 0xFFF6u; break; case 16: - fatlimit = 0xFFF6; - fatlimitmin = 0xFF6; + fatlimit = 0xFFF6u; + fatlimitmin = 0xFF6u; break; case 12: - fatlimit = 0xFF6; - fatlimitmin = 0; + fatlimit = 0xFF6u; + fatlimitmin = 0u; break; default: abort(); @@ -9385,7 +9385,7 @@ void DOS_SetupPrograms(void) { #endif MSG_Add("PROGRAM_IMGMAKE_FILE_EXISTS","The file \"%s\" already exists. You can specify \"-force\" to overwrite.\n"); MSG_Add("PROGRAM_IMGMAKE_CANNOT_WRITE","The file \"%s\" cannot be opened for writing.\n"); - MSG_Add("PROGRAM_IMGMAKE_NOT_ENOUGH_SPACE","Not enough space available for the image file. Need %u bytes.\n"); + MSG_Add("PROGRAM_IMGMAKE_NOT_ENOUGH_SPACE","Not enough space available for the image file. Need %lld bytes.\n"); MSG_Add("PROGRAM_IMGMAKE_PRINT_CHS","Creating image file \"%s\" with %u cylinders, %u heads and %u sectors\n"); MSG_Add("PROGRAM_IMGMAKE_CANT_READ_FLOPPY","\n\nUnable to read floppy."); MSG_Add("PROGRAM_IMGMAKE_BADSIZE","Wrong -size or -chs arguments.\n");