mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
vfs: Implement GetName() & GetPath() in FileNode class
This commit is contained in:
parent
74faef2623
commit
3ca2463834
@ -48,6 +48,9 @@ public:
|
|||||||
Inode *Node;
|
Inode *Node;
|
||||||
FileSystemInfo *fsi;
|
FileSystemInfo *fsi;
|
||||||
|
|
||||||
|
std::string GetName();
|
||||||
|
std::string GetPath();
|
||||||
|
|
||||||
bool IsDirectory() { return S_ISDIR(Node->Mode); }
|
bool IsDirectory() { return S_ISDIR(Node->Mode); }
|
||||||
bool IsCharacterDevice() { return S_ISCHR(Node->Mode); }
|
bool IsCharacterDevice() { return S_ISCHR(Node->Mode); }
|
||||||
bool IsBlockDevice() { return S_ISBLK(Node->Mode); }
|
bool IsBlockDevice() { return S_ISBLK(Node->Mode); }
|
||||||
|
@ -287,3 +287,27 @@ namespace vfs
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string FileNode::GetName()
|
||||||
|
{
|
||||||
|
return this->Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileNode::GetPath()
|
||||||
|
{
|
||||||
|
const char *path = this->Path.c_str();
|
||||||
|
if (strncmp(path, "\x06root-", 6) == 0) /* FIXME: deduce the index */
|
||||||
|
{
|
||||||
|
path += 6;
|
||||||
|
while (*path != '\0' && *path != '\x06')
|
||||||
|
path++;
|
||||||
|
if (*path == '\x06')
|
||||||
|
path++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return this->Path;
|
||||||
|
|
||||||
|
if (path[0] == '\0')
|
||||||
|
return std::string(this->fsi->RootName);
|
||||||
|
return std::string(path);
|
||||||
|
}
|
||||||
|
@ -1897,14 +1897,19 @@ static long linux_getcwd(SysFrm *, char *buf, size_t size)
|
|||||||
if (pBuf == nullptr)
|
if (pBuf == nullptr)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
const char *cwd = pcb->CWD->Path.c_str();
|
std::string cwd = pcb->CWD->GetPath();
|
||||||
size_t len = strlen(cwd);
|
if (cwd.length() >= size)
|
||||||
if (len >= size)
|
|
||||||
{
|
{
|
||||||
warn("Buffer too small (%ld < %ld)", len, size);
|
warn("Buffer too small (%ld < %ld)", cwd.length(), size);
|
||||||
return -ERANGE;
|
return -linux_ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strncpy(pBuf, cwd.c_str(), cwd.length());
|
||||||
|
pBuf[cwd.length()] = '\0';
|
||||||
|
debug("cwd: \"%s\" with %ld bytes", cwd.c_str(), cwd.length());
|
||||||
|
return cwd.length();
|
||||||
|
}
|
||||||
|
|
||||||
static int linux_chdir(SysFrm *, const char *path)
|
static int linux_chdir(SysFrm *, const char *path)
|
||||||
{
|
{
|
||||||
PCB *pcb = thisProcess;
|
PCB *pcb = thisProcess;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user