Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerlembke committed Feb 23, 2025
1 parent 06b3b87 commit 1f564b2
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ notizen.txt
*.cmd
.vscode
makeESPFMfGKdeflate
examplesCopy
!postbuild.cmd
24 changes: 24 additions & 0 deletions examples/advanced/ESPFMfGKdropin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ void addFileSystems(void) {
}

uint32_t checkFileFlags(fs::FS &fs, String filename, uint32_t flags) {
// Show file/path in Lists
// filenames start without "/", pathnames start with "/"
if (flags & (ESPFMfGK::flagCheckIsFilename | ESPFMfGK::flagCheckIsPathname)) {
/** /
Serial.print("flagCheckIsFilename || flagCheckIsPathname check: ");
Serial.println(filename);
/**/
if (flags | ESPFMfGK::flagCheckIsFilename) {
if (filename.startsWith(".")) {
// Serial.println(filename + " flagIsNotVisible");
return ESPFMfGK::flagIsNotVisible;
}
}
/*
this will catch a pathname like /.test, but *not* /foo/.test
so you might use .indexOf()
*/
if (flags | ESPFMfGK::flagCheckIsPathname) {
if (filename.startsWith("/.")) {
// Serial.println(filename + " flagIsNotVisible");
return ESPFMfGK::flagIsNotVisible;
}
}
}

// this will hide system files (in my world, system files start with a dot)
if (filename.startsWith("/.")) {
Expand Down
25 changes: 25 additions & 0 deletions examples/simple/ESPFMfGKdropin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ void addFileSystems(void) {
}

uint32_t checkFileFlags(fs::FS &fs, String filename, uint32_t flags) {
// Show file/path in Lists
// filenames start without "/", pathnames start with "/"
if (flags & (ESPFMfGK::flagCheckIsFilename | ESPFMfGK::flagCheckIsPathname)) {
/** /
Serial.print("flagCheckIsFilename || flagCheckIsPathname check: ");
Serial.println(filename);
/**/
if (flags | ESPFMfGK::flagCheckIsFilename) {
if (filename.startsWith(".")) {
// Serial.println(filename + " flagIsNotVisible");
return ESPFMfGK::flagIsNotVisible;
}
}
/*
this will catch a pathname like /.test, but *not* /foo/.test
so you might use .indexOf()
*/
if (flags | ESPFMfGK::flagCheckIsPathname) {
if (filename.startsWith("/.")) {
// Serial.println(filename + " flagIsNotVisible");
return ESPFMfGK::flagIsNotVisible;
}
}
}

// Checks if target file name is valid for action. This will simply allow everything by returning the queried flag
if (flags & ESPFMfGK::flagIsValidAction) {
return flags & (~ESPFMfGK::flagIsValidAction);
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32 File Manager for Generation Klick ESPFMfGK
version=2.0.13
version=2.0.14
author=Holger Lembke
maintainer=Holger Lembke <lembke@gmail.com>
sentence=Manage your ES32 file system content with a simple web based interface
Expand Down
56 changes: 36 additions & 20 deletions src/ESPFMfGK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ int ESPFMfGK::getFileSystemIndex(bool uselastFileSystemIndex)
*/

//*****************************************************************************************************
// flat view
void ESPFMfGK::recurseFolderList(String foldername, int maxtiefe, int tiefe)
{
int fsi = getFileSystemIndex(false);
Expand All @@ -448,29 +449,37 @@ void ESPFMfGK::recurseFolderList(String foldername, int maxtiefe, int tiefe)
{
if (file.isDirectory())
{
if (!(String(file.path()).startsWith(svi)))
uint32_t flags = ~0;
// Show this folder?
if (checkFileFlags != NULL)
{
/** /
Serial.print("Pfad: ");
Serial.println(String(file.path()));
Serial.print("Name: ");
Serial.println(String(file.name()));
/**/
uint32_t flags = ~0;
if (checkFileFlags != NULL)
flags = checkFileFlags(*fsinfo[fsi].filesystem, String(file.path()) + "/", flagCheckIsPathname);
}
if (!(flags & ESPFMfGK::flagIsNotVisible))
{
if (!(String(file.path()).startsWith(svi)))
{
flags = checkFileFlags(*fsinfo[fsi].filesystem, String(file.path()) + "/", 0);
/** /
Serial.print("Pfad: ");
Serial.println(String(file.path()));
Serial.print("Name: ");
Serial.println(String(file.name()));
/**/
if (checkFileFlags != NULL)
{
flags = checkFileFlags(*fsinfo[fsi].filesystem, String(file.path()) + "/", flagCheckIsPathname);
}
if (!(flags & ESPFMfGK::flagIsNotVisible))
{
fileManager->sendContent(String(tiefe) + ":" + DeUmlautFilename(String(file.path())));
fileManager->sendContent(itemtrenner); // 0
}
}
if (!(flags & ESPFMfGK::flagIsNotVisible))
if (tiefe < maxtiefe)
{
fileManager->sendContent(String(tiefe) + ":" + DeUmlautFilename(String(file.path())));
fileManager->sendContent(itemtrenner); // 0
recurseFolderList(file.path(), maxtiefe, tiefe + 1);
}
}
if (tiefe < maxtiefe)
{
recurseFolderList(file.path(), maxtiefe, tiefe + 1);
}
}
file = root.openNextFile();
}
Expand Down Expand Up @@ -550,9 +559,16 @@ void ESPFMfGK::recurseFolder(String foldername, bool flatview, int maxtiefe, boo
{
if (file.isDirectory())
{
if (flatview)
uint32_t flags = ~0;
if (checkFileFlags != NULL)
{
recurseFolder(file.path(), flatview, maxtiefe, false, linecounter);
flags = checkFileFlags(*fsinfo[fsi].filesystem, String(file.path()) + "/", flagCheckIsPathname);
}
if (!(flags & ESPFMfGK::flagIsNotVisible)) {
if (flatview)
{
recurseFolder(file.path(), flatview, maxtiefe, false, linecounter);
}
}
}
else
Expand All @@ -569,7 +585,7 @@ void ESPFMfGK::recurseFolder(String foldername, bool flatview, int maxtiefe, boo
uint32_t flags = ~0;
if (checkFileFlags != NULL)
{
flags = checkFileFlags(*fsinfo[fsi].filesystem, file.name(), 0);
flags = checkFileFlags(*fsinfo[fsi].filesystem, file.name(), flagCheckIsFilename);
}
if (!gzipperexists)
{
Expand Down
15 changes: 14 additions & 1 deletion src/ESPFMfGK.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ das funktioniert nicht, weil der / nicht mitgeliefert wird. wie sieht das
return ESPFMfGK::flagIsNotVisible;
}
schön wäre eine Funktion wie...
if (Pathname.startsWith("/.")) ...
...um die entsprechenden Ordner ebenfalls auszublenden?!
Hi, thanks for your great work.
I have a few suggestions:
Expand All @@ -31,7 +35,12 @@ tab im editor zum echten tab umwandeln.
Changes
V2.0.7
V2.0.8
+ fixed some stuff around displaying/not displaying files+folders,
adding two flags flagCheckIsFilename and flagCheckIsPathname
+ Arduino-release V2.0.14
V2.0.7
+ Fix: another checkFileFlags() error...
+ add "SOC_SDMMC_HOST_SUPPORTED" for devices without this support
+ Arduino-release V2.0.13
Expand Down Expand Up @@ -171,6 +180,10 @@ class ESPFMfGK
// allowed to create new files
const static uint32_t flagCanCreateNew = 1 << 11;

//checking call is for a filename/pathname
const static uint32_t flagCheckIsFilename = 1 << 12;
const static uint32_t flagCheckIsPathname = 1 << 13;

ESPxWebCallbackFlags_t checkFileFlags = NULL;
ESPxWebCallbackURL_t checkURLs = NULL;
HtmlIncludesCallback_t HtmlIncludesCallback = NULL;
Expand Down

0 comments on commit 1f564b2

Please sign in to comment.