MCPcopy Create free account
hub / github.com/SmingHub/Sming / mapFileOpenFlags

Function mapFileOpenFlags

Sming/Libraries/Spiffs/src/FileSystem.cpp:56–80  ·  view source on GitHub ↗

@brief map IFS OpenFlags to SPIFFS equivalents * @param flags * @param sflags OUT the SPIFFS file open flags * @retval OpenFlags if non-zero then some flags weren't recognised * @note OpenFlags were initially created the same as SPIFFS, but they * may change to support other features so map them here */

Source from the content-addressed store, hash-verified

54 * may change to support other features so map them here
55 */
56OpenFlags mapFileOpenFlags(OpenFlags flags, spiffs_flags& sflags)
57{
58 sflags = 0;
59
60 auto map = [&](OpenFlag flag, spiffs_flags sflag) {
61 if(flags[flag]) {
62 sflags |= sflag;
63 flags -= flag;
64 }
65 };
66
67 map(OpenFlag::Append, SPIFFS_O_APPEND);
68 map(OpenFlag::Truncate, SPIFFS_O_TRUNC);
69 map(OpenFlag::Create, SPIFFS_O_CREAT);
70 map(OpenFlag::Read, SPIFFS_O_RDONLY);
71 map(OpenFlag::Write, SPIFFS_O_WRONLY);
72
73 flags -= OpenFlag::NoFollow;
74
75 if(flags.any()) {
76 debug_w("Unknown OpenFlags: 0x%02X", flags.value());
77 }
78
79 return flags;
80}
81
82void fillStat(Stat& stat, const SpiffsMetaBuffer& smb)
83{

Callers 1

openMethod · 0.85

Calls 3

mapFunction · 0.85
anyMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected