Skip to content

Commit 268a188

Browse files
author
Ian Seyler
committed
Fix for writing large files without create
1 parent e7d82ae commit 268a188

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/bmfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string.h>
1010
#include <strings.h>
1111
#include <ctype.h>
12+
#include <math.h>
1213

1314
/* Typedefs */
1415
typedef uint8_t u8;
@@ -818,7 +819,14 @@ void bmfs_write(char *filename)
818819
rewind(tfile);
819820
if (0 == bmfs_find(filename, &tempentry, &slot))
820821
{
821-
bmfs_create(filename, (tempfilesize+blockSize)/blockSize);
822+
if (tempfilesize < blockSize)
823+
{
824+
bmfs_create(filename, (tempfilesize+blockSize)/blockSize);
825+
}
826+
else
827+
{
828+
bmfs_create(filename, ceil((tempfilesize+1048576)/1048576));
829+
}
822830
bmfs_find(filename, &tempentry, &slot);
823831
}
824832
if ((tempentry.ReservedBlocks*blockSize) < tempfilesize)

0 commit comments

Comments
 (0)