mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
38 lines
827 B
C++
38 lines
827 B
C++
#include "script.h"
|
|
|
|
namespace Code {
|
|
|
|
Script::Script(Record f) :
|
|
Record(f)
|
|
{
|
|
}
|
|
|
|
bool Script::importationStatus() const {
|
|
assert(!isNull());
|
|
const char * body = read();
|
|
return (body[0] == 1);
|
|
}
|
|
|
|
void Script::toggleImportationStatus() {
|
|
assert(bodySize() >= 1);
|
|
m_body[0] = importationStatus() ? 0 : 1;
|
|
}
|
|
|
|
const char * Script::readContent() const {
|
|
const char * body = read();
|
|
return body+k_importationStatusSize;
|
|
}
|
|
|
|
Record::ErrorStatus Script::writeContent(const char * data, size_t size) {
|
|
int deltaSize = (int)size+k_importationStatusSize - (int)bodySize();
|
|
if (Kallax::sharedKallax()->moveNextRecord(start(), deltaSize)) {
|
|
*m_size += deltaSize;
|
|
strlcpy(m_body+k_importationStatusSize, data, size);
|
|
return ErrorStatus::None;
|
|
} else {
|
|
return ErrorStatus::NoEnoughSpaceAvailable;
|
|
}
|
|
}
|
|
|
|
}
|