* util/misc.c (grub_util_get_image_size): Use FILE functions rather than

stat.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-13 23:45:22 +02:00
parent e19bec1715
commit 66a1b3eeb7
2 changed files with 17 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2013-10-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/misc.c (grub_util_get_image_size): Use FILE functions rather than
stat.
2013-10-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-editenv.c: Remove leftover set_program_name and init_nls.

View File

@ -79,14 +79,21 @@ grub_util_get_path (const char *dir, const char *file)
size_t
grub_util_get_image_size (const char *path)
{
struct stat st;
FILE *f;
size_t ret;
grub_util_info ("getting the size of %s", path);
f = grub_util_fopen (path, "rb");
if (stat (path, &st) == -1)
grub_util_error (_("cannot stat `%s': %s"), path, strerror (errno));
if (!f)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
return st.st_size;
fseeko (f, 0, SEEK_END);
ret = ftello (f);
fclose (f);
return ret;
}
char *