I now need to have these chunks save to a file when they are no longer visible to the user.
I was thinking of saving them as for example save/1-1-1.txt, save/1-1-2.txt, etc.
Then I thought it would be easier to just seperate the x, y, and z locations of the chunks
using directorys like so: save/1/0/0.txt, save/2/0/0.txt, save/3/0/0.txt.
However I have now come to realise fstream does not create folders.
Do I need to use the current approach and create folders when saving?
Do I need to save the origonal way with some char seperating the vars? (seems it may get complicated with big numbers ex: save/101-3-21.txt)
What approach should I take?
keep in mind this has to be compilable on Windows, Mac, and Linux.
Thanks
Current code that doesn't work because folders dont exist:
#include "Global.h"
file::file()
{
////Clear Variables
name.str(std::string());
}
void file::write(int x,int y,int z)
{
name.str(std::string());
name << "save/" << x << "/" << y << "/" << z << ".txt";
//name << x << "-" << y << "-" << z << ".txt";
temp = name.str();
fileStream.open(temp.c_str());
if (fileStream.is_open())
{
//Just something to write
for (int i=100;i>=0;i-=2)
{
fileStream << i << endl;
}
}
else
{
//printf("/!\\ Cannot open \n");
cout << "/!\\ Cannot open " << temp.c_str() << "\n";
fileStream.close();
}
return;
}