File IO operations

What is the correct way to create a file from within a Legato application ? We need to create and save a configuration file during the application initialization, however, any and all attempts to create, open, read, write, and even close the file fail. The result is always a null file pointer or a return value of LE_FAULT.

I have tried :
a) FILE *fp = fopen( filename, “rw”)
b) int fd = open(filename, O_RDWR);
c) int fd = le_flock_open(filename, LE_FLOCK_READ);
d) int fd = le_atomFile_Open(filename, LE_FLOCK_READ);

Only (d) above has worked and ONLY if unsandboxed. (a) - (c) fail with or without sandboxing.

I have added the dir entry to the .adef file.

It cannot be this difficult to create a file in Legato. What I am missing ?

Using legato 16.10.1

Hi @dsnedigar

Are you able to share the dir entry? Be aware that a lot of the directories within Legato are read-only.

I too experienced file creation issues. Making sure that both the dir was ‘writeable’ and the app was unsandboxed (as you’ve discovered) resolved this.

Cheers,
Raf