Do not use FILE functions directly

This commit is contained in:
Yevgen Muntyan 2015-12-25 21:35:41 -08:00
parent 04b80a26e7
commit e0806c3c86
3 changed files with 6 additions and 57 deletions

View File

@ -1194,56 +1194,6 @@ _moo_mkdir (const char *path, mgw_errno_t *err)
}
gpointer
_moo_fopen (const char *path,
const char *mode)
{
#ifdef __WIN32__
gboolean use_wide_char_api;
gpointer path_conv, mode_conv;
FILE *retval;
mgw_errno_t save_errno;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
use_wide_char_api = TRUE;
path_conv = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
mode_conv = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
}
else
{
use_wide_char_api = FALSE;
path_conv = g_locale_from_utf8 (path, -1, NULL, NULL, NULL);
mode_conv = g_locale_from_utf8 (mode, -1, NULL, NULL, NULL);
}
if (!path_conv || !mode_conv)
{
g_free (path_conv);
g_free (mode_conv);
mgw_set_errno (MGW_EINVAL);
return NULL;
}
mgw_set_errno (0);
if (use_wide_char_api)
retval = _wfopen (path_conv, mode_conv);
else
retval = fopen (path_conv, mode_conv);
save_errno = mgw_errno ();
g_free (path_conv);
g_free (mode_conv);
mgw_set_errno (save_errno);
return retval;
#else
return fopen (path, mode);
#endif
}
int
_moo_rename (const char *old_name,
const char *new_name,

View File

@ -83,8 +83,6 @@ gboolean _moo_move_files_ui (GList *filenames,
int _moo_mkdir (const char *path,
mgw_errno_t *err); /* S_IRWXU on unix */
gpointer _moo_fopen (const char *path,
const char *mode);
int _moo_rename (const char *old_name,
const char *new_name,
mgw_errno_t *err);

View File

@ -887,7 +887,8 @@ static void moo_static_rec_mutex_unlock (GStaticRecMutex *mutex)
static void
print_func_file (const char *string)
{
FILE *file;
MGW_FILE *file;
mgw_errno_t err;
moo_static_rec_mutex_lock (&moo_log_file_mutex);
@ -899,18 +900,18 @@ print_func_file (const char *string)
if (!moo_log_file_written)
{
file = fopen (moo_log_file, "w+");
file = mgw_fopen (moo_log_file, "w+", &err);
moo_log_file_written = TRUE;
}
else
{
file = fopen (moo_log_file, "a+");
file = mgw_fopen (moo_log_file, "a+", &err);
}
if (file)
{
fprintf (file, "%s", string);
fclose (file);
mgw_fwrite (string, strlen(string), 1, file);
mgw_fclose (file);
}
else
{