Skip to content

Commit

Permalink
change more references and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
idolpx committed Jul 6, 2023
1 parent 6cef56d commit 4a9d787
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions lib/FileSystem/fnFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const char * FileSystem::type_to_string(fsType type)
{
case FSTYPE_SPIFFS:
return "FS_SPIFFS";
case FSTYPE_LITTLEFS:
return "FS_LITTLEFS";
case FSTYPE_SDFAT:
return "FS_SDFAT";
case FSTYPE_TNFS:
Expand Down
30 changes: 15 additions & 15 deletions lib/config/fnc_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "../../include/debug.h"

/* Load configuration data from SPIFFS. If no config file exists in SPIFFS,
/* Load configuration data from FLASH. If no config file exists in FLASH,
copy it from SD if a copy exists there.
*/
void fnConfig::load()
Expand Down Expand Up @@ -46,15 +46,15 @@ void fnConfig::load()
#endif /* NO_BUTTONS */

/*
Original behavior: read from SPIFFS first and only read from SD if nothing found on SPIFFS.
Original behavior: read from FLASH first and only read from SD if nothing found on FLASH.
// See if we have a file in SPIFFS
// See if we have a file in FLASH
if(false == fsFlash.exists(CONFIG_FILENAME))
{
// See if we have a copy on SD (only copy from SD if we don't have a local copy)
if(fnSDFAT.running() && fnSDFAT.exists(CONFIG_FILENAME))
{
Debug_println("Found copy of config file on SD - copying that to SPIFFS");
Debug_println("Found copy of config file on SD - copying that to FLASH");
if(0 == fnSystem.copy_file(&fnSDFAT, CONFIG_FILENAME, &fsFlash, CONFIG_FILENAME))
{
Debug_println("Failed to copy config from SD");
Expand All @@ -69,9 +69,9 @@ Original behavior: read from SPIFFS first and only read from SD if nothing found
}
*/
/*
New behavior: copy from SD first if available, then read SPIFFS.
New behavior: copy from SD first if available, then read FLASH.
*/
// See if we have a copy on SD load it to check if we should write to spiffs (only copy from SD if we don't have a local copy)
// See if we have a copy on SD load it to check if we should write to flash (only copy from SD if we don't have a local copy)
FILE *fin = NULL; //declare fin
if (fnSDFAT.running() && fnSDFAT.exists(CONFIG_FILENAME))
{
Expand All @@ -86,7 +86,7 @@ New behavior: copy from SD first if available, then read SPIFFS.
Debug_println("No config found - starting fresh!");
return; // No local copy - ABORT
}
Debug_println("Load fnconfig.ini from spiffs");
Debug_println("Load fnconfig.ini from flash");
fin = fsFlash.file_open(CONFIG_FILENAME);
}
// Read INI file into buffer (for speed)
Expand Down Expand Up @@ -169,24 +169,24 @@ New behavior: copy from SD first if available, then read SPIFFS.

_dirty = false;

if (fnConfig::get_general_fnconfig_spifs() == true) // Only if spiffs is enabled
if (fnConfig::get_general_fnconfig_spifs() == true) // Only if flash is enabled
{
if (true == fsFlash.exists(CONFIG_FILENAME))
{
Debug_println("SPIFFS Config Storage: Enabled");
Debug_println("FLASH Config Storage: Enabled");
FILE *fin = fsFlash.file_open(CONFIG_FILENAME);
char *inibuffer = (char *)malloc(CONFIG_FILEBUFFSIZE);
if (inibuffer == nullptr)
{
Debug_printf("Failed to allocate %d bytes to read config file from SPIFFS\r\n", CONFIG_FILEBUFFSIZE);
Debug_printf("Failed to allocate %d bytes to read config file from FLASH\r\n", CONFIG_FILEBUFFSIZE);
return;
}
int i = fread(inibuffer, 1, CONFIG_FILEBUFFSIZE - 1, fin);
fclose(fin);
Debug_printf("fnConfig::load read %d bytes from SPIFFS config file\r\n", i);
Debug_printf("fnConfig::load read %d bytes from FLASH config file\r\n", i);
if (i < 0)
{
Debug_println("Failed to read data from SPIFFS configuration file");
Debug_println("Failed to read data from FLASH configuration file");
free(inibuffer);
return;
}
Expand All @@ -196,7 +196,7 @@ New behavior: copy from SD first if available, then read SPIFFS.
ss_ffs << inibuffer;
free(inibuffer);
if (ss.str() != ss_ffs.str()) {
Debug_println("Copying SD config file to SPIFFS");
Debug_println("Copying SD config file to FLASH");
if (0 == fnSystem.copy_file(&fnSDFAT, CONFIG_FILENAME, &fsFlash, CONFIG_FILENAME))
{
Debug_println("Failed to copy config from SD");
Expand All @@ -207,8 +207,8 @@ New behavior: copy from SD first if available, then read SPIFFS.
}
else
{
Debug_println("Config file dosn't exist on SPIFFS");
Debug_println("Copying SD config file to SPIFFS");
Debug_println("Config file dosn't exist on FLASH");
Debug_println("Copying SD config file to FLASH");
if (0 == fnSystem.copy_file(&fnSDFAT, CONFIG_FILENAME, &fsFlash, CONFIG_FILENAME))
{
Debug_println("Failed to copy config from SD");
Expand Down
10 changes: 5 additions & 5 deletions lib/config/fnc_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../../include/debug.h"

/* Save configuration data to SPIFFS. If SD is mounted, save a backup copy there.
/* Save configuration data to FLASH. If SD is mounted, save a backup copy there.
*/
void fnConfig::save()
{
Expand Down Expand Up @@ -161,16 +161,16 @@ void fnConfig::save()
FILE *fout = NULL;
if (fnConfig::get_general_fnconfig_spifs() == true) //only if spiffs is enabled
{
Debug_println("SPIFFS Config Storage: Enabled. Saving config to SPIFFS");
Debug_println("FLASH Config Storage: Enabled. Saving config to FLASH");
if ( !(fout = fsFlash.file_open(CONFIG_FILENAME, "w")))
{
Debug_println("Failed to Open config on SPIFFS");
Debug_println("Failed to Open config on FLASH");
return;
}
}
else
{
Debug_println("SPIFFS Config Storage: Disabled. Saving config to SD");
Debug_println("FLASH Config Storage: Disabled. Saving config to SD");
if ( !(fout = fnSDFAT.file_open(CONFIG_FILENAME, "w")))
{
Debug_println("Failed to Open config on SD");
Expand All @@ -185,7 +185,7 @@ void fnConfig::save()

_dirty = false;

// Copy to SD if possible, only when wrote SPIFFS first
// Copy to SD if possible, only when wrote FLASH first
if (fnSDFAT.running() && fnConfig::get_general_fnconfig_spifs() == true)
{
Debug_println("Attempting config copy to SD");
Expand Down
2 changes: 1 addition & 1 deletion lib/hardware/fnSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void SystemManager::delete_tempfile(FileSystem *fs, const char *filename)

/*
Remove specified temporary file, if fnSDFAT available, then file is deleted there,
otherwise deleted from SPIFFS
otherwise deleted from FLASH
*/
void SystemManager::delete_tempfile(const char *filename)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/printer-emulator/printer_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ printer_emu::~printer_emu()
// virtual void flushOutput(); // do this in pageEject

// Copy contents of given file to the current printer output file
// Assumes source file is in SPIFFS
// Assumes source file is in FLASH
size_t printer_emu::copy_file_to_output(const char *filename)
{
#define PRINTER_FILE_COPY_BUFLEN 2048
Expand Down

0 comments on commit 4a9d787

Please sign in to comment.