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

Method GetFileBuffer

external/zep/src/editor.cpp:299–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297 }
298
299 ZepBuffer* ZepEditor::GetFileBuffer(const fs::path& filePath, uint32_t fileFlags, bool create) {
300 auto path = GetFileSystem().Exists(filePath) ? GetFileSystem().Canonical(filePath) : filePath;
301 if (!path.empty()) {
302 for (auto& pBuffer : m_buffers) {
303 if (!pBuffer->GetFilePath().empty()) {
304 if (GetFileSystem().Equivalent(pBuffer->GetFilePath(), path)) {
305 return pBuffer.get();
306 }
307 }
308 }
309 }
310
311 if (!create) {
312 return nullptr;
313 }
314
315 // Create buffer, try to load even if not present, the buffer represents the save path (it just isn't saved yet)
316 auto pBuffer = CreateNewBuffer(filePath);
317 pBuffer->SetFileFlags(fileFlags);
318
319 return pBuffer;
320 }
321
322 ZepWindow* ZepEditor::AddTree() {
323 auto pTree = GetEmptyBuffer("Tree.tree", FileFlags::Locked | FileFlags::ReadOnly);

Callers 3

OpenSelectionMethod · 0.80
GetCommandMethod · 0.80
HandleExCommandMethod · 0.80

Calls 7

ExistsMethod · 0.80
CanonicalMethod · 0.80
GetFilePathMethod · 0.80
EquivalentMethod · 0.80
SetFileFlagsMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected