| 1681 | } |
| 1682 | |
| 1683 | U32 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 | |
| 1707 | S64 KProcess::llseek(FD fildes, S64 offset, U32 whence) { |
| 1708 | KFileDescriptorPtr fd = this->getFileDescriptor(fildes); |
no test coverage detected