summaryrefslogtreecommitdiffstats
path: root/src/io/sys.cpp
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-12-04 09:51:15 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-12-04 09:51:15 +0000
commit2c6e21d9fd3945a73b3ed5d04a87fb16a90f7a8e (patch)
tree52a0994d8a30aaa8f867073d1cd9ce575f490de8 /src/io/sys.cpp
parentchanges_2012-11_28.patch (diff)
parentwix installer: create msi filename from version sing in src/inkscape.rc, add ... (diff)
downloadinkscape-2c6e21d9fd3945a73b3ed5d04a87fb16a90f7a8e.tar.gz
inkscape-2c6e21d9fd3945a73b3ed5d04a87fb16a90f7a8e.zip
merge from trunk (r11929)
[win32] Please update to latest devlibs for Windows (r41) (bzr r11668.1.44)
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)