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

@ -1,3 +1,14 @@
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.
2005-06-08 Tor Lillqvist <tml@novell.com>
* glib/gutils.c (get_windows_directory_root): New helper function

View File

@ -1,3 +1,14 @@
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.
2005-06-08 Tor Lillqvist <tml@novell.com>
* glib/gutils.c (get_windows_directory_root): New helper function

View File

@ -1,3 +1,14 @@
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.
2005-06-08 Tor Lillqvist <tml@novell.com>
* glib/gutils.c (get_windows_directory_root): New helper function

View File

@ -1,3 +1,14 @@
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.
2005-06-08 Tor Lillqvist <tml@novell.com>
* glib/gutils.c (get_windows_directory_root): New helper function

View File

@ -858,6 +858,7 @@ g_open
g_creat
g_rename
g_mkdir
g_chdir
g_stat
g_lstat
g_unlink
@ -1228,6 +1229,7 @@ g_win32_get_package_installation_subdirectory PRIVATE
g_win32_get_package_installation_subdirectory_utf8
g_win32_get_windows_version
g_win32_getlocale
g_win32_locale_filename_from_utf8
#endif
#endif
#endif

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

View File

@ -37,6 +37,7 @@
#define g_creat creat
#define g_rename rename
#define g_mkdir mkdir
#define g_chdir chdir
#define g_stat stat
#define g_lstat lstat
#define g_unlink unlink
@ -76,6 +77,8 @@ int g_rename (const gchar *oldfilename,
int g_mkdir (const gchar *filename,
int mode);
int g_chdir (const gchar *path);
int g_stat (const gchar *filename,
struct stat *buf);

View File

@ -1483,11 +1483,13 @@ g_win32_get_windows_version (void)
* 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.