MCPcopy Create free account
hub / github.com/Rezonality/zep / Load

Method Load

src/buffer.cpp:565–597  ·  view source on GitHub ↗

Basic load support; read a file if it's present, but keep the file path in case you want to write later

Source from the content-addressed store, hash-verified

563// Basic load support; read a file if it's present, but keep
564// the file path in case you want to write later
565void ZepBuffer::Load(const ZepPath& path)
566{
567 // Set the name from the path
568 if (path.has_filename())
569 {
570 m_strName = path.filename().string();
571 }
572 else
573 {
574 m_strName = m_filePath.string();
575 }
576
577 // Must set the syntax before the first buffer change messages
578 // TODO: I believe that some of this buffer config should move to Editor.cpp
579 GetEditor().SetBufferSyntax(*this);
580
581 if (GetEditor().GetFileSystem().Exists(path))
582 {
583 m_filePath = GetEditor().GetFileSystem().Canonical(path);
584 auto read = GetEditor().GetFileSystem().Read(path);
585
586 // Always set text, to ensure we prepare the buffer with 0 terminator,
587 // even if string is empty
588 SetText(read, true);
589 }
590 else
591 {
592 // Can't canonicalize a non-existent path.
593 // But we may have a path we haven't save to yet!
594 Clear();
595 m_filePath = path;
596 }
597}
598
599bool ZepBuffer::Save(int64_t& size)
600{

Callers

nothing calls this directly

Calls 7

has_filenameMethod · 0.80
filenameMethod · 0.80
SetBufferSyntaxMethod · 0.80
CanonicalMethod · 0.80
ReadMethod · 0.80
stringMethod · 0.45
ExistsMethod · 0.45

Tested by

no test coverage detected