+
+#if !GLIB_CHECK_VERSION(2, 7, 0) && !defined(G_OS_UNIX)
+gint g_chdir(const gchar *path)
+{
+#ifdef G_OS_WIN32
+ if (G_WIN32_HAVE_WIDECHAR_API()) {
+ wchar_t *wpath;
+ gint retval;
+ gint save_errno;
+
+ wpath = g_utf8_to_utf16(path, -1, NULL, NULL, NULL);
+ if (wpath == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = _wchdir(wpath);
+ save_errno = errno;
+
+ g_free(wpath);
+
+ errno = save_errno;
+ return retval;
+ } else {
+ gchar *cp_path;
+ gint retval;
+ gint save_errno;
+
+ cp_path = g_locale_from_utf8(path, -1, NULL, NULL, NULL);
+ if (cp_path == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = chdir(cp_path);
+ save_errno = errno;
+
+ g_free(cp_path);
+
+ errno = save_errno;
+ return retval;
+ }
+#else
+ return chdir(path);
+#endif
+}
+
+gint g_chmod(const gchar *path, gint mode)
+{
+#ifdef G_OS_WIN32
+ if (G_WIN32_HAVE_WIDECHAR_API()) {
+ wchar_t *wpath;
+ gint retval;
+ gint save_errno;
+
+ wpath = g_utf8_to_utf16(path, -1, NULL, NULL, NULL);
+ if (wpath == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = _wchmod(wpath, mode);
+ save_errno = errno;
+
+ g_free(wpath);
+
+ errno = save_errno;
+ return retval;
+ } else {
+ gchar *cp_path;
+ gint retval;
+ gint save_errno;
+
+ cp_path = g_locale_from_utf8(path, -1, NULL, NULL, NULL);
+ if (cp_path == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = chmod(cp_path, mode);
+ save_errno = errno;
+
+ g_free(cp_path);
+
+ errno = save_errno;
+ return retval;
+ }
+#else
+ return chmod(path, mode);
+#endif
+}
+#endif /* GLIB_CHECK_VERSION && G_OS_UNIX */