Can't write text file on SD card

Hello,

I’m trying to write to a file on the SD card but it doesn’t work. I’m using an ANAFI-AI drone on the latest version (7.6) and I’m following the documentation available here: Storage and persistence - 7.6
I can create folders, but when I want to create a file and write to it, nothing happens.
This is the part of the code I use. The folder is well created but not the file. Do you have any idea ?

std::stringstream temp;
temp << "/mnt/user/" << "testFolder";

char prop[SYS_PROP_VALUE_MAX];

sys_prop_get("user.storage.status", prop, "0");
if (strcmp(prop, "ready") == 0) {
  /* The storage is ready to be used */
  mkdir(temp.str().c_str(), 0777);
  std::ofstream outputFile;
  outputFile.open("/mnt/user/hello.txt");
  outputFile << "Hello world \n";
  outputFile.close();
}

Thank you very much,

Thibaut

This topic was automatically closed after 30 days. New replies are no longer allowed.