diff --git a/toolbox/fs_spec.cpp b/toolbox/fs_spec.cpp index 22cd60d..7a8020e 100644 --- a/toolbox/fs_spec.cpp +++ b/toolbox/fs_spec.cpp @@ -28,6 +28,13 @@ namespace OS { int32_t FSSpecManager::IDForPath(const std::string &path, bool insert) { + if (path.empty()) return -1; + if (path.back() != '/') + { + std::string tmp(path); + return IDForPath(std::move(tmp), insert); + } + /* char buffer[PATH_MAX + 1]; @@ -66,6 +73,10 @@ namespace OS { std::string s(cp); */ + // trailing / is required. + if (path.empty()) return -1; + if (path.back() != '/') path.push_back('/'); + std::hash hasher; size_t hash = hasher(path); @@ -99,7 +110,7 @@ namespace OS { std::string FSSpecManager::ExpandPath(const std::string &path, int32_t id) { - if (path.length() && path[0] == '/') return path; + if (path.length() && path.front() == '/') return path; if (id == 0) return path; const std::string &dir = PathForID(id); diff --git a/toolbox/os_hfs_dispatch.cpp b/toolbox/os_hfs_dispatch.cpp index 65dfe9b..1a5209d 100644 --- a/toolbox/os_hfs_dispatch.cpp +++ b/toolbox/os_hfs_dispatch.cpp @@ -215,7 +215,12 @@ namespace OS { memoryWriteByte(0, parm + _ioACUser); std::memset(memoryPointer(parm + _ioDrUsrWds), 0, 16); // DInfo - memoryWriteLong(0, parm + _ioDrDirID); + + // cw68k expects the directory ID to be set. + + uint32_t dirID = FSSpecManager::IDForPath(sname); + + memoryWriteLong(dirID, parm + _ioDrDirID); // the links count should be ~= number of dirents ( +2 for . and ..) int links = st.st_nlink - 2;