finish debug dump

This commit is contained in:
Kyle Isom 2023-10-13 04:06:06 +00:00
parent 7cec414e3d
commit 5a9c09b217
2 changed files with 12 additions and 10 deletions

View File

@ -23,7 +23,6 @@
#include <filesystem> #include <filesystem>
#include <iostream>
#include <iterator> #include <iterator>
#include <optional> #include <optional>
#include <random> #include <random>
@ -68,7 +67,6 @@ Buffer::Buffer(std::filesystem::path fPath)
this->cursor = Cursor(); this->cursor = Cursor();
this->file = OptFile(fPath.string()); this->file = OptFile(fPath.string());
if (this->Exists()) { if (this->Exists()) {
std::cout << "file exists, refreshing\n";
/// \todo Should I signal an error here, or is it /// \todo Should I signal an error here, or is it
/// okay for this to be a best-effort thing? /// okay for this to be a best-effort thing?
this->status = this->Refresh(); this->status = this->Refresh();
@ -144,14 +142,12 @@ Buffer::Refresh()
/// We can't actually refresh a virtual buffer. Unlike flush, /// We can't actually refresh a virtual buffer. Unlike flush,
/// it doesn't make sense to Refresh from an alternate file. /// it doesn't make sense to Refresh from an alternate file.
if (this->IsVirtual()) { if (this->IsVirtual()) {
std::cerr << "[!] virtual file, bailing\n";
return Buffer::FileStatus::FileStatusVirtual; return Buffer::FileStatus::FileStatusVirtual;
} }
auto realFile = this->file.value(); auto realFile = this->file.value();
auto handle = realFile.Refresh(); auto handle = realFile.Refresh();
if (!handle) { if (!handle) {
std::cerr << "[!] file doesn't exist\n";
return FileStatus::FileStatusNonExistent; return FileStatus::FileStatusNonExistent;
} }
@ -164,7 +160,6 @@ Buffer::Refresh()
/// contents first isn't the right move. Maybe mark the /// contents first isn't the right move. Maybe mark the
/// file as ReadOnly? /// file as ReadOnly?
if (!realHandle->good()) { if (!realHandle->good()) {
std::cerr << "[!] handle isn't good";
realHandle->close(); realHandle->close();
delete realHandle; delete realHandle;
return FileStatus::FileStatusIOFailed; return FileStatus::FileStatusIOFailed;
@ -306,10 +301,18 @@ Buffer::PrintBufferStatus(std::ostream &os)
if (realFile.IsReadOnly()) { if (realFile.IsReadOnly()) {
os << "@"; os << "@";
} else { } else {
os << " "; os << "-";
} }
os << ":" << this->Size() << " if (this->IsDirty()) {
os << "!";
} else {
os << "-";
}
os << ":" << this->Size() << "B";
} }
return os;
os << "\n";
return;
} }

View File

@ -71,8 +71,7 @@ main(int argc, char *argv[])
} }
*/ */
std::cout << "\t[+] loaded buffer " << buffer.Name() buffer.PrintBufferStatus(std::cout);
<< " of " << buffer.Size() << " bytes.\n";
buffer.Close(); buffer.Close();
} }