openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glib-2.0/1_2.60.3-r0/glib-2.60.3/glib/gstdio.c
int g_rename(const gchar* oldfilename, const gchar* newfilename)
{
#ifdef G_OS_WIN32
    wchar_t* woldfilename = g_utf8_to_utf16(oldfilename, -1, NULL, NULL, NULL);
    wchar_t* wnewfilename;
    int retval;
    int save_errno = 0;

    if (woldfilename == NULL)
    {
        errno = EINVAL;
        return -1;
    }

    wnewfilename = g_utf8_to_utf16(newfilename, -1, NULL, NULL, NULL);

    if (wnewfilename == NULL)
    {
        g_free(woldfilename);
        errno = EINVAL;
        return -1;
    }

    if (MoveFileExW(woldfilename, wnewfilename, MOVEFILE_REPLACE_EXISTING))
        retval = 0;
    else
    {
        retval = -1;
        switch (GetLastError())
        {
#define CASE(a, b)                                                             \
    case ERROR_##a:                                                            \
        save_errno = b;                                                        \
        break
            CASE(FILE_NOT_FOUND, ENOENT);
            CASE(PATH_NOT_FOUND, ENOENT);
            CASE(ACCESS_DENIED, EACCES);
            CASE(NOT_SAME_DEVICE, EXDEV);
            CASE(LOCK_VIOLATION, EACCES);
            CASE(SHARING_VIOLATION, EACCES);
            CASE(FILE_EXISTS, EEXIST);
            CASE(ALREADY_EXISTS, EEXIST);
#undef CASE
            default:
                save_errno = EIO;
        }
    }

    g_free(woldfilename);
    g_free(wnewfilename);

    errno = save_errno;
    return retval;
#else
    return rename(oldfilename, newfilename);
#endif
}
/**
 * g_rename:
 * @oldfilename: (type filename): a pathname in the GLib file name encoding
 *     (UTF-8 on Windows)
 * @newfilename: (type filename): a pathname in the GLib file name encoding
 *
 * A wrapper for the POSIX rename() function. The rename() function
 * renames a file, moving it between directories if required.
 *
 * See your C library manual for more details about how rename() works
 * on your system. It is not possible in general on Windows to rename
 * a file that is open to some process.
 *
 * Returns: 0 if the renaming succeeded, -1 if an error occurred
 *
 * Since: 2.6
 */
@oldfilename: (type filename): a pathname in the GLib file name encoding
(UTF-8 on Windows)
@newfilename: (type filename): a pathname in the GLib file name encoding

A wrapper for the POSIX rename() function. The rename() function
renames a file, moving it between directories if required.

See your C library manual for more details about how rename() works
on your system. It is not possible in general on Windows to rename
a file that is open to some process.

0 if the renaming succeeded, -1 if an error occurred


@oldfilename : ( type filename ) : a pathname in the GLib file name encoding ( UTF - 8 on Windows ) @newfilename : ( type filename ) : a pathname in the GLib file name encoding A wrapper for the POSIX rename () function . The rename () function renames a file moving it between directories if required . See your C library manual for more details about how rename () works on your system . It is not possible in general on Windows to rename a file that is open to some process . 0 if the renaming succeeded - 1 if an error occurred
int g_rename(const gchar* oldfilename, const gchar* newfilename)
{
#ifdef G_OS_WIN32
    wchar_t* woldfilename = g_utf8_to_utf16(oldfilename, -1, NULL, NULL, NULL);
    wchar_t* wnewfilename;
    int retval;
    int save_errno = 0;
    if (woldfilename == NULL)
    {
        errno = EINVAL;
        return -1;
    }
    wnewfilename = g_utf8_to_utf16(newfilename, -1, NULL, NULL, NULL);
    if (wnewfilename == NULL)
    {
        g_free(woldfilename);
        errno = EINVAL;
        return -1;
    }
    if (MoveFileExW(woldfilename, wnewfilename, MOVEFILE_REPLACE_EXISTING))
        retval = 0;
    else
    {
        retval = -1;
        switch (GetLastError())
        {
#define CASE(a, b)                                                             \
    case ERROR_##a:                                                            \
        save_errno = b;                                                        \
        break
            CASE(FILE_NOT_FOUND, ENOENT);
            CASE(PATH_NOT_FOUND, ENOENT);
            CASE(ACCESS_DENIED, EACCES);
            CASE(NOT_SAME_DEVICE, EXDEV);
            CASE(LOCK_VIOLATION, EACCES);
            CASE(SHARING_VIOLATION, EACCES);
            CASE(FILE_EXISTS, EEXIST);
            CASE(ALREADY_EXISTS, EEXIST);
#undef CASE
            default:
                save_errno = EIO;
        }
    }
    g_free(woldfilename);
    g_free(wnewfilename);
    errno = save_errno;
    return retval;
#else
    return rename(oldfilename, newfilename);
#endif
}
int g_rename ( const gchar * oldfilename , const gchar * newfilename ) { #ifdef G_OS_WIN32 wchar_t * woldfilename = g_utf8_to_utf16 ( oldfilename , -1 , NULL , NULL , NULL ) ; wchar_t * wnewfilename ; int retval ; int save_errno = 0 ; if ( woldfilename == NULL ) { errno = EINVAL ; return -1 ; } wnewfilename = g_utf8_to_utf16 ( newfilename , -1 , NULL , NULL , NULL ) ; if ( wnewfilename == NULL ) { g_free ( woldfilename ) ; errno = EINVAL ; return -1 ; } if ( MoveFileExW ( woldfilename , wnewfilename , MOVEFILE_REPLACE_EXISTING ) ) retval = 0 ; else { retval = -1 ; switch ( GetLastError ( ) ) { #define CASE ( a , b )                                                              \
    case ERROR_##a:                                                            \
        save_errno = b;                                                        \
        break CASE ( FILE_NOT_FOUND , ENOENT ) ; CASE ( PATH_NOT_FOUND , ENOENT ) ; CASE ( ACCESS_DENIED , EACCES ) ; CASE ( NOT_SAME_DEVICE , EXDEV ) ; CASE ( LOCK_VIOLATION , EACCES ) ; CASE ( SHARING_VIOLATION , EACCES ) ; CASE ( FILE_EXISTS , EEXIST ) ; CASE ( ALREADY_EXISTS , EEXIST ) ; #undef  CASE default : save_errno = EIO ; } } g_free ( woldfilename ) ; g_free ( wnewfilename ) ; errno = save_errno ; return retval ; #else return rename ( oldfilename , newfilename ) ; #endif }
g_rename:
 @oldfilename: (type filename): a pathname in the GLib file name encoding
     (UTF-8 on Windows)
 @newfilename: (type filename): a pathname in the GLib file name encoding
g_rename : @oldfilename : ( type filename ) : a pathname in the GLib file name encoding ( UTF - 8 on Windows ) @newfilename : ( type filename ) : a pathname in the GLib file name encoding