Create directory

Hi,
I want to create directory, but system allows me to do it, only when in my .adef file sandboxed: false.

I have got in .adef :
requires:
{
dir:
{
/mnt/userrw /
}
}

my .c file
le_result_t Err = le_dir_Make(“/mnt/userrw/TestDir”, S_IRUSR | S_IWUSR);
if(Err == LE_DUPLICATE)
{
//System creates folder “/mnt/userrw/TestDir” but instead of Err == LE_OK
//I have got Err == LE_DUPLICATE which is weird.
}

I am going to store data in files located in the folder, so I have to have permission to create/read/write files there.

Questions:

  1. Do I have to have sandboxed:false? If not what should I change in my program to create dir.
  2. Which folder should I use for my data storage?
  3. Why system returns LE_DUPLICATE instead of LE_OK

Thanks

Hi @TheGod,

  1. I believe you need to run the app unsanboxed in order to create new directories.
    See my post here: Unable to make new directories within Legato app - #3 by raf
    Having sandboxed: false was the only way it worked.

  • For persistent data storage:
    I’ve used the same path and mounted an SD card at /mnt/userrw/sd.
    If you are going to be storing lots of files or doing lots of write/erase operations on the module’s non-volatile Flash memory, be conscious of Flash wear (finite write/erase cycles - typically 100000). You may want to consider external memory.

  • For non-persistent data storage (wiped on power cycle):
    Use /tmp - this is mapped to the module’s RAM so there’s no concern over Flash wear here.

  1. See: le_dir.h File Reference - Legato Docs
    le_dir_Make will return LE_DUPLICATE if the directory already exists. Try using le_dir_MakePath instead.

Raf

1 Like