+#else
+ if ((fd = open(string[tok[1]], _OPEN_INC)) < 0)
+ {
+ errors("cannot open include binary file (%s)", string[tok[1]]);
+ return ERROR;
+ }
+
+ size = lseek(fd, 0L, SEEK_END);
+ pos = lseek(fd, 0L, SEEK_SET);
+ chcheck(size);
+
+ DEBUG
+ {
+ printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size);
+ }
+
+#if 0
+ for(i=0; i<size; i++)
+ {
+ buf = '\0';
+ bytes = read(j, &buf, 1);
+ D_byte(buf);
+ }
+#else
+ char * fileBuffer = (char *)malloc(size);
+ bytesRead = read(fd, fileBuffer, size);
+
+ if (bytesRead != size)
+ {
+ sprintf(msg, "was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[tok[1]], size);
+ error(msg);
+ return ERROR;
+ }
+
+//#define D_byte(b) {*chptr++=(char)b; ++sloc; ++ch_size; if(orgactive) ++orgaddr;}
+ memcpy(chptr, fileBuffer, size);
+ chptr += size;
+ sloc += size;
+ ch_size += size;