Browse Source

TransientDirectory

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
c12aa4decd
  1. 4
      libtestutils/BlockChainLoader.h
  2. 8
      libtestutils/TransientDirectory.cpp
  3. 8
      libtestutils/TransientDirectory.h

4
libtestutils/BlockChainLoader.h

@ -24,7 +24,7 @@
#include <json/json.h> #include <json/json.h>
#include <libethereum/BlockChain.h> #include <libethereum/BlockChain.h>
#include <libethereum/State.h> #include <libethereum/State.h>
#include "ShortLivingDirectory.h" #include "TransientDirectory.h"
namespace dev namespace dev
{ {
@ -43,7 +43,7 @@ public:
eth::State const& state() const { return m_state; } eth::State const& state() const { return m_state; }
private: private:
ShortLivingDirectory m_dir; TransientDirectory m_dir;
std::auto_ptr<eth::BlockChain> m_bc; std::auto_ptr<eth::BlockChain> m_bc;
eth::State m_state; eth::State m_state;
}; };

8
libtestutils/ShortLivingDirectory.cpp → libtestutils/TransientDirectory.cpp

@ -14,20 +14,20 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file ShortLivingDirectory.cpp /** @file TransientDirectory.cpp
* @author Marek Kotewicz <marek@ethdev.com> * @author Marek Kotewicz <marek@ethdev.com>
* @date 2015 * @date 2015
*/ */
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <libdevcore/Exceptions.h> #include <libdevcore/Exceptions.h>
#include "ShortLivingDirectory.h" #include "TransientDirectory.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::test; using namespace dev::test;
ShortLivingDirectory::ShortLivingDirectory(std::string const& _path) : m_path(_path) TransientDirectory::TransientDirectory(std::string const& _path) : m_path(_path)
{ {
// we never ever want to delete a directory (including all its contents) that we did not create ourselves. // we never ever want to delete a directory (including all its contents) that we did not create ourselves.
if (boost::filesystem::exists(m_path)) if (boost::filesystem::exists(m_path))
@ -36,7 +36,7 @@ ShortLivingDirectory::ShortLivingDirectory(std::string const& _path) : m_path(_p
boost::filesystem::create_directories(m_path); boost::filesystem::create_directories(m_path);
} }
ShortLivingDirectory::~ShortLivingDirectory() TransientDirectory::~TransientDirectory()
{ {
boost::filesystem::remove_all(m_path); boost::filesystem::remove_all(m_path);
} }

8
libtestutils/ShortLivingDirectory.h → libtestutils/TransientDirectory.h

@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file ShortLivingDirectory.h /** @file TransientDirectory.h
* @author Marek Kotewicz <marek@ethdev.com> * @author Marek Kotewicz <marek@ethdev.com>
* @date 2015 * @date 2015
*/ */
@ -34,11 +34,11 @@ namespace test
* It creates temporary directory in the given path. On dealloc it removes the directory * It creates temporary directory in the given path. On dealloc it removes the directory
* @throws if the given path already exists, throws an exception * @throws if the given path already exists, throws an exception
*/ */
class ShortLivingDirectory class TransientDirectory
{ {
public: public:
ShortLivingDirectory(std::string const& _path = getRandomPath()); TransientDirectory(std::string const& _path = getRandomPath());
~ShortLivingDirectory(); ~TransientDirectory();
std::string const& path() const { return m_path; } std::string const& path() const { return m_path; }
Loading…
Cancel
Save