diff options
Autocommit at 30.05.2022 @ 18:32
2 files changed, 15 insertions, 0 deletions
| -rw-r--r-- | src/UserInterface/UserInterface.cpp | 13 | ||||
| -rw-r--r-- | src/UserInterface/UserInterface.h | 2 |
diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp index 3fd51a7..3272f0d 100644 --- a/src/UserInterface/UserInterface.cpp +++ b/src/UserInterface/UserInterface.cpp @@ -7,6 +7,7 @@ /* Private (static) */ Table* UserInterface::table = nullptr; +String fileName = String(); void UserInterface::com_open(const char* params) { if (table != nullptr) { @@ -16,16 +17,28 @@ void UserInterface::com_open(const char* params) { try { table = new Table(params); + fileName = params; } catch (std::logic_error err) { printLine(err.what()); } } void UserInterface::com_close(const char* params) { + if (table == nullptr) { + printLine("No file has been opened!"); + return; + } + + delete table; } void UserInterface::com_save(const char* params) { + com_saveas(fileName.get_cstr()); } void UserInterface::com_saveas(const char* params) { + if (table == nullptr) { + printLine("No file has been opened!"); + return; + } } void UserInterface::com_help(const char* params) { diff --git a/src/UserInterface/UserInterface.h b/src/UserInterface/UserInterface.h index 42d323c..2a83580 100644 --- a/src/UserInterface/UserInterface.h +++ b/src/UserInterface/UserInterface.h @@ -2,12 +2,14 @@ #define HEADER_USERINTERFACE #include "../Generic/ConsoleInterface/Menu.h" +#include "../Generic/String/String.h" #include "../Models/Table.h" class UserInterface { Menu menu; static Table* table; + static String fileName; static void com_open(const char* params); static void com_close(const char* params); |
