MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / Load

Method Load

external/zep/src/buffer.cpp:588–613  ·  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

586 // Basic load support; read a file if it's present, but keep
587 // the file path in case you want to write later
588 void ZepBuffer::Load(const fs::path& path) {
589 // Set the name from the path
590 if (path.has_filename()) {
591 m_strName = path.filename().string();
592 } else {
593 m_strName = m_filePath.string();
594 }
595
596 // Must set the syntax before the first buffer change messages
597 // TODO: I believe that some of this buffer config should move to Editor.cpp
598 GetEditor().SetBufferSyntax(*this);
599
600 if (GetEditor().GetFileSystem().Exists(path)) {
601 m_filePath = GetEditor().GetFileSystem().Canonical(path);
602 auto read = GetEditor().GetFileSystem().Read(path);
603
604 // Always set text, to ensure we prepare the buffer with 0 terminator,
605 // even if string is empty
606 SetText(read, true);
607 } else {
608 // Can't canonicalize a non-existent path.
609 // But we may have a path we haven't save to yet!
610 Clear();
611 m_filePath = path;
612 }
613 }
614
615 bool ZepBuffer::Save(int64_t& size) {
616 if (ZTestFlags(m_fileFlags, FileFlags::Locked)) {

Callers

nothing calls this directly

Calls 5

stringMethod · 0.80
SetBufferSyntaxMethod · 0.80
ExistsMethod · 0.80
CanonicalMethod · 0.80
ReadMethod · 0.80

Tested by

no test coverage detected