mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion] Method to destroy all records with given extension in Storage
This commit is contained in:
@@ -82,6 +82,8 @@ public:
|
||||
Record recordBaseNamedWithExtension(const char * baseName, const char * extension);
|
||||
Record recordBaseNamedWithExtensions(const char * baseName, const char * extension[], size_t numberOfExtensions);
|
||||
|
||||
// Record destruction
|
||||
void destroyRecordsWithExtension(const char * extension);
|
||||
private:
|
||||
constexpr static uint32_t Magic = 0xEE0BDDBA;
|
||||
constexpr static size_t k_maxRecordSize = (1 << sizeof(record_size_t)*8);
|
||||
|
||||
@@ -183,6 +183,20 @@ Storage::Record Storage::recordBaseNamedWithExtensions(const char * baseName, co
|
||||
return Record();
|
||||
}
|
||||
|
||||
void Storage::destroyRecordsWithExtension(const char * extension) {
|
||||
size_t extensionLength = strlen(extension);
|
||||
char * currentRecordStart = (char *)m_buffer;
|
||||
while (currentRecordStart != nullptr && sizeOfRecordStarting(currentRecordStart) != 0) {
|
||||
const char * currentFullName = fullNameOfRecordStarting(currentRecordStart);
|
||||
if (FullNameHasExtension(currentFullName, extension, extensionLength)) {
|
||||
Record currentRecord(currentFullName);
|
||||
currentRecord.destroy();
|
||||
continue;
|
||||
}
|
||||
currentRecordStart = *(RecordIterator(currentRecordStart).operator++());
|
||||
}
|
||||
}
|
||||
|
||||
const char * Storage::fullNameOfRecord(const Record record) {
|
||||
for (char * p : *this) {
|
||||
Record currentRecord(fullNameOfRecordStarting(p));
|
||||
|
||||
Reference in New Issue
Block a user