mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-16 16:12:14 +11:00
⚡ cleaner solution to initial save file generation
This commit is contained in:
parent
bf8ecccbb8
commit
21abb82c76
3 changed files with 18 additions and 6 deletions
|
|
@ -82,6 +82,7 @@ lastly type in
|
|||
```
|
||||
cmake <flags of your choice or none> ..
|
||||
make -j<threads>
|
||||
./bank
|
||||
```
|
||||
|
||||
## Certs
|
||||
|
|
|
|||
17
main.cpp
17
main.cpp
|
|
@ -29,7 +29,22 @@ void SaveSig(int s)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
{
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
std::ofstream users_save(users_location, std::ios::out | std::ios::binary);
|
||||
if (users_save.is_open())
|
||||
{
|
||||
uint8_t temp[16]{16, 0, 0, 0, 4};
|
||||
users_save.write((char *)temp, 16);
|
||||
users_save.close();
|
||||
std::cout << "User save file generated\nUsage: sudo ./bank <admin account> <saving frequency in minutes>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "File cannot be created\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (argc != 3)
|
||||
{
|
||||
std::cerr << "Usage: sudo ./bank <admin account> <saving frequency in minutes>\n";
|
||||
|
|
|
|||
|
|
@ -341,11 +341,7 @@ void Bank::Load()
|
|||
std::ifstream users_load(users_location, std::ios::out | std::ios::binary);
|
||||
if (!users_load.is_open())
|
||||
{
|
||||
std::ofstream users_save(users_location, std::ios::out | std::ios::binary);
|
||||
uint8_t temp[16]{16, 0, 0, 0, 4};
|
||||
users_save.write((char *)temp, 16);
|
||||
users_save.close();
|
||||
throw std::invalid_argument("Cannot find users.dat, file has been created\n");
|
||||
throw std::invalid_argument("Cannot find save file, to generate a new one run ./bank\n");
|
||||
}
|
||||
|
||||
uint32_t buffer_size;
|
||||
|
|
|
|||
Loading…
Reference in a new issue