[BUG]
Describe the bug Jupiter does not seem to be able to read binary files A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen. It does not appear like an attach a binary file here.
Screenshots If applicable, add screenshots to help explain your problem.
Jupiter (please complete the following information):
- OS: [e.g. OS X]
- Version [e.g. v3.1]
- Mode GUI]
Additional context When you fread from a binary file, e.g., txt file (convert to binary before trying to fread). 5 3 1 -3 4 46 -2 -5 2 -62 0 1 3 13 26 -7 34
The first fread returns 5, but subsequent fread returns 0.
More details. This seems related to how readBytes is implemented. It seems to assume that the entire file is read at once by the program. This will not work, if we do not know how many bytes to read. https://github.com/andrescv/Jupiter/blob/c51efb6bc925abb37a9c1316a40b1fc458d62ed5/src/main/java/jupiter/utils/FS.java#L160
e.g., assume file
Bytes to read
Data.....
Program read() // Read metadata allocate bytes read() // Read data
Now, we first need to read a 4 byte metadata at the beginning of the file to figure out how many more bytes we want to read from the file i.e., we need to issue multiple read calls to the file descriptor.
The first read() will return # Bytes, but in the current implementation the subsequent read call will fail as it assumes the file has already been read and it will return 0 bytes.
You need to main a seek pointer for each file descriptor within the VirtualFS (just like libc would).