Info

This question is closed. Reopen it to edit or answer.

Windows 10 can read my .bin files but Ubuntu cannot?

1 view (last 30 days)
I'm running a basic analysis script that requires two .bin files to be read in. On win10 the following works
d1=[];
d2=[];
filenameA= 'Results...A.bin';
filenameB='Results...B.bin';
fid1=fopen(filenameA,'r+');
fid2=fopen(filenameB,'r+');
chunk_size=1e6;
precision='uint64';
d1=fread(fid1,chunk_size,precision);
d2=fread(fid2,chunk_size,precision);
fclose('all');
and reads in the data perfectly fine. On Ubuntu this does not work. d1 and d2 end up just being 0 by 0 arrays. The error doesn't occur until later in the code (when I try to use a size of d1, d2) so I know that it isn't an issue about incorrect filename, working dir, or similar, because the code gets further than this bit. Why would this be an issue? Is it related to file line endings? can this be implemented as an argument with fread?
edit: MATLAB 2019b
  9 Comments
Walter Roberson
Walter Roberson on 5 Nov 2020
Bruno, I am not clear why you indicate that it would fail with 'r+' flag? 'r+' is valid to indicate reading and writing. It does not create the file if it does not exist and it should initially position at beginning of file, but it permits switching to writing in the same file (provided that you fseek each time you switch between reading and writing)
https://www.mathworks.com/help/matlab/ref/fopen.html#btrnibn-1-permission
Bruno Luong
Bruno Luong on 5 Nov 2020
Edited: Bruno Luong on 5 Nov 2020
In linux here is what happen if a file opened with 'r+' but doesn't have write permission:
$ touch toto
$ chmod -w toto
$ ls -alrt toto
-r--r--r-- 1 Bruno 197121 0 Nov 5 19:01 toto
MATLAB
>> fid=fopen('toto','r+')
fid =
-1

Answers (0)

Tags

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!