mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Revert "[storage] New attempt to save cursor position"
This reverts commit c826e556a1.
This commit is contained in:
@@ -14,11 +14,6 @@ namespace Ion {
|
||||
|
||||
class StorageDelegate;
|
||||
|
||||
/**
|
||||
* Purpose the two storage classes :
|
||||
* - The first (InternalStorage) is the base, it allows to create, modify and delete records
|
||||
* - The second (Storage) is the visible part. It handle the trash system and the metadata records
|
||||
*/
|
||||
class InternalStorage {
|
||||
public:
|
||||
typedef uint16_t record_size_t;
|
||||
@@ -119,7 +114,6 @@ public:
|
||||
// Used by Python OS module
|
||||
int numberOfRecords();
|
||||
Record recordAtIndex(int index);
|
||||
|
||||
protected:
|
||||
InternalStorage();
|
||||
/* Getters on address in buffer */
|
||||
|
||||
@@ -37,16 +37,9 @@ public:
|
||||
Record recordAtIndex(int index);
|
||||
void destroyRecord(Record record);
|
||||
|
||||
// Trash
|
||||
void reinsertTrash(const char * extension);
|
||||
void emptyTrash();
|
||||
|
||||
// Metadata
|
||||
typedef Record::Data Metadata;
|
||||
Metadata metadataForRecord(Record record);
|
||||
Record::ErrorStatus setMetadataForRecord(Record record, Metadata metadata);
|
||||
void removeMetadataForRecord(Record record);
|
||||
|
||||
private:
|
||||
Storage():
|
||||
InternalStorage() {}
|
||||
|
||||
@@ -26,10 +26,6 @@ int CountOccurrences(const char * s, CodePoint c);
|
||||
* null terminating char otherwise. */
|
||||
const char * CodePointSearch(const char * s, CodePoint c, const char * stoppingPosition = nullptr);
|
||||
|
||||
/* Returns the last occurrence of a code point in a string, the position of the
|
||||
* null terminating char otherwise. */
|
||||
const char * LastCodePoint(const char * s, CodePoint c, const char * stoppingPosition = nullptr);
|
||||
|
||||
// Returns true if the text had the code point
|
||||
bool HasCodePoint(const char * s, CodePoint c, const char * stoppingPosition = nullptr);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ InternalStorage::Record::Record(const char * fullName) {
|
||||
m_fullNameCRC32 = 0;
|
||||
return;
|
||||
}
|
||||
const char * dotChar = UTF8Helper::LastCodePoint(fullName, k_dotChar);
|
||||
const char * dotChar = UTF8Helper::CodePointSearch(fullName, k_dotChar);
|
||||
// If no extension, return empty record
|
||||
if (*dotChar == 0 || *(dotChar+1) == 0) {
|
||||
m_fullNameCRC32 = 0;
|
||||
|
||||
@@ -61,10 +61,6 @@ bool Storage::hasRecord(Record r) {
|
||||
|
||||
void Storage::destroyRecord(Record record) {
|
||||
emptyTrash();
|
||||
const Record metadataRecord = recordBaseNamedWithExtension(record.fullName(), "sys");
|
||||
if (!metadataRecord.isNull()) {
|
||||
InternalStorage::destroyRecord(metadataRecord);
|
||||
}
|
||||
m_trashRecord = record;
|
||||
}
|
||||
|
||||
@@ -181,21 +177,4 @@ void Storage::emptyTrash() {
|
||||
}
|
||||
}
|
||||
|
||||
Storage::Metadata Storage::metadataForRecord(Record record) {
|
||||
return recordBaseNamedWithExtension(record.fullName(), "sys").value();
|
||||
}
|
||||
|
||||
Storage::Record::ErrorStatus Storage::setMetadataForRecord(Record record, Metadata data) {
|
||||
Record metadataRecord = Record(record.fullName(), "sys");
|
||||
if (!hasRecord(metadataRecord)) {
|
||||
return createRecordWithExtension(record.fullName(), "sys", data.buffer, data.size);
|
||||
} else {
|
||||
return metadataRecord.setValue(data);
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::removeMetadataForRecord(Record record) {
|
||||
recordBaseNamedWithExtension(record.fullName(), "sys").destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,34 +54,6 @@ const char * CodePointSearch(const char * s, CodePoint c, const char * stoppingP
|
||||
return currentPointer;
|
||||
}
|
||||
|
||||
const char * LastCodePoint(const char * s, CodePoint c, const char * stoppingPosition) {
|
||||
if (UTF8Decoder::CharSizeOfCodePoint(c) == 1) {
|
||||
const char * result = nullptr;
|
||||
const char * position = s;
|
||||
while (*position != 0 && (stoppingPosition == nullptr || position != stoppingPosition)) {
|
||||
if (*position == c) {
|
||||
result = position;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
return result ? result : position;
|
||||
}
|
||||
UTF8Decoder decoder(s);
|
||||
const char * currentPointer = s;
|
||||
const char * result = nullptr;
|
||||
CodePoint codePoint = decoder.nextCodePoint();
|
||||
const char * nextPointer = decoder.stringPosition();
|
||||
while (codePoint != UCodePointNull && (stoppingPosition == nullptr || currentPointer < stoppingPosition)) {
|
||||
if (c == codePoint) {
|
||||
result = currentPointer;
|
||||
}
|
||||
currentPointer = nextPointer;
|
||||
codePoint = decoder.nextCodePoint();
|
||||
nextPointer = decoder.stringPosition();
|
||||
}
|
||||
return result ? result : currentPointer;
|
||||
}
|
||||
|
||||
bool HasCodePoint(const char * s, CodePoint c, const char * stoppingPosition) {
|
||||
assert(c != 0);
|
||||
const char * resultPosition = CodePointSearch(s, c, stoppingPosition);
|
||||
|
||||
Reference in New Issue
Block a user