~george-edison55/twistload/trunk

« back to all changes in this revision

Viewing changes to src/fs/file.cpp

  • Committer: Nathan Osman
  • Date: 2017-07-20 19:01:04 UTC
  • Revision ID: git-v1:f6404b4fb7bc534c1c108af8860fb8f7593f0b69
Add a couple of methods to File class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "allocationtask.h"
28
28
#include "file.h"
29
29
 
 
30
File::File()
 
31
    : mTask(nullptr)
 
32
{
 
33
}
 
34
 
30
35
File::File(const QString &filename)
31
36
    : mTask(nullptr),
32
37
      mFile(filename)
41
46
    }
42
47
}
43
48
 
 
49
QString File::filename() const
 
50
{
 
51
    return mFile.fileName();
 
52
}
 
53
 
 
54
void File::setFilename(const QString &filename)
 
55
{
 
56
    mFile.setFileName(filename);
 
57
}
 
58
 
44
59
void File::open(qint64 size)
45
60
{
46
61
    if (size) {
50
65
        mTask->moveToThread(&mThread);
51
66
 
52
67
        // Ensure the task and thread are destroyed when complete
 
68
        connect(mTask, &AllocationTask::error, this, &File::error);
53
69
        connect(mTask, &AllocationTask::progress, this, &File::allocationProgress);
54
 
        connect(mTask, &AllocationTask::error, this, &File::allocationError);
55
70
        connect(mTask, &AllocationTask::succeeded, this, &File::onSucceeded);
56
71
        connect(mTask, &AllocationTask::finished, this, [=]() {
57
72
            mTask->deleteLater();