--- nono/host/hostwindrv.cpp 2026/04/29 17:05:26 1.1.1.1 +++ nono/host/hostwindrv.cpp 2026/04/29 17:05:55 1.1.1.4 @@ -9,6 +9,7 @@ // #include "hostwindrv.h" +#include "ascii_ctype.h" #include #include #include @@ -41,20 +42,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 +391,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; } }