24#include "AstUtil/StringView.hpp"
25#include "AstUtil/PosixExt.hpp"
26#include "AstUtil/Logger.hpp"
43 oldpath_ = posix::getcwd();
45 int rc = posix::chdir(std::string(path).c_str());
47 aError(
"failed to change working directory to %.*s", path.size(), path.data());
54 int rc = posix::chdir(oldpath_.c_str());
56 aError(
"failed to change working directory to %s", oldpath_.c_str());
60 operator bool()
const {
return isChanged(); }
63 bool isChanged()
const {
return !curpath_.empty(); }
工作目录切换器
定义 WorkingDirectory.hpp:39
WorkingDirectory(StringView path)
定义 WorkingDirectory.hpp:41
bool isChanged() const
检查是否成功切换工作目录
定义 WorkingDirectory.hpp:63
StringView getCurrentPath() const
获取切换后的工作目录
定义 WorkingDirectory.hpp:66