Define grub_util_is_directory/regular/special_file and

use OS-dependent versions rather than to rely on stat().
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-15 20:27:58 +02:00
parent ec16e02639
commit df1e64c98e
6 changed files with 113 additions and 31 deletions

View file

@ -216,4 +216,36 @@ grub_util_fopen (const char *path, const char *mode)
return fopen (path, mode);
}
int
grub_util_is_directory (const char *path)
{
struct stat st;
if (stat (path, &st) == -1)
return 0;
return S_ISDIR (st.st_mode);
}
int
grub_util_is_regular (const char *path)
{
struct stat st;
if (stat (path, &st) == -1)
return 0;
return S_ISREG (st.st_mode);
}
int
grub_util_is_special_file (const char *path)
{
struct stat st;
if (lstat (path, &st) == -1)
return 1;
return (!S_ISREG (st.st_mode) && !S_ISDIR (st.st_mode));
}
#endif