1 | var fs = require('fs');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | function PDFWStreamForFile(inPath)
|
8 | {
|
9 | this.ws = fs.createWriteStream(inPath);
|
10 | this.position = 0;
|
11 | this.path = inPath;
|
12 | }
|
13 |
|
14 | PDFWStreamForFile.prototype.write = function(inBytesArray)
|
15 | {
|
16 | if(inBytesArray.length > 0)
|
17 | {
|
18 | this.ws.write(new Buffer(inBytesArray));
|
19 | this.position+=inBytesArray.length;
|
20 | return inBytesArray.length;
|
21 | }
|
22 | else
|
23 | return 0;
|
24 | };
|
25 |
|
26 | PDFWStreamForFile.prototype.getCurrentPosition = function()
|
27 | {
|
28 | return this.position;
|
29 | };
|
30 |
|
31 | PDFWStreamForFile.prototype.close = function(inCallback)
|
32 | {
|
33 | if(this.ws)
|
34 | {
|
35 | var self = this;
|
36 |
|
37 | this.ws.end(function()
|
38 | {
|
39 | self.ws = null;
|
40 | if(inCallback)
|
41 | inCallback();
|
42 | })
|
43 | }
|
44 | else
|
45 | {
|
46 | if(inCallback)
|
47 | inCallback();
|
48 | }
|
49 | };
|
50 |
|
51 | module.exports = PDFWStreamForFile; |
\ | No newline at end of file |