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

Method GetFileBuffer

src/editor.cpp:302–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302ZepBuffer* ZepEditor::GetFileBuffer(const ZepPath& filePath, uint32_t fileFlags, bool create)
303{
304 auto path = GetFileSystem().Exists(filePath) ? GetFileSystem().Canonical(filePath) : filePath;
305 if (!path.empty())
306 {
307 for (auto& pBuffer : m_buffers)
308 {
309 if (!pBuffer->GetFilePath().empty())
310 {
311 if (GetFileSystem().Equivalent(pBuffer->GetFilePath(), path))
312 {
313 return pBuffer.get();
314 }
315 }
316 }
317 }
318
319 if (!create)
320 {
321 return nullptr;
322 }
323
324 // Create buffer, try to load even if not present, the buffer represents the save path (it just isn't saved yet)
325 auto pBuffer = CreateNewBuffer(filePath);
326 pBuffer->SetFileFlags(fileFlags);
327
328 return pBuffer;
329}
330
331ZepWindow* ZepEditor::AddTree()
332{

Callers 4

OpenSelectionMethod · 0.80
GetCommandMethod · 0.80
HandleExCommandMethod · 0.80
mainFunction · 0.80

Calls 7

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

Tested by

no test coverage detected