2023-07-03 13:10:16 +02:00
|
|
|
#include "sys/sysproto.hpp"
|
2024-01-13 18:57:02 +01:00
|
|
|
#include "thread/Thread.hpp"
|
|
|
|
|
#include "thread/Process.hpp"
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <string>
|
2023-07-03 13:10:16 +02:00
|
|
|
|
2023-07-06 18:16:25 +02:00
|
|
|
orbis::SysResult orbis::sys___getcwd(Thread *thread, ptr<char> buf,
|
|
|
|
|
uint buflen) {
|
2024-01-13 18:57:02 +01:00
|
|
|
|
|
|
|
|
std::string cwd;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard lock(thread->tproc->mtx);
|
|
|
|
|
cwd = std::string(thread->tproc->cwd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buflen < cwd.size() + 1) {
|
|
|
|
|
return ErrorCode::NOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ORBIS_RET_ON_ERROR(uwriteRaw(buf, cwd.data(), cwd.size() + 1));
|
|
|
|
|
return{};
|
2023-07-06 18:16:25 +02:00
|
|
|
}
|