## Summary I love the new screenshot feature but I can tell that soon I'm gonna have a folder full of screenshots and not know what's what. It would be great if the folder could self organize. When a screenshot is taken while reading, the filename would now include the book title, chapter (EPUB), page number, and progress percentage. Example: My-Great-Book_ch3_p5_42pct_12345.bmp * **What is the goal of this PR?** (e.g., Implements the new feature for file uploading.) * **What changes are included?** ## Additional Context * Non-reader screens keep the existing screenshot-<millis>.bmp naming. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< YES >**_ I reviewed all the changes but I don't have any experience with this project so this is my best guess
67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
#pragma once
|
|
#include <WString.h>
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace FsHelpers {
|
|
|
|
std::string normalisePath(const std::string& path);
|
|
|
|
/**
|
|
* Check if the given filename ends with the specified extension (case-insensitive).
|
|
*/
|
|
bool checkFileExtension(std::string_view fileName, const char* extension);
|
|
inline bool checkFileExtension(const String& fileName, const char* extension) {
|
|
return checkFileExtension(std::string_view{fileName.c_str(), fileName.length()}, extension);
|
|
}
|
|
|
|
// Check for either .jpg or .jpeg extension (case-insensitive)
|
|
bool hasJpgExtension(std::string_view fileName);
|
|
inline bool hasJpgExtension(const String& fileName) {
|
|
return hasJpgExtension(std::string_view{fileName.c_str(), fileName.length()});
|
|
}
|
|
|
|
// Check for .png extension (case-insensitive)
|
|
bool hasPngExtension(std::string_view fileName);
|
|
inline bool hasPngExtension(const String& fileName) {
|
|
return hasPngExtension(std::string_view{fileName.c_str(), fileName.length()});
|
|
}
|
|
|
|
// Check for .bmp extension (case-insensitive)
|
|
bool hasBmpExtension(std::string_view fileName);
|
|
|
|
// Check for .gif extension (case-insensitive)
|
|
bool hasGifExtension(std::string_view fileName);
|
|
inline bool hasGifExtension(const String& fileName) {
|
|
return hasGifExtension(std::string_view{fileName.c_str(), fileName.length()});
|
|
}
|
|
|
|
// Check for .epub extension (case-insensitive)
|
|
bool hasEpubExtension(std::string_view fileName);
|
|
inline bool hasEpubExtension(const String& fileName) {
|
|
return hasEpubExtension(std::string_view{fileName.c_str(), fileName.length()});
|
|
}
|
|
|
|
// Check for either .xtc or .xtch extension (case-insensitive)
|
|
bool hasXtcExtension(std::string_view fileName);
|
|
|
|
// Check for .txt extension (case-insensitive)
|
|
bool hasTxtExtension(std::string_view fileName);
|
|
inline bool hasTxtExtension(const String& fileName) {
|
|
return hasTxtExtension(std::string_view{fileName.c_str(), fileName.length()});
|
|
}
|
|
|
|
// Check for .md extension (case-insensitive)
|
|
bool hasMarkdownExtension(std::string_view fileName);
|
|
|
|
std::string extractFolderPath(const std::string& filePath);
|
|
|
|
/**
|
|
* Sanitize a filename/path component for FAT32 in a caller-provided buffer.
|
|
* Replaces invalid path characters, spaces, and control characters with '-'.
|
|
*/
|
|
void sanitizePathComponentForFat32(const char* input, char* output, size_t maxLen);
|
|
|
|
} // namespace FsHelpers
|