diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
| commit | d2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch) | |
| tree | e2703384779e83312c456399999997fcc289c5cf /src/io | |
| parent | Merge branch 'master' into powerpencil (diff) | |
| parent | change assignment to equality (diff) | |
| download | inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip | |
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/io')
| -rw-r--r-- | src/io/makefile.in | 17 | ||||
| -rw-r--r-- | src/io/resource.cpp | 6 | ||||
| -rw-r--r-- | src/io/resource.h | 3 | ||||
| -rw-r--r-- | src/io/sys.cpp | 33 | ||||
| -rw-r--r-- | src/io/sys.h | 2 |
5 files changed, 17 insertions, 44 deletions
diff --git a/src/io/makefile.in b/src/io/makefile.in deleted file mode 100644 index 74148f11a..000000000 --- a/src/io/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) io/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) io/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/io/resource.cpp b/src/io/resource.cpp index bc6c9f7b0..3f970dfa1 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -52,6 +52,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename) case APPICONS: temp = INKSCAPE_APPICONDIR; break; case EXTENSIONS: temp = INKSCAPE_EXTENSIONDIR; break; case FILTERS: temp = INKSCAPE_FILTERDIR; break; + case FONTS: temp = INKSCAPE_FONTSDIR; break; case GRADIENTS: temp = INKSCAPE_GRADIENTSDIR; break; case ICONS: temp = INKSCAPE_PIXMAPDIR; break; case KEYS: temp = INKSCAPE_KEYSDIR; break; @@ -87,6 +88,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename) switch (type) { case EXTENSIONS: name = "extensions"; break; case FILTERS: name = "filters"; break; + case FONTS: name = "fonts"; break; case GRADIENTS: name = "gradients"; break; case ICONS: name = "icons"; break; case KEYS: name = "keys"; break; @@ -113,10 +115,10 @@ gchar *_get_path(Domain domain, Type type, char const *filename) return path; } -Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename) +Util::ptr_shared get_path(Domain domain, Type type, char const *filename) { char *path = _get_path(domain, type, filename); - Util::ptr_shared<char> result=Util::share_string(path); + Util::ptr_shared result=Util::share_string(path); g_free(path); return result; } diff --git a/src/io/resource.h b/src/io/resource.h index d12372024..6ec08a28c 100644 --- a/src/io/resource.h +++ b/src/io/resource.h @@ -33,6 +33,7 @@ namespace Resource { enum Type { APPICONS, EXTENSIONS, + FONTS, GRADIENTS, ICONS, KEYS, @@ -56,7 +57,7 @@ enum Domain { USER }; -Util::ptr_shared<char> get_path(Domain domain, Type type, +Util::ptr_shared get_path(Domain domain, Type type, char const *filename=NULL); Glib::ustring get_path_ustring(Domain domain, Type type, diff --git a/src/io/sys.cpp b/src/io/sys.cpp index b06b550dd..2ff17cdc9 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -18,7 +18,6 @@ #include <fstream> #include <glib.h> #include <glib/gstdio.h> -#include <glibmm/fileutils.h> #include <glibmm/ustring.h> #include <gtk/gtk.h> @@ -71,10 +70,20 @@ FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode ) gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL ); if ( filename ) { + // ensure we open the file in binary mode (not needed in POSIX but doesn't hurt either) Glib::ustring how( mode ); if ( how.find("b") == Glib::ustring::npos ) { - how.append("b"); // not needed in POSIX but doesn't hurt either + how.append("b"); + } + // when opening a file for writing: create parent directories if they don't exist already + if ( how.find("w") != Glib::ustring::npos ) + { + gchar *dirname = g_path_get_dirname(utf8name); + if (g_mkdir_with_parents(dirname, 0777)) { + g_warning("Could not create directory '%s'", dirname); + } + g_free(dirname); } fp = g_fopen(filename, how.c_str()); g_free(filename); @@ -97,26 +106,6 @@ int Inkscape::IO::mkdir_utf8name( char const *utf8name ) return retval; } -/* - * Wrapper around Glib::file_open_tmp(). - * Returns a handle to the temp file. - * name_used contains the actual name used (a raw filename, not necessarily utf8). - * - * Returns: - * A file handle (as from open()) to the file opened for reading and writing. - * The file is opened in binary mode on platforms where there is a difference. - * The file handle should be closed with close(). - * - * Note: - * On Windows Vista Glib::file_open_tmp fails with the current version of glibmm - * A special case is implemented for WIN32. This can be removed if the issue is fixed - * in future versions of glibmm - * */ -int Inkscape::IO::file_open_tmp(std::string& name_used, const std::string& prefix) -{ - return Glib::file_open_tmp(name_used, prefix); -} - bool Inkscape::IO::file_test( char const *utf8name, GFileTest test ) { bool exists = false; diff --git a/src/io/sys.h b/src/io/sys.h index 78d25afa3..e349fc09c 100644 --- a/src/io/sys.h +++ b/src/io/sys.h @@ -32,8 +32,6 @@ FILE *fopen_utf8name( char const *utf8name, char const *mode ); int mkdir_utf8name( char const *utf8name ); -int file_open_tmp( std::string& name_used, const std::string& prefix ); - bool file_test( char const *utf8name, GFileTest test ); bool file_directory_exists( char const *utf8name ); |
