Add a scoped CWD restorer, and set method
This commit is contained in:
parent
cf63a35e94
commit
c8f464aa7b
19
io.cpp
19
io.cpp
@ -131,6 +131,24 @@ indenter::~indenter ()
|
||||
m_owner->rdbuf (m_dest);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
scoped_cwd::scoped_cwd ():
|
||||
m_original (getcwd (nullptr, 0))
|
||||
{
|
||||
if (!m_original)
|
||||
throw errno_error ();
|
||||
}
|
||||
|
||||
|
||||
scoped_cwd::~scoped_cwd () {
|
||||
set_cwd (m_original.data ());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util::set_cwd (const boost::filesystem::path &path) {
|
||||
chdir (path.string ().c_str ());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
#if defined(HAVE_MMAP)
|
||||
@ -189,4 +207,3 @@ mapped_file::data (void) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user