aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-10-24 15:08:46 +0100
committergingerBill <bill@gingerbill.org>2020-10-24 15:08:46 +0100
commit0061e63db010cdb2043af63527b4c25f45652a51 (patch)
treed34d662837963a8b0aa0b26fb6e994c511ff311d /src/common.cpp
parent5fa488f163fbaa049e213f4b1cabf885ab49816f (diff)
parent71ef27fef92a926059183f0cda927b29aaf74793 (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 8d2802b1f..350127e1e 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -968,7 +968,20 @@ ReadDirectoryError read_directory(String path, Array<FileInfo> *fi) {
DIR *dir = opendir(c_path);
if (!dir) {
- return ReadDirectory_NotDir;
+ switch (errno) {
+ case ENOENT:
+ return ReadDirectory_NotExists;
+ case EACCES:
+ return ReadDirectory_Permission;
+ case ENOTDIR:
+ return ReadDirectory_NotDir;
+ default:
+ // ENOMEM: out of memory
+ // EMFILE: per-process limit on open fds reached
+ // ENFILE: system-wide limit on total open files reached
+ return ReadDirectory_Unknown;
+ }
+ GB_PANIC("unreachable");
}
array_init(fi, a, 0, 100);