2015-09-29 14:29:10 +02:00
|
|
|
#include "ProgramOptions.h"
|
|
|
|
#include <cstring>
|
|
|
|
#include <messmer/cpp-utils/assert/assert.h>
|
|
|
|
|
|
|
|
using namespace cryfs::program_options;
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
2015-10-17 18:31:17 +02:00
|
|
|
using boost::optional;
|
2015-09-29 14:29:10 +02:00
|
|
|
|
2015-10-24 19:56:05 +02:00
|
|
|
ProgramOptions::ProgramOptions(const string &baseDir, const string &mountDir, const optional<string> &configFile,
|
2015-11-12 20:43:11 +01:00
|
|
|
bool foreground, const optional<unsigned int> &unmountAfterIdleMinutes,
|
|
|
|
const optional<string> &logFile, const optional<string> &cipher,
|
2015-11-03 21:22:35 +01:00
|
|
|
const optional<string> &extPass, const vector<char*> &fuseOptions)
|
2015-10-17 18:31:17 +02:00
|
|
|
:_baseDir(baseDir), _mountDir(new char[mountDir.size()+1]), _configFile(configFile), _foreground(foreground),
|
2015-11-12 20:43:11 +01:00
|
|
|
_cipher(cipher), _unmountAfterIdleMinutes(unmountAfterIdleMinutes), _logFile(logFile), _extPass(extPass),
|
|
|
|
_fuseOptions(fuseOptions) {
|
2015-09-29 14:29:10 +02:00
|
|
|
std::memcpy(_mountDir, mountDir.c_str(), mountDir.size()+1);
|
|
|
|
// Fuse needs the mountDir passed as first option (first option = position 1, since 0 is the executable name)
|
|
|
|
ASSERT(_fuseOptions.size() >= 1, "There has to be one parameter at least for the executable name");
|
|
|
|
_fuseOptions.insert(_fuseOptions.begin()+1, _mountDir);
|
|
|
|
}
|
|
|
|
|
2015-10-17 21:33:41 +02:00
|
|
|
ProgramOptions::ProgramOptions(ProgramOptions &&rhs)
|
|
|
|
:_baseDir(std::move(rhs._baseDir)), _mountDir(std::move(rhs._mountDir)), _configFile(std::move(rhs._configFile)),
|
2015-11-12 20:43:11 +01:00
|
|
|
_foreground(std::move(rhs._foreground)), _cipher(std::move(rhs._cipher)),
|
|
|
|
_unmountAfterIdleMinutes(std::move(rhs._unmountAfterIdleMinutes)), _logFile(std::move(rhs._logFile)),
|
2015-11-03 21:22:35 +01:00
|
|
|
_extPass(std::move(rhs._extPass)), _fuseOptions(std::move(rhs._fuseOptions)) {
|
2015-10-17 21:33:41 +02:00
|
|
|
rhs._mountDir = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-09-29 14:29:10 +02:00
|
|
|
ProgramOptions::~ProgramOptions() {
|
2015-10-17 21:33:41 +02:00
|
|
|
if (_mountDir != nullptr) {
|
|
|
|
delete[] _mountDir;
|
|
|
|
}
|
2015-09-29 14:29:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const string &ProgramOptions::baseDir() const {
|
|
|
|
return _baseDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
string ProgramOptions::mountDir() const {
|
|
|
|
return string(_mountDir);
|
|
|
|
}
|
|
|
|
|
2015-10-24 19:56:05 +02:00
|
|
|
const optional<string> &ProgramOptions::configFile() const {
|
2015-09-29 14:39:10 +02:00
|
|
|
return _configFile;
|
|
|
|
}
|
|
|
|
|
2015-10-15 03:38:44 +02:00
|
|
|
bool ProgramOptions::foreground() const {
|
|
|
|
return _foreground;
|
|
|
|
}
|
|
|
|
|
2015-11-12 20:43:11 +01:00
|
|
|
const optional<unsigned int> &ProgramOptions::unmountAfterIdleMinutes() const {
|
|
|
|
return _unmountAfterIdleMinutes;
|
|
|
|
}
|
|
|
|
|
2015-10-24 19:56:05 +02:00
|
|
|
const optional<string> &ProgramOptions::logFile() const {
|
2015-10-17 18:31:17 +02:00
|
|
|
return _logFile;
|
|
|
|
}
|
|
|
|
|
2015-10-30 19:53:15 +01:00
|
|
|
const optional<string> &ProgramOptions::cipher() const {
|
|
|
|
return _cipher;
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:22:35 +01:00
|
|
|
const optional<string> &ProgramOptions::extPass() const {
|
|
|
|
return _extPass;
|
|
|
|
}
|
|
|
|
|
2015-09-29 14:29:10 +02:00
|
|
|
const vector<char *> &ProgramOptions::fuseOptions() const {
|
|
|
|
return _fuseOptions;
|
|
|
|
}
|