Author: Carlos Lopez <genet...@gmail.com> Date: Sun May 1 11:43:48 2011 +0200
When testing whether the destination path is writable or exists, don't create a file to test that. Use access() to determine the accessibility of the path and improve error message. --- synfig-studio/src/gui/render.cpp | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/synfig-studio/src/gui/render.cpp b/synfig-studio/src/gui/render.cpp index a94a94c..01485d4 100644 --- a/synfig-studio/src/gui/render.cpp +++ b/synfig-studio/src/gui/render.cpp @@ -41,7 +41,8 @@ #include "general.h" -#include <fstream> +#include <ETL/stringf> +#include <errno.h> #endif @@ -308,12 +309,10 @@ RenderSettings::on_render_pressed() canvas_interface_->get_ui_interface()->error(_("Unable to create target for ")+filename); return; } - // This is the only way I've found to avoid send a non writable - // filename path to the renderer. - fstream filetest (filename.c_str(), fstream::out); - if (filetest.fail()) + // Test whether the output file is writable (path exists or has write permit) + if (access(dirname(filename).c_str(),W_OK) == -1) { - canvas_interface_->get_ui_interface()->error(_("Unable to create file for ")+filename); + canvas_interface_->get_ui_interface()->error(_("Unable to create file for ")+filename+": "+strerror( errno )); return; } ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl