diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-28 12:18:04 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-28 12:18:04 +0200 |
| commit | 9a0407119f41dab3264f9d6e52a6adf35b433cac (patch) | |
| tree | 9f0774709eba8ea4827ea2ffd333346354add0e5 | |
| parent | ddf8647a5393e049f514a39764aebd8893ce00b9 (diff) | |
| download | vis-9a0407119f41dab3264f9d6e52a6adf35b433cac.tar.gz vis-9a0407119f41dab3264f9d6e52a6adf35b433cac.tar.xz | |
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.
| -rw-r--r-- | text.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) { |
