mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-28 08:49:20 +00:00
PBGetCatInfo should return a directory's directory id.
This commit is contained in:
parent
45c89042ee
commit
b9fcbf2aac
@ -28,6 +28,13 @@ namespace OS {
|
|||||||
|
|
||||||
int32_t FSSpecManager::IDForPath(const std::string &path, bool insert)
|
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];
|
char buffer[PATH_MAX + 1];
|
||||||
|
|
||||||
@ -66,6 +73,10 @@ namespace OS {
|
|||||||
std::string s(cp);
|
std::string s(cp);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// trailing / is required.
|
||||||
|
if (path.empty()) return -1;
|
||||||
|
if (path.back() != '/') path.push_back('/');
|
||||||
|
|
||||||
std::hash<std::string> hasher;
|
std::hash<std::string> hasher;
|
||||||
size_t hash = hasher(path);
|
size_t hash = hasher(path);
|
||||||
|
|
||||||
@ -99,7 +110,7 @@ namespace OS {
|
|||||||
|
|
||||||
std::string FSSpecManager::ExpandPath(const std::string &path, int32_t id)
|
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;
|
if (id == 0) return path;
|
||||||
|
|
||||||
const std::string &dir = PathForID(id);
|
const std::string &dir = PathForID(id);
|
||||||
|
@ -215,7 +215,12 @@ namespace OS {
|
|||||||
memoryWriteByte(0, parm + _ioACUser);
|
memoryWriteByte(0, parm + _ioACUser);
|
||||||
|
|
||||||
std::memset(memoryPointer(parm + _ioDrUsrWds), 0, 16); // DInfo
|
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 ..)
|
// the links count should be ~= number of dirents ( +2 for . and ..)
|
||||||
int links = st.st_nlink - 2;
|
int links = st.st_nlink - 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user