io: remove useless chdir wrapper
just use chdir directly.
This commit is contained in:
parent
b084cb2e4c
commit
0967c5252f
26
io.cpp
26
io.cpp
@ -197,21 +197,19 @@ indenter::~indenter ()
|
||||
m_owner->rdbuf (m_dest);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
scoped_cwd::scoped_cwd ():
|
||||
m_original(boost::filesystem::canonical (getcwd (nullptr, 0)))
|
||||
{ ; }
|
||||
|
||||
|
||||
scoped_cwd::~scoped_cwd () {
|
||||
set_cwd (m_original);
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
scoped_cwd::scoped_cwd ()
|
||||
{
|
||||
m_original.resize (16);
|
||||
while (getcwd (&m_original[0], m_original.size ()) == nullptr && errno == ERANGE)
|
||||
m_original.resize (m_original.size () * 2);
|
||||
errno_error::try_code ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util::set_cwd (const boost::filesystem::path &path) {
|
||||
CHECK (path.string ().size () > 0);
|
||||
|
||||
if (chdir (path.string ().c_str ()) != 0)
|
||||
throw errno_error ();
|
||||
//-----------------------------------------------------------------------------
|
||||
scoped_cwd::~scoped_cwd ()
|
||||
{
|
||||
if (!chdir (m_original.c_str ()))
|
||||
errno_error::throw_code ();
|
||||
}
|
||||
|
4
io.hpp
4
io.hpp
@ -134,12 +134,10 @@ namespace util {
|
||||
~scoped_cwd ();
|
||||
|
||||
protected:
|
||||
boost::filesystem::path m_original;
|
||||
std::string m_original;
|
||||
};
|
||||
|
||||
|
||||
void set_cwd (const boost::filesystem::path &);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
class path_error : public std::runtime_error {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user