]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/misc.c (grub_util_get_image_size): Use FILE functions rather than
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 13 Oct 2013 21:45:22 +0000 (23:45 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 13 Oct 2013 21:45:22 +0000 (23:45 +0200)
stat.

ChangeLog
util/misc.c

index b29964a3b9ea90f90b2472554b700e9d0906c191..2a51cd796f48191e8ccb9eb41d856fefc90ad0b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index e6bba751bd2d394faac2bf6b553371b423418929..1f7784ba9c1faed0781c737d2949f0cbe8a23360 100644 (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 *