1 | var chai = require('chai');
|
2 |
|
3 |
|
4 |
|
5 | chai.Assertion.includeStack = true;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | exports.assert = chai.assert;
|
13 |
|
14 |
|
15 | var constants = process.binding('constants');
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | exports.flags = function(str) {
|
24 | switch (str) {
|
25 | case 'r' :
|
26 | return constants.O_RDONLY;
|
27 | case 'rs' :
|
28 | return constants.O_RDONLY | constants.O_SYNC;
|
29 | case 'r+' :
|
30 | return constants.O_RDWR;
|
31 | case 'rs+' :
|
32 | return constants.O_RDWR | constants.O_SYNC;
|
33 |
|
34 | case 'w' :
|
35 | return constants.O_TRUNC | constants.O_CREAT | constants.O_WRONLY;
|
36 | case 'wx' :
|
37 | case 'xw' :
|
38 | return constants.O_TRUNC | constants.O_CREAT | constants.O_WRONLY |
|
39 | constants.O_EXCL;
|
40 |
|
41 | case 'w+' :
|
42 | return constants.O_TRUNC | constants.O_CREAT | constants.O_RDWR;
|
43 | case 'wx+':
|
44 | case 'xw+':
|
45 | return constants.O_TRUNC | constants.O_CREAT | constants.O_RDWR |
|
46 | constants.O_EXCL;
|
47 |
|
48 | case 'a' :
|
49 | return constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY;
|
50 | case 'ax' :
|
51 | case 'xa' :
|
52 | return constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY |
|
53 | constants.O_EXCL;
|
54 |
|
55 | case 'a+' :
|
56 | return constants.O_APPEND | constants.O_CREAT | constants.O_RDWR;
|
57 | case 'ax+':
|
58 | case 'xa+':
|
59 | return constants.O_APPEND | constants.O_CREAT | constants.O_RDWR |
|
60 | constants.O_EXCL;
|
61 | }
|
62 | };
|