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