2019-11-01 18:40:32 +01:00
|
|
|
#include "ProjectFile.h"
|
2019-10-23 20:54:41 +02:00
|
|
|
#include <LibCore/CFile.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2019-11-01 18:40:32 +01:00
|
|
|
const GTextDocument& ProjectFile::document() const
|
2019-10-27 19:39:15 +01:00
|
|
|
{
|
|
|
|
|
if (!m_document) {
|
|
|
|
|
m_document = GTextDocument::create(nullptr);
|
2019-10-23 20:54:41 +02:00
|
|
|
auto file = CFile::construct(m_name);
|
2019-11-01 19:22:42 +01:00
|
|
|
if (!file->open(CFile::ReadOnly)) {
|
|
|
|
|
ASSERT_NOT_REACHED();
|
2019-10-23 20:54:41 +02:00
|
|
|
}
|
2019-11-01 19:22:42 +01:00
|
|
|
m_document->set_text(file->read_all());
|
2019-10-23 20:54:41 +02:00
|
|
|
}
|
2019-11-01 19:22:42 +01:00
|
|
|
return *m_document;
|
2019-10-23 20:54:41 +02:00
|
|
|
}
|