From b6406159bd7b35e05a68c7d42aad42f856f11c0a Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 17 Feb 2019 18:46:19 -0500 Subject: [PATCH 1/2] unix host mli bug fixes 1. file/directory storage types were reversed 2. month was off-by-one. --- src/unix_host_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix_host_common.c b/src/unix_host_common.c index 0df5b91..c5075d9 100644 --- a/src/unix_host_common.c +++ b/src/unix_host_common.c @@ -126,7 +126,7 @@ void host_set_date_time(word32 ptr, time_t time) { word16 tmp = 0; tmp |= (tm->tm_year % 100) << 9; - tmp |= tm->tm_mon << 5; + tmp |= (tm->tm_mon + 1) << 5; tmp |= tm->tm_mday; set_memory16_c(ptr, tmp, 0); @@ -146,7 +146,7 @@ word32 host_convert_date_time(time_t time) { word16 dd = 0; dd |= (tm->tm_year % 100) << 9; - dd |= tm->tm_mon << 5; + dd |= (tm->tm_mon + 1) << 5; dd |= tm->tm_mday; word16 tt = 0; @@ -503,10 +503,10 @@ unsigned host_storage_type(const char *path, word16 *error) { *error = host_map_errno_path(errno, path); return 0; } - if (S_ISREG(st.st_mode)) { + if (S_ISDIR(st.st_mode)) { return host_is_root(&st) ? 0x0f : directoryFile; } - if (S_ISDIR(st.st_mode)) return standardFile; + if (S_ISREG(st.st_mode)) return standardFile; *error = badStoreType; return 0; } From e9e9fcfd59c21508bc1144b7ed35824e41c6eef1 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 17 Feb 2019 21:18:11 -0500 Subject: [PATCH 2/2] host mli - opening/closing a directory would close fd 0 (aka stdin). --- src/host_mli.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/host_mli.c b/src/host_mli.c index 5356e94..48bec74 100644 --- a/src/host_mli.c +++ b/src/host_mli.c @@ -1048,6 +1048,11 @@ static int mli_open(unsigned dcb, const char *name, const char *path) { word16 terr = host_get_file_info(path, &fi); if (terr) return terr; +#if _WIN32 + file->h = INVALID_HANDLE_VALUE; +#else + file->fd = -1; +#endif if (fi.storage_type == 0x0f || fi.storage_type == 0x0d) { unsigned blocks;