diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-04-22 14:13:50 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-04-22 14:13:50 +0000 |
| commit | f1f37f4e215993c3e00db3240f6fb132479e6577 (patch) | |
| tree | 7f1a593cc3e2dc338a041f0756e50c79cde66a09 /src/io/sys.cpp | |
| parent | Cleanup: Remove some unused debug messages (diff) | |
| download | inkscape-f1f37f4e215993c3e00db3240f6fb132479e6577.tar.gz inkscape-f1f37f4e215993c3e00db3240f6fb132479e6577.zip | |
Simplify code and avoid conditional compilation by consistently using glib functions
Also fixes a case where the modifier passed to g_fopen() might contain a duplicated binary specifier on Windows (e.g. 'wbb') which broke functionality in MSYS2 builds (see bug 1685091)
Fixed bugs:
- https://launchpad.net/bugs/1685091
(bzr r15630)
Diffstat (limited to 'src/io/sys.cpp')
| -rw-r--r-- | src/io/sys.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/io/sys.cpp b/src/io/sys.cpp index 9d0837675..b06b550dd 100644 --- a/src/io/sys.cpp +++ b/src/io/sys.cpp @@ -68,20 +68,18 @@ void Inkscape::IO::dump_fopen_call( char const *utf8name, char const *id ) FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode ) { FILE* fp = NULL; -#ifndef WIN32 gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL ); if ( filename ) { - fp = std::fopen(filename, mode); + Glib::ustring how( mode ); + if ( how.find("b") == Glib::ustring::npos ) + { + how.append("b"); // not needed in POSIX but doesn't hurt either + } + fp = g_fopen(filename, how.c_str()); g_free(filename); filename = 0; } -#else - Glib::ustring how( mode ); - how.append("b"); - - fp = g_fopen(utf8name, how.c_str()); -#endif return fp; } @@ -89,19 +87,13 @@ FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode ) int Inkscape::IO::mkdir_utf8name( char const *utf8name ) { int retval = -1; -#ifndef WIN32 gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL ); if ( filename ) { - retval = ::mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP); + retval = g_mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP); // The mode argument is ignored on Windows. g_free(filename); filename = 0; } -#else - - // Mode should be ingnored inside of glib on the way in - retval = g_mkdir( utf8name, 0 ); -#endif return retval; } |
