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);
|
m_owner->rdbuf (m_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
scoped_cwd::scoped_cwd ():
|
scoped_cwd::scoped_cwd ()
|
||||||
m_original(boost::filesystem::canonical (getcwd (nullptr, 0)))
|
{
|
||||||
{ ; }
|
m_original.resize (16);
|
||||||
|
while (getcwd (&m_original[0], m_original.size ()) == nullptr && errno == ERANGE)
|
||||||
|
m_original.resize (m_original.size () * 2);
|
||||||
scoped_cwd::~scoped_cwd () {
|
errno_error::try_code ();
|
||||||
set_cwd (m_original);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
//-----------------------------------------------------------------------------
|
||||||
util::set_cwd (const boost::filesystem::path &path) {
|
scoped_cwd::~scoped_cwd ()
|
||||||
CHECK (path.string ().size () > 0);
|
{
|
||||||
|
if (!chdir (m_original.c_str ()))
|
||||||
if (chdir (path.string ().c_str ()) != 0)
|
errno_error::throw_code ();
|
||||||
throw errno_error ();
|
|
||||||
}
|
}
|
||||||
|
4
io.hpp
4
io.hpp
@ -134,12 +134,10 @@ namespace util {
|
|||||||
~scoped_cwd ();
|
~scoped_cwd ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
boost::filesystem::path m_original;
|
std::string m_original;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void set_cwd (const boost::filesystem::path &);
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
class path_error : public std::runtime_error {
|
class path_error : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user