mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
Use consistent error messages for missing files.
Detect directories where an ordinary file is expected.
This commit is contained in:
@ -450,3 +450,28 @@ parse_vma (const char *s, const char *arg)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns the size of the named file. If the file does not
|
||||
exist, or if it is not a real file, then a suitable non-fatal
|
||||
error message is printed and zero is returned. */
|
||||
|
||||
off_t
|
||||
get_file_size (const char * file_name)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (file_name, &statbuf) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
non_fatal (_("'%s': No such file"), file_name);
|
||||
else
|
||||
non_fatal (_("Warning: could not locate '%s'. reason: %s"),
|
||||
file_name, strerror (errno));
|
||||
}
|
||||
else if (! S_ISREG (statbuf.st_mode))
|
||||
non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
|
||||
else
|
||||
return statbuf.st_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user