PBGetCatInfo should return a directory's directory id.

This commit is contained in:
Kelvin Sherlock 2015-01-07 14:44:26 -05:00
parent 45c89042ee
commit b9fcbf2aac
2 changed files with 18 additions and 2 deletions

View File

@ -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<std::string> 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);

View File

@ -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;