Sorry, forgot to check in a file change for last patch :-(
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
* Copyright (c) 2010 Sasha Vasko <sasha@aftercode.net>
|
||||
* Copyright (c) 2010 Oliver Duis <www.oliverduis.de>
|
||||
*
|
||||
* RawTherapee is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,6 +21,8 @@
|
||||
|
||||
#include <safegtk.h>
|
||||
#include <guiutils.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> safe_create_from_file(const std::string& filename)
|
||||
{
|
||||
@@ -45,7 +48,7 @@ Cairo::RefPtr<Cairo::ImageSurface> safe_create_from_png(const std::string& filen
|
||||
{
|
||||
Cairo::RefPtr<Cairo::ImageSurface> res;
|
||||
|
||||
if (!Glib::file_test (filename, Glib::FILE_TEST_EXISTS)) {
|
||||
if (!safe_file_test (filename, Glib::FILE_TEST_EXISTS)) {
|
||||
printf ("ERROR: File \"%s\" not found.\n", filename.c_str());
|
||||
} else {
|
||||
try {
|
||||
@@ -159,6 +162,26 @@ std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str)
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string safe_filename_from_utf8 (const Glib::ustring& utf8_str)
|
||||
{
|
||||
std::string str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
str = Glib::filename_from_utf8 (utf8_str);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
//str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
str = Glib::filename_from_utf8 (utf8_str, error);
|
||||
/*if (error.get())
|
||||
{str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?", error);}*/
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return str;
|
||||
}
|
||||
|
||||
bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
|
||||
{
|
||||
@@ -208,3 +231,28 @@ bool safe_spawn_command_line_sync (const Glib::ustring& cmd_utf8)
|
||||
}
|
||||
return (exitStatus==0);
|
||||
}
|
||||
|
||||
FILE * safe_g_fopen(const Glib::ustring& src,const gchar *mode)
|
||||
{
|
||||
return g_fopen(safe_filename_from_utf8(src).c_str(),mode);
|
||||
}
|
||||
|
||||
bool safe_file_test (const Glib::ustring& filename, Glib::FileTest test)
|
||||
{
|
||||
return Glib::file_test (safe_filename_from_utf8(filename), test);
|
||||
}
|
||||
|
||||
int safe_g_remove(const Glib::ustring& filename)
|
||||
{
|
||||
return ::g_remove(safe_filename_from_utf8(filename).c_str());
|
||||
}
|
||||
|
||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename)
|
||||
{
|
||||
return ::g_rename(safe_filename_from_utf8(oldFilename).c_str(), safe_filename_from_utf8(newFilename).c_str());
|
||||
}
|
||||
|
||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode)
|
||||
{
|
||||
return ::g_mkdir_with_parents(safe_filename_from_utf8(dirName).c_str(), mode);
|
||||
}
|
@@ -28,7 +28,11 @@ bool safe_spawn_command_line_sync (const Glib::ustring& cmd_utf8);
|
||||
|
||||
Glib::ustring safe_locale_to_utf8 (const std::string& src); // from rtengine
|
||||
std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str);
|
||||
std::string safe_filename_from_utf8 (const Glib::ustring& utf8_str);
|
||||
|
||||
|
||||
|
||||
FILE * safe_g_fopen(const Glib::ustring& src,const gchar *mode);
|
||||
bool safe_file_test (const Glib::ustring& filename, Glib::FileTest test);
|
||||
int safe_g_remove(const Glib::ustring& filename);
|
||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename);
|
||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
|
||||
#endif
|
Reference in New Issue
Block a user