--- nono/host/hostwindrv.cpp 2026/04/29 17:05:26 1.1 +++ nono/host/hostwindrv.cpp 2026/04/29 17:06:02 1.1.1.5 @@ -9,6 +9,8 @@ // #include "hostwindrv.h" +#include "ascii_ctype.h" +#include "mytime.h" #include #include #include @@ -41,20 +43,37 @@ HostWindrv::~HostWindrv() } // ルートパスの設定。 -void +bool HostWindrv::InitRootPath(const std::string& rootpath_) { - assert(rootpath_.empty() == false); rootpath = rootpath_; // ルートパスのほうは末尾の '/' なし。 // ゲストパスが必ず '/' から始まるため。 - while (*rootpath.rbegin() == '/') { + while (rootpath.empty() == false && rootpath.back() == '/') { rootpath.pop_back(); } if (rootpath.empty()) { rootpath = "."; } + + struct stat st; + int r = stat(rootpath.c_str(), &st); + if (r < 0) { + putmsg(1, "stat '%s': %s", rootpath.c_str(), strerror(errno)); + return false; + } + if (!S_ISDIR(st.st_mode)) { + putmsg(1, "stat '%s': Not directory", rootpath.c_str()); + return false; + } + r = access(rootpath.c_str(), R_OK | X_OK); + if (r != 0) { + putmsg(1, "access '%s': %s", rootpath.c_str(), strerror(errno)); + return false; + } + + return true; } // 初期化コマンド。 @@ -373,7 +392,7 @@ HostWindrv::IsHuman68kFilename(const cha for (auto c : name) { // TODO: 記号どこまで使えるか調べる - if (!isalnum((int)c) && strchr("-._", c) == NULL) { + if (!is_ascii_alnum(c) && strchr("-._", c) == NULL) { return false; } } @@ -816,9 +835,11 @@ HostWindrv::SetFileTime(Windrv::FCB *fcb // [0] が atime、[1] が mtime。 struct timeval times[2]; - times[1].tv_sec = Human68k::DateTime2Unixtime(datetime); + uint64 now = get_hosttime_usec(); + times[0].tv_sec = now / 1000'000U; + times[0].tv_usec = now % 1000'000U; + times[1].tv_sec = Human68k::DateTime2Unixtime(datetime); times[1].tv_usec = 0; - gettimeofday(×[0], NULL); int r = futimes(fcb->fd, times); if (r < 0) { putmsg(1, "%s: futimes: %s", __func__, strerror(errno)); @@ -831,6 +852,6 @@ HostWindrv::SetFileTime(Windrv::FCB *fcb /*static*/ uint64 HostWindrv::timespec2nsec(const struct timespec& ts) { - return (uint64)ts.tv_sec * 1000'000'000 + (uint64)ts.tv_nsec; + return sec_to_nsec(ts.tv_sec) + ts.tv_nsec; } #endif