
/*---------------------------------------------------------------------------*/
/* tasks_file.h                                                              */
/* copyright (c) innovaphone 2016 - 2026                                     */
/*                                                                           */
/*---------------------------------------------------------------------------*/

class TaskFileWrite : public STask {
    void SStart();

    char * workingPath;
    char * fileName;
    bool append;
    class IFileWrite * file;
    byte * buffer;
    unsigned length;
    bool last;

public:
    TaskFileWrite(class STaskContext * context, const char * workingPath, const char * fileName, bool append);
    ~TaskFileWrite();

    void write(byte * buffer, unsigned length, bool last);
    void writeBuffer(byte * buffer, unsigned length, bool last);
};

class TaskFileRead : public STask {
    void SStart();

    char * workingPath;
    char * fileName;
    class IFileRead * file;
    byte * buffer;
    unsigned length;
    bool last;
public:
    TaskFileRead(class STaskContext * context, const char * workingPath, const char * fileName, unsigned length, bool last);
    ~TaskFileRead();

    void read(unsigned length, bool last);
    unsigned getLength() { return length; };
    void getData(byte * buffer, unsigned length) { memcpy(buffer, this->buffer, length); };
};

class TaskDirectoryMonitor : public STask {
private:
    void SStart();

    class IInstanceLog * log = 0;
    char * workingPath;
    class IDirectoryMonitor * directoryMonitor;
public:
    TaskDirectoryMonitor(class STaskContext * context, const char * workingPath, class IInstanceLog * log);
    ~TaskDirectoryMonitor();

    void Monitor();
    const char * ChangedFile();
    void Stop() override;
};
