Skip to content
/ bart Public

Commit 9b6a032

Browse files
committed
stl/misc.c: rewind file descriptor for MacOS
Seems like it needs it
1 parent 1522f69 commit 9b6a032

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/stl/misc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <stdbool.h>
1111
#include <complex.h>
12+
#include <errno.h>
1213
#include <limits.h>
1314
#include <stdio.h>
1415
#include <stdint.h>
@@ -430,6 +431,12 @@ static void stl_read_ascii(FILE *fp, long dims[3], double* model)
430431
static double* stl_read_binary(FILE* fp, long dims[3])
431432
{
432433
int fd = fileno(fp);
434+
#ifdef __APPLE__
435+
// Mac OS needs the file descriptor to be rewinded:
436+
const int lseek_ret = lseek(fd, 0, SEEK_SET);
437+
if (0 != lseek_ret)
438+
error("lseek() returned %d (!= 0), errno: %d\n", lseek_ret, errno);
439+
#endif
433440

434441
char tmp[80];
435442

0 commit comments

Comments
 (0)