Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 14 Oct 2018 19:19:46 UTC Commit: 884f90dce152f192f766f1d7990c82d7b9219a93 https://github.com/geany/geany-plugins/commit/884f90dce152f192f766f1d7990c82...
Log Message: ----------- Use locale encoding for file operations instead of utf8
Modified Paths: -------------- projectorganizer/src/prjorg-utils.c
Modified: projectorganizer/src/prjorg-utils.c 43 lines changed, 24 insertions(+), 19 deletions(-) =================================================================== @@ -124,26 +124,36 @@ void close_file(gchar *utf8_name)
gboolean create_file(gchar *utf8_name) { - int fd; - GError *err; - - fd = g_open(utf8_name, O_CREAT|O_EXCL, 0660); // rw-rw---- - if (fd == -1) // not created? - return FALSE; - g_close(fd, &err); - return TRUE; + gchar *name = utils_get_locale_from_utf8(utf8_name); + gint fd = g_open(name, O_CREAT|O_EXCL, 0660); // rw-rw---- + gboolean success = FALSE; + + if (fd != -1) + { + GError *err; + success = TRUE; + g_close(fd, &err); + } + g_free(name); + return success; }
gboolean create_dir(char *utf8_name) { - return g_mkdir_with_parents(utf8_name, 0770) == 0; // rwxrwx--- + gchar *name = utils_get_locale_from_utf8(utf8_name); + gboolean ret = g_mkdir_with_parents(name, 0770) == 0; // rwxrwx--- + g_free(name); + return ret; }
gboolean remove_file_or_dir(char *utf8_name) { - return g_remove(utf8_name) == 0; + gchar *name = utils_get_locale_from_utf8(utf8_name); + gboolean ret = g_remove(utf8_name) == 0; + g_free(name); + return ret; }
@@ -157,19 +167,14 @@ static gboolean document_rename(GeanyDocument *document, gchar *utf8_name)
gboolean rename_file_or_dir(gchar *utf8_oldname, gchar *utf8_newname) { - GeanyDocument *doc; - gchar *oldname; - gchar *newname; - int res; - - doc = document_find_by_filename(utf8_oldname); + GeanyDocument *doc = document_find_by_filename(utf8_oldname); if (doc) return document_rename(doc, utf8_newname); else { - oldname = utils_get_locale_from_utf8(utf8_oldname); - newname = utils_get_locale_from_utf8(utf8_newname); - res = g_rename(oldname, newname); + gchar *oldname = utils_get_locale_from_utf8(utf8_oldname); + gchar *newname = utils_get_locale_from_utf8(utf8_newname); + gint res = g_rename(oldname, newname); g_free(oldname); g_free(newname); return res == 0;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org