glib/gstdio.h glib/gstdio.c Add a chdir() wrapper, too.

2005-06-09  Tor Lillqvist  <tml@novell.com>

	* glib/gstdio.h
	* glib/gstdio.c
	* glib/glib.symbols: Add a chdir() wrapper, too.

	* glib/glib.symbols: Add g_win32_locale_filename_from_utf8().

	* glib/gwin32.c (g_win32_locale_filename_from_utf8): Clarify doc
	comment.
This commit is contained in:
Tor Lillqvist
2005-06-09 10:46:21 +00:00
committed by Tor Lillqvist
parent b8d34f6609
commit f928d83482
8 changed files with 130 additions and 17 deletions

View File

@@ -50,7 +50,7 @@
/**
* 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
@@ -120,7 +120,7 @@ g_access (const gchar *filename,
/**
* 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
@@ -189,7 +189,7 @@ g_chmod (const gchar *filename,
/**
* 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()
*
@@ -260,7 +260,7 @@ g_open (const gchar *filename,
/**
* 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
@@ -329,7 +329,7 @@ g_creat (const gchar *filename,
/**
* 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
@@ -419,7 +419,7 @@ g_rename (const gchar *oldfilename,
/**
* 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
@@ -482,9 +482,71 @@ g_mkdir (const gchar *filename,
#endif
}
/**
* 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
*
@@ -550,7 +612,7 @@ g_stat (const gchar *filename,
/**
* 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
*
@@ -581,7 +643,7 @@ g_lstat (const gchar *filename,
/**
* 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
@@ -648,7 +710,7 @@ g_unlink (const gchar *filename)
/**
* 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.
@@ -722,7 +784,7 @@ g_remove (const gchar *filename)
/**
* 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.
@@ -786,7 +848,7 @@ g_rmdir (const gchar *filename)
/**
* 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
*
@@ -863,7 +925,7 @@ g_fopen (const gchar *filename,
/**
* 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