Create directory


#1

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


#2

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
    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: http://legato.io/legato-docs/latest/le__dir_8h.html#a7ac7d25b67f2e47127084677626d5344
    le_dir_Make will return LE_DUPLICATE if the directory already exists. Try using le_dir_MakePath instead.

Raf