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