+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.
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 *