🧑💻 Add SD Card 'hide' method for dev usage (#22425)
This commit is contained in:
committed by
GitHub
parent
7c0b465754
commit
08d9cbb930
@@ -1668,6 +1668,28 @@ bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) {
|
|||||||
return file.open(dirFile, path, O_WRITE) ? file.remove() : false;
|
return file.open(dirFile, path, O_WRITE) ? file.remove() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SdBaseFile::hide(const bool hidden) {
|
||||||
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
// must be an open file or subdirectory
|
||||||
|
if (!(isFile() || isSubDir())) return false;
|
||||||
|
// sync() and cache directory entry
|
||||||
|
sync();
|
||||||
|
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
|
if (!d) return false;
|
||||||
|
uint8_t a = d->attributes;
|
||||||
|
if (hidden)
|
||||||
|
a |= DIR_ATT_HIDDEN;
|
||||||
|
else
|
||||||
|
a &= ~DIR_ATT_HIDDEN;
|
||||||
|
|
||||||
|
if (a != d->attributes) {
|
||||||
|
d->attributes = a;
|
||||||
|
return vol_->cacheFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename a file or subdirectory.
|
* Rename a file or subdirectory.
|
||||||
*
|
*
|
||||||
|
@@ -310,6 +310,11 @@ class SdBaseFile {
|
|||||||
bool rmdir();
|
bool rmdir();
|
||||||
bool rmRfStar();
|
bool rmRfStar();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set or clear DIR_ATT_HIDDEN attribute for directory entry
|
||||||
|
*/
|
||||||
|
bool hide(const bool hidden);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the files position to current position + \a pos. See seekSet().
|
* Set the files position to current position + \a pos. See seekSet().
|
||||||
* \param[in] offset The new position in bytes from the current position.
|
* \param[in] offset The new position in bytes from the current position.
|
||||||
|
Reference in New Issue
Block a user