From 9a0407119f41dab3264f9d6e52a6adf35b433cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 28 Sep 2014 12:18:04 +0200 Subject: More helpful error when trying to open a non file This is not really correct e.g. vis /dev/zero will print a misleading error. --- text.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'text.c') diff --git a/text.c b/text.c index 565505f..89e3512 100644 --- a/text.c +++ b/text.c @@ -664,8 +664,10 @@ Text *text_load(const char *filename) { goto out; if (fstat(txt->fd, &txt->info) == -1) goto out; - if (!S_ISREG(txt->info.st_mode)) + if (!S_ISREG(txt->info.st_mode)) { + errno = EISDIR; goto out; + } // XXX: use lseek(fd, 0, SEEK_END); instead? txt->buf.size = txt->info.st_size; if (txt->buf.size != 0) { -- cgit v1.2.3