summaryrefslogtreecommitdiffstats
path: root/src/io/sys.cpp
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-11-30 02:05:35 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-11-30 02:05:35 +0000
commit91276e1763b33970684e93ef6a20cd2134a5be57 (patch)
tree253044f18ee0506fbb40902fbf47c97d48697c66 /src/io/sys.cpp
parentFix for #955141: Converting clipped object to pattern produces rasterised pat... (diff)
downloadinkscape-91276e1763b33970684e93ef6a20cd2134a5be57.tar.gz
inkscape-91276e1763b33970684e93ef6a20cd2134a5be57.zip
Fix for 430301 : core dump exporting to non existing folder
(bzr r11915)
Diffstat (limited to 'src/io/sys.cpp')
-rw-r--r--src/io/sys.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/io/sys.cpp b/src/io/sys.cpp
index 5f19ee5db..26c1993a7 100644
--- a/src/io/sys.cpp
+++ b/src/io/sys.cpp
@@ -239,6 +239,40 @@ bool Inkscape::IO::file_is_writable( char const *utf8name)
return success;
}
+/**Checks if directory of file exists, useful
+ * because inkscape doesn't create directories.*/
+bool Inkscape::IO::file_directory_exists( char const *utf8name ){
+ bool exists = true;
+
+ if ( utf8name) {
+ gchar *filename = NULL;
+ if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) {
+ /* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
+ If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
+ use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
+ to beginning of this function. */
+ filename = g_strdup(utf8name);
+ // Looks like g_get_home_dir isn't safe.
+ //g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
+ } else {
+ filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL );
+ }
+ if ( filename ) {
+ gchar *dirname = g_path_get_dirname(filename);
+ exists = Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS);
+ g_free(filename);
+ g_free(dirname);
+ filename = NULL;
+ dirname = NULL;
+ } else {
+ g_warning( "Unable to convert filename in IO:file_test" );
+ }
+ }
+
+ return exists;
+
+}
+
/** Wrapper around g_dir_open, but taking a utf8name as first argument. */
GDir *
Inkscape::IO::dir_open(gchar const *const utf8name, guint const flags, GError **const error)