2026-01-07 03:58:37 -05:00
|
|
|
#pragma once
|
2026-01-07 20:07:23 +10:00
|
|
|
|
2026-01-21 05:06:07 -08:00
|
|
|
#include <WString.h>
|
|
|
|
|
|
2026-01-07 03:58:37 -05:00
|
|
|
#include <string>
|
2026-03-02 04:28:57 -05:00
|
|
|
#include <vector>
|
2026-01-07 03:58:37 -05:00
|
|
|
|
|
|
|
|
namespace StringUtils {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sanitize a string for use as a filename.
|
|
|
|
|
* Replaces invalid characters with underscores, trims spaces/dots,
|
|
|
|
|
* and limits length to maxLength characters.
|
|
|
|
|
*/
|
|
|
|
|
std::string sanitizeFilename(const std::string& name, size_t maxLength = 100);
|
|
|
|
|
|
2026-01-07 20:07:23 +10:00
|
|
|
/**
|
|
|
|
|
* Check if the given filename ends with the specified extension (case-insensitive).
|
|
|
|
|
*/
|
|
|
|
|
bool checkFileExtension(const std::string& fileName, const char* extension);
|
2026-01-21 05:06:07 -08:00
|
|
|
bool checkFileExtension(const String& fileName, const char* extension);
|
2026-01-07 20:07:23 +10:00
|
|
|
|
2026-03-02 04:28:57 -05:00
|
|
|
/**
|
|
|
|
|
* Sort a file/directory list with directories first, using case-insensitive natural sort.
|
|
|
|
|
* Directory entries are identified by a trailing '/'.
|
|
|
|
|
*/
|
|
|
|
|
void sortFileList(std::vector<std::string>& entries);
|
|
|
|
|
|
2026-01-07 03:58:37 -05:00
|
|
|
} // namespace StringUtils
|