Problème avec enregistrement d'un fichier
Bonjour, j'essaie d'écrire un fichier.
J'ai un File Save Dialog avec wxWidgets, et j'envoie le path à ma fonction Écrire pour qu'il écrive le fichier.
Code:
1 2 3 4 5 6
|
wxFileDialog fdialog(this, title, defaultDir, defaultFilename, filter, wxSAVE | wxOVERWRITE_PROMPT);
if (fdialog.ShowModal() == wxID_OK) {
std::string path = fdialog.GetPath().mb_str();
m_glCanvas->SaveConfig(path);
} |
Et ensuite je fais
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
void GL_MAILLAGE::SaveConfig(const std::string& filetosavepath)
{
std::string setup = "blablabla"
Util::Ecrire(setup,filetosavepath);
}
// util.h
inline void Util::Ecrire(const std::string& text, const std::string& filepath)
{
std::ofstream myfile(filepath.c_str(), std::ios::out);
if (myfile.is_open()) {
myfile << text;
myfile.close();
}
} |
Mon problème: Ca écrit seulement le fichier lorsqu'il n'existe pas déjà. Si il existe, ca ne l'overwrite pas :(