-->
Page 1 of 1

Files created by SPIFFS commands are not visible in FBrowser

PostPosted: Mon Apr 03, 2023 8:34 am
by DyadyaGenya
I am learning ESP8266 and SPIFFS file system. There is a plugin that allows you to upload files to a flash format formatted in this file system. And there is a FSBrowser sketch that allows you to view and download flash files in the browser. It works well. When I create a file in a sketch using commands, and then in the same sketch I check what is on the flash, the file I created is visible in the list. But when I upload the sketch with FSBrowser again, this file is not visible. If I upload a sketch with checking which files are on the flash, then the file is visible and all files that are uploaded using FSBrowser or using the plugin are visible. I create a file like this:
Code: Select allif(!SPIFFS.exists(path1+"edit/Test2.txt")){
// Create a file
  File file = SPIFFS.open(path1+"edit/Test2.txt", "w+");
// Check if the file has been created and if it is possible to write information to it
  if(!file){
    Serial.println("Can't open file for writing");
    SPIFFS.end();
    return;
    }
  else {
    file.write("Hellow, world\n");
    file.close();
    }
}

I check for the existence of files like this:
Code: Select allvoid main_scan(String path){
    int v = scan_dir(path);
    Serial.print("Total used in Dir \"" +path+ "\" = ");
    Serial println(v);
}

unsigned long scan_dir(String path) {
  Dir dir1 = SPIFFS.openDir(path);
  unsigned long total_size = 0;
  while (dir1.next()) {
      if (dir1.isFile()){
        Serial.print("File:\t");
        Serial.print(path + dir1.fileName());
        Serial.print("\tSize:\t");
        unsigned long f_size = dir1.fileSize();
        Serial.println(f_size);
        total_size += f_size;
      }
      if (dir1.isDirectory()) {
        unsigned long dsize = scan_dir(path+dir1.fileName()+"/");
        Serial.print("Dir:\t");
        Serial.print(path+dir1.fileName()+"/");
        Serial.print("\tSize:\t");
        Serial println(dsize);
        total_size += dsize;
      }
  }
  return total_size;
}

Can someone tell me why when using FSBrowser files that are created using commands are not visible? And how to make these files visible?

Re: Files created by SPIFFS commands are not visible in FBro

PostPosted: Wed Apr 05, 2023 5:49 am
by DyadyaGenya
I wanted to clarify that by FSBrowser I meant the standard library, which is installed when installing the ESP8266 board and is among the standard examples. Her github page: https://github.com/esp8266/Arduino/tree ... /FSBrowser