| 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); |
no test coverage detected