blob: 44c1427458e047e1334fc5afb8e605355fc0861c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import qbs
import qbs.TextFile
Product {
type: ["dummy"]
Rule {
multiplex: true
outputFileTags: "dummy"
prepare: {
var commands = [];
var cmd = new JavaScriptCommand();
cmd.silent = true;
cmd.sourceCode = function() {
var file1 = new TextFile("file1.txt", TextFile.WriteOnly);
file1.write("First line.\n");
// Do not close the file to test the auto close functionality.
};
commands.push(cmd);
cmd = new JavaScriptCommand();
cmd.silent = true;
cmd.sourceCode = function() {
var file1 = new TextFile("file1.txt", TextFile.WriteOnly | TextFile.Append);
file1.write("Second line.\nThird line.");
file1.close();
file1 = new TextFile("file1.txt", TextFile.ReadWrite);
var file2 = new TextFile("file2.txt", TextFile.WriteOnly);
file2.writeLine(file1.atEof());
while (true) {
var line = file1.readLine();
if (!line || line.length == 0)
break;
file2.writeLine(line);
}
file1.truncate();
file2.writeLine(file1.filePath());
file2.writeLine(file1.atEof());
file1.close();
file2.close();
};
commands.push(cmd);
return commands;
}
}
}
|