Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I read a binary file.

ANSWERED

I'm trying to read some binary data. I've added a file called "level_data.bin" to the resources folder but I can't open it for reading.

 

import * as fs from "fs";

let file = fs.openSync("../resources/level_data.bin", "r");
  • [22:31:17]App Started
  • [22:31:17]Unhandled Error
  • [22:31:17]Couldn't open file: ../resources/level_data.bin
  • [22:31:17] at ./app/index.js:30:9
  • at ./app/index.js:21:5
  • at ./app/index.js:54:1

I've tried it with / and \ and no path at all, thinking it might automatically look in the resources folder. I've also tried the file in the app folder (so there's no relative path), but it just can't open it.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hey Allan!

 

Can you try: /mnt/assets/resources/

 

Let me know how you get on!

View best answer in original post

Best Answer
5 REPLIES 5

Are you certain the file is being copied to the app?

You can download the packaged app (option on the top toolbar inside Studio) and unpack it to see if the file is indeed being packed or not.  I'm not certain of how they have rollup configured, so you might have to figure out a clever hack for getting it bundled if not. (Just a hunch)

Best Answer
0 Votes

Good point! I will check that and see when I get back on my computer. 

Best Answer
0 Votes

I've checked the package and the file is definitely there, and definitely in the resources folder.

Best Answer
0 Votes

Hey Allan!

 

Can you try: /mnt/assets/resources/

 

Let me know how you get on!

Best Answer

It got past the load, now to figure out how to actually access the data!

 

Thanks.

Best Answer
0 Votes