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