////////////////////////////////////////////////////////////////////////////////
// BGProcess.h
// Copyright Bjoern Ganster
////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "BGBase.h"
#include "BGCPString.h"

#include <memory>

class BGProcess FINAL: public VirtualClass {
public:
	// Constructor
	BGProcess();

	// Destructor
	~BGProcess() OVERRIDE
	{
	}

	// Run command cmd, with dir as working directory
	// Returns true if the process was started successfully
	// This call returns only when the external process finishes
	bool run(const BGCPString& dir, const BGCPString& cmd);

	// Get error message from running the external process
	const BGCPString& getErrors() const
	{
		return mErrors;
	}

	DWORD getExitCode() const
	{
		return mExitCode;
	}

private:
	std::unique_ptr<wchar_t> mCmdLine;
	BGCPString mErrors;
	DWORD mExitCode;
};
