הערה (קובץ קוד)
קובץ זה הוא קובץ קוד מסוג CPP.
#include "CreateAction.h"
#include "SymbolicLink.h"
#include "TextFile.h"
#include "Utilities.h"
CreateAction::CreateAction(const std::string& name, const std::string& type,
const std::vector<std::string>& pathVector, Directory& directory)
: Action(), name(name), type(type), pathVector(pathVector),
parent(directory)
{ }
void CreateAction::execute() const {
std::shared_ptr<File> file;
if (type == "textfile") {
file = std::make_shared<TextFile>(name, &parent);
} else if (type == "directory") {
file = std::make_shared<Directory>(name, &parent);
} else if (type == "symlink") {
file = std::make_shared<SymbolicLink>(name, &parent, pathVector);
} else {
throw std::runtime_error(Utilities::TypeErrorMsg());
}
parent.addFile(file);
}