MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / fchdir

Method fchdir

source/kernel/kprocess.cpp:1683–1705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1681}
1682
1683U32 KProcess::fchdir(FD fildes) {
1684 KFileDescriptorPtr fd = this->getFileDescriptor(fildes);
1685
1686 if (fd==nullptr) {
1687 return -K_EBADF;
1688 }
1689 if (fd->kobject->type!=KTYPE_FILE) {
1690 return -K_EINVAL;
1691 }
1692 std::shared_ptr<KFile> p = std::dynamic_pointer_cast<KFile>(fd->kobject);
1693
1694 if (!p->openFile->node->isDirectory()) {
1695 return -K_ENOTDIR;
1696 }
1697 if (p->openFile->openedPath.length())
1698 this->currentDirectory = p->openFile->openedPath;
1699 else
1700 this->currentDirectory = p->openFile->node->path;
1701 if (this->currentDirectory.endsWith("/")) {
1702 this->currentDirectory = this->currentDirectory.substr(0, this->currentDirectory.length()-1);
1703 }
1704 return 0;
1705}
1706
1707S64 KProcess::llseek(FD fildes, S64 offset, U32 whence) {
1708 KFileDescriptorPtr fd = this->getFileDescriptor(fildes);

Callers 1

syscall_fchdirFunction · 0.80

Calls 5

getFileDescriptorMethod · 0.95
isDirectoryMethod · 0.80
endsWithMethod · 0.80
substrMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected