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

ReadAction

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

    ReadAction

    02340124

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

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

    ReadAction

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

    uni-folder.vercel.app

    readaction.cpp

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

    קובץ זה הוא קובץ קוד מסוג CPP.

    #include "ReadAction.h"
    
    #include "Utilities.h"
    
    ReadAction::ReadAction(const std::string& hostPath, const std::vector<std::string>& text, bool isCout)
        : Action(), hostPath(hostPath), lines(text), isCout(isCout) {
    }
    
    void ReadAction::execute() const {
        if (isCout) {
            Utilities::printFileContent(lines);
            return;
        }
        std::ofstream outputStream(hostPath);
        if (!outputStream.is_open()) {
            throw std::runtime_error(Utilities::HostFileErrorMsg());
        }
        Utilities::writeLinesToStream(outputStream, lines);
    }