@@ -3,6 +3,7 @@ var events = require('events');
33var Buffer = require ( 'buffer' ) . Buffer ;
44
55var binding = process . binding ( 'fs' ) ;
6+ var constants = process . binding ( 'constants' ) ;
67var fs = exports ;
78
89var kMinPoolSpace = 128 ;
@@ -11,35 +12,35 @@ var kPoolSize = 40 * 1024;
1112fs . Stats = binding . Stats ;
1213
1314fs . Stats . prototype . _checkModeProperty = function ( property ) {
14- return ( ( this . mode & process . S_IFMT ) === property ) ;
15+ return ( ( this . mode & constants . S_IFMT ) === property ) ;
1516} ;
1617
1718fs . Stats . prototype . isDirectory = function ( ) {
18- return this . _checkModeProperty ( process . S_IFDIR ) ;
19+ return this . _checkModeProperty ( constants . S_IFDIR ) ;
1920} ;
2021
2122fs . Stats . prototype . isFile = function ( ) {
22- return this . _checkModeProperty ( process . S_IFREG ) ;
23+ return this . _checkModeProperty ( constants . S_IFREG ) ;
2324} ;
2425
2526fs . Stats . prototype . isBlockDevice = function ( ) {
26- return this . _checkModeProperty ( process . S_IFBLK ) ;
27+ return this . _checkModeProperty ( constants . S_IFBLK ) ;
2728} ;
2829
2930fs . Stats . prototype . isCharacterDevice = function ( ) {
30- return this . _checkModeProperty ( process . S_IFCHR ) ;
31+ return this . _checkModeProperty ( constants . S_IFCHR ) ;
3132} ;
3233
3334fs . Stats . prototype . isSymbolicLink = function ( ) {
34- return this . _checkModeProperty ( process . S_IFLNK ) ;
35+ return this . _checkModeProperty ( constants . S_IFLNK ) ;
3536} ;
3637
3738fs . Stats . prototype . isFIFO = function ( ) {
38- return this . _checkModeProperty ( process . S_IFIFO ) ;
39+ return this . _checkModeProperty ( constants . S_IFIFO ) ;
3940} ;
4041
4142fs . Stats . prototype . isSocket = function ( ) {
42- return this . _checkModeProperty ( process . S_IFSOCK ) ;
43+ return this . _checkModeProperty ( constants . S_IFSOCK ) ;
4344} ;
4445
4546fs . readFile = function ( path , encoding_ , callback ) {
@@ -48,7 +49,7 @@ fs.readFile = function (path, encoding_, callback) {
4849 var callback = ( typeof ( callback_ ) == 'function' ? callback_ : noop ) ;
4950 binding . stat ( path , function ( err , stat ) {
5051 if ( err ) { callback ( err ) ; return ; }
51- binding . open ( path , process . O_RDONLY , 0666 , function ( err , fd ) {
52+ binding . open ( path , constants . O_RDONLY , 0666 , function ( err , fd ) {
5253 if ( err ) { callback ( err ) ; return ; }
5354 var size = stat . size ;
5455 var buffer = new Buffer ( size ) ;
@@ -91,7 +92,7 @@ fs.readFile = function (path, encoding_, callback) {
9192} ;
9293
9394fs . readFileSync = function ( path , encoding ) {
94- var fd = fs . openSync ( path , process . O_RDONLY , 0666 ) ;
95+ var fd = fs . openSync ( path , constants . O_RDONLY , 0666 ) ;
9596 var stat = fs . statSync ( path ) ;
9697 var buffer = new Buffer ( stat . size ) ;
9798 var nread = 0 ;
@@ -117,12 +118,12 @@ function stringToFlags(flag) {
117118 return flag ;
118119 }
119120 switch ( flag ) {
120- case "r" : return process . O_RDONLY ;
121- case "r+" : return process . O_RDWR ;
122- case "w" : return process . O_CREAT | process . O_TRUNC | process . O_WRONLY ;
123- case "w+" : return process . O_CREAT | process . O_TRUNC | process . O_RDWR ;
124- case "a" : return process . O_APPEND | process . O_CREAT | process . O_WRONLY ;
125- case "a+" : return process . O_APPEND | process . O_CREAT | process . O_RDWR ;
121+ case "r" : return constants . O_RDONLY ;
122+ case "r+" : return constants . O_RDWR ;
123+ case "w" : return constants . O_CREAT | constants . O_TRUNC | constants . O_WRONLY ;
124+ case "w+" : return constants . O_CREAT | constants . O_TRUNC | constants . O_RDWR ;
125+ case "a" : return constants . O_APPEND | constants . O_CREAT | constants . O_WRONLY ;
126+ case "a+" : return constants . O_APPEND | constants . O_CREAT | constants . O_RDWR ;
126127 default : throw new Error ( "Unknown file open flag: " + flag ) ;
127128 }
128129}
0 commit comments