Basic load support; read a file if it's present, but keep the file path in case you want to write later
| 563 | // Basic load support; read a file if it's present, but keep |
| 564 | // the file path in case you want to write later |
| 565 | void 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 | |
| 599 | bool ZepBuffer::Save(int64_t& size) |
| 600 | { |
nothing calls this directly
no test coverage detected