MCPcopy Create free account
hub / github.com/cucumber/cucumber-cpp / TemporaryFileWrapper

Class TemporaryFileWrapper

src/drivers/QtTestDriver.cpp:15–47  ·  view source on GitHub ↗

* Wraps the QTemporaryFile for Windows. * * On Windows. the file can not be written as long as QTemporaryFile keeps it open. */

Source from the content-addressed store, hash-verified

13 * On Windows. the file can not be written as long as QTemporaryFile keeps it open.
14 */
15class TemporaryFileWrapper {
16public:
17 ~TemporaryFileWrapper() {
18 QFile::remove(filename);
19 }
20
21 bool exists() const {
22 return !filename.isEmpty();
23 }
24
25 QString name() const {
26 return filename;
27 }
28
29 QString read() const {
30 QFile file{filename};
31 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
32 return QString();
33 QTextStream in(&file);
34 return in.readAll();
35 }
36
37private:
38 const QString filename{getTmpFileName()};
39
40 static QString getTmpFileName() {
41 QTemporaryFile tempFile{};
42 if (!tempFile.open()) {
43 return {};
44 }
45 return tempFile.fileName() + ".txt";
46 }
47};
48
49const InvokeResult QtTestStep::invokeStepBody() {
50 const TemporaryFileWrapper file{};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected