mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
glib/gstdio.h glib/gstdio.c Wrap also creat(). (#171285)
2005-04-08 Tor Lillqvist <tml@novell.com> * glib/gstdio.h * glib/gstdio.c * glib/glib.symbols (g_creat): Wrap also creat(). (#171285)
This commit is contained in:
parent
9099d64b3a
commit
ff79c0b525
@ -2,8 +2,8 @@
|
||||
|
||||
* glib/gstdio.h
|
||||
* glib/gstdio.c
|
||||
* glib/glib.symbols (g_access, g_chmod): Wrap also access() and
|
||||
chmod(). (#169623)
|
||||
* glib/glib.symbols (g_access, g_chmod, g_creat): Wrap also
|
||||
access(), chmod() and creat(). (#169623, #171285)
|
||||
|
||||
2005-04-08 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
* glib/gstdio.h
|
||||
* glib/gstdio.c
|
||||
* glib/glib.symbols (g_access, g_chmod): Wrap also access() and
|
||||
chmod(). (#169623)
|
||||
* glib/glib.symbols (g_access, g_chmod, g_creat): Wrap also
|
||||
access(), chmod() and creat(). (#169623, #171285)
|
||||
|
||||
2005-04-08 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
* glib/gstdio.h
|
||||
* glib/gstdio.c
|
||||
* glib/glib.symbols (g_access, g_chmod): Wrap also access() and
|
||||
chmod(). (#169623)
|
||||
* glib/glib.symbols (g_access, g_chmod, g_creat): Wrap also
|
||||
access(), chmod() and creat(). (#169623, #171285)
|
||||
|
||||
2005-04-08 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
* glib/gstdio.h
|
||||
* glib/gstdio.c
|
||||
* glib/glib.symbols (g_access, g_chmod): Wrap also access() and
|
||||
chmod(). (#169623)
|
||||
* glib/glib.symbols (g_access, g_chmod, g_creat): Wrap also
|
||||
access(), chmod() and creat(). (#169623, #171285)
|
||||
|
||||
2005-04-08 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
|
@ -852,6 +852,7 @@ g_spawn_sync
|
||||
g_access
|
||||
g_chmod
|
||||
g_open
|
||||
g_creat
|
||||
g_rename
|
||||
g_mkdir
|
||||
g_stat
|
||||
|
@ -258,6 +258,75 @@ g_open (const gchar *filename,
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* g_creat:
|
||||
* @filename: a pathname in the GLib file name encoding
|
||||
* @mode: as in creat()
|
||||
*
|
||||
* A wrapper for the POSIX creat() function. The creat() function is
|
||||
* used to convert a pathname into a file descriptor, creating a file
|
||||
* if necessar. Note that on POSIX systems file descriptors are
|
||||
* implemented by the operating system. On Windows, it's the C library
|
||||
* that implements creat() and file descriptors. The actual Windows
|
||||
* API for opening files is something different.
|
||||
*
|
||||
* See the C library manual for more details about creat().
|
||||
*
|
||||
* Returns: a new file descriptor, or -1 if an error occurred. The
|
||||
* return value can be used exactly like the return value from creat().
|
||||
*
|
||||
* Since: 2.7
|
||||
*/
|
||||
int
|
||||
g_creat (const gchar *filename,
|
||||
int mode)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
if (G_WIN32_HAVE_WIDECHAR_API ())
|
||||
{
|
||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||
int retval;
|
||||
int save_errno;
|
||||
|
||||
if (wfilename == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = _wcreat (wfilename, mode);
|
||||
save_errno = errno;
|
||||
|
||||
g_free (wfilename);
|
||||
|
||||
errno = save_errno;
|
||||
return retval;
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
|
||||
int retval;
|
||||
int save_errno;
|
||||
|
||||
if (cp_filename == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = creat (cp_filename, mode);
|
||||
save_errno = errno;
|
||||
|
||||
g_free (cp_filename);
|
||||
|
||||
errno = save_errno;
|
||||
return retval;
|
||||
}
|
||||
#else
|
||||
return creat (filename, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* g_rename:
|
||||
* @oldfilename: a pathname in the GLib file name encoding
|
||||
|
@ -34,6 +34,7 @@
|
||||
#define g_access access
|
||||
#define g_chmod chmod
|
||||
#define g_open open
|
||||
#define g_creat creat
|
||||
#define g_rename rename
|
||||
#define g_mkdir mkdir
|
||||
#define g_stat stat
|
||||
@ -66,6 +67,9 @@ int g_open (const gchar *filename,
|
||||
int flags,
|
||||
int mode);
|
||||
|
||||
int g_creat (const gchar *filename,
|
||||
int mode);
|
||||
|
||||
int g_rename (const gchar *oldfilename,
|
||||
const gchar *newfilename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user