חזור לתיקייה: actions

CreateAction

חיפוש בתיקיה
Ctrl K
לחץ כאן או הקש Ctrl K כדי לחפש בכל התיקיה

    CreateAction

    02340124

    מבוא לתכנות מערכות

    רשימות הרצאה לקריאה בשבת

    CreateAction

    הופק מתוך תקיית התואר של שקד

    uni-folder.vercel.app

    createaction.cpp

    הערה (קובץ קוד)

    קובץ זה הוא קובץ קוד מסוג 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);
    }