Add a wrapper for fopen. On unix-like systems just pass-through. On
windows use unicode version.
This commit is contained in:
parent
ae5540d3d4
commit
bb338aaf24
27 changed files with 97 additions and 41 deletions
|
@ -499,3 +499,9 @@ grub_util_fd_strerror (void)
|
|||
return buf + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
FILE *
|
||||
grub_util_fopen (const char *path, const char *mode)
|
||||
{
|
||||
return fopen (path, mode);
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
|
|||
if (relroot)
|
||||
*relroot = NULL;
|
||||
|
||||
fp = fopen ("/proc/self/mountinfo", "r");
|
||||
fp = grub_util_fopen ("/proc/self/mountinfo", "r");
|
||||
if (! fp)
|
||||
return NULL; /* fall through to other methods */
|
||||
|
||||
|
|
|
@ -721,7 +721,7 @@ grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs)
|
|||
if (stat (dir, &st) != 0)
|
||||
return;
|
||||
|
||||
FILE *mnttab = fopen ("/etc/mnttab", "r");
|
||||
FILE *mnttab = grub_util_fopen ("/etc/mnttab", "r");
|
||||
if (! mnttab)
|
||||
return;
|
||||
|
||||
|
|
|
@ -211,4 +211,10 @@ canonicalize_file_name (const char *path)
|
|||
#endif
|
||||
}
|
||||
|
||||
FILE *
|
||||
grub_util_fopen (const char *path, const char *mode)
|
||||
{
|
||||
return fopen (path, mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@ grub_get_random (void *out, grub_size_t len)
|
|||
FILE *f;
|
||||
size_t rd;
|
||||
|
||||
f = fopen ("/dev/urandom", "rb");
|
||||
f = grub_util_fopen ("/dev/urandom", "rb");
|
||||
if (!f)
|
||||
return 1;
|
||||
rd = fread (out, 1, len, f);
|
||||
|
|
|
@ -291,9 +291,35 @@ canonicalize_file_name (const char *path)
|
|||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
FILE *
|
||||
grub_util_fopen (const char *path, const char *mode)
|
||||
{
|
||||
LPTSTR tpath;
|
||||
FILE *ret;
|
||||
tpath = grub_util_get_windows_path (path);
|
||||
#if SIZEOF_TCHAR == 1
|
||||
ret = fopen (tpath, tmode);
|
||||
#else
|
||||
LPTSTR tmode;
|
||||
tmode = grub_util_utf8_to_tchar (mode);
|
||||
ret = _wfopen (tpath, tmode);
|
||||
free (tmode);
|
||||
#endif
|
||||
free (tpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fsync (int fno __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FILE *
|
||||
grub_util_fopen (const char *path, const char *mode)
|
||||
{
|
||||
return fopen (path, mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue