/**
* g_access:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: as in access()
*
* A wrapper for the POSIX access() function. This function is used to
/**
* g_chmod:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: as in chmod()
*
* A wrapper for the POSIX chmod() function. The chmod() function is
/**
* g_open:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @flags: as in open()
* @mode: as in open()
*
/**
* g_creat:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: as in creat()
*
* A wrapper for the POSIX creat() function. The creat() function is
/**
* g_rename:
- * @oldfilename: a pathname in the GLib file name encoding
+ * @oldfilename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @newfilename: a pathname in the GLib file name encoding
*
* A wrapper for the POSIX rename() function. The rename() function
/**
* g_mkdir:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: permissions to use for the newly created directory
*
* A wrapper for the POSIX mkdir() function. The mkdir() function
}
/**
+ * g_chdir:
+ * @path: a pathname in the GLib file name encoding (UTF-8 on Windows)
+ *
+ * A wrapper for the POSIX chdir() function. The function changes the
+ * current directory of the process to @path.
+ *
+ * See your C library manual for more details about chdir().
+ *
+ * Returns: 0 on success, -1 if an error occurred.
+ *
+ * Since: 2.8
+ */
+int
+g_chdir (const gchar *path)
+{
+#ifdef G_OS_WIN32
+ if (G_WIN32_HAVE_WIDECHAR_API ())
+ {
+ wchar_t *wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
+
+ 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 = g_locale_from_utf8 (path, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
+
+ 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
+}
+
+/**
* g_stat:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @buf: a pointer to a <structname>stat</structname> struct, which
* will be filled with the file information
*
/**
* g_lstat:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @buf: a pointer to a <structname>stat</structname> struct, which
* will be filled with the file information
*
/**
* g_unlink:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
*
* A wrapper for the POSIX unlink() function. The unlink() function
* deletes a name from the filesystem. If this was the last link to the
/**
* g_remove:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
*
* A wrapper for the POSIX remove() function. The remove() function
* deletes a name from the filesystem.
/**
* g_rmdir:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
*
* A wrapper for the POSIX rmdir() function. The rmdir() function
* deletes a directory from the filesystem.
/**
* g_fopen:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: a string describing the mode in which the file should be
* opened
*
/**
* g_freopen:
- * @filename: a pathname in the GLib file name encoding
+ * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
* @mode: a string describing the mode in which the file should be
* opened
* @stream: an existing stream which will be reused, or %NULL
* In such a case, and if the filename refers to an existing file, and
* the file system stores alternate short (8.3) names for directory
* entries, the short form of the filename is returned. Note that the
- * "short" name might in fact be longer than the Unicode name. If no
- * system codepage name for the file is possible, %NULL is returned.
+ * "short" name might in fact be longer than the Unicode name if the
+ * Unicode name has very short pathname components containing
+ * non-ASCII characters. If no system codepage name for the file is
+ * possible, %NULL is returned.
*
- * The return value is dynamically allocated and should be freed when
- * no longer used.
+ * The return value is dynamically allocated and should be freed with
+ * g_free() when no longer needed.
*
* Return value: The converted filename, or %NULL on conversion
* failure and lack of short names.