File tree 4 files changed +42
-26
lines changed
4 files changed +42
-26
lines changed Original file line number Diff line number Diff line change 24
24
25
25
'use strict' ;
26
26
27
- // Most platforms don't allow reads or writes >= 2 GB.
28
- // See https://github.com./libuv/libuv/pull/1501.
29
- const kIoMaxLength = 2 ** 31 - 1 ;
30
-
31
27
// When using FSReqCallback, make sure to create the object only *after* all
32
28
// parameter validation has happened, so that the objects are not kept in memory
33
29
// in case they are created but never used due to an exception.
@@ -90,6 +86,10 @@ const { FSReqCallback } = binding;
90
86
const { toPathIfFileURL } = require ( 'internal/url' ) ;
91
87
const internalUtil = require ( 'internal/util' ) ;
92
88
const {
89
+ constants : {
90
+ kIoMaxLength,
91
+ kMaxUserId,
92
+ } ,
93
93
copyObject,
94
94
Dirent,
95
95
emitRecursiveRmdirWarning,
@@ -136,8 +136,6 @@ const {
136
136
validateFunction,
137
137
validateInteger,
138
138
} = require ( 'internal/validators' ) ;
139
- // 2 ** 32 - 1
140
- const kMaxUserId = 4294967295 ;
141
139
142
140
let truncateWarn = true ;
143
141
let fs ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- // Most platforms don't allow reads or writes >= 2 GB.
4
- // See https://github.com./libuv/libuv/pull/1501.
5
- const kIoMaxLength = 2 ** 31 - 1 ;
6
-
7
- const kReadFileBufferLength = 512 * 1024 ;
8
- const kReadFileUnknownBufferLength = 64 * 1024 ;
9
- const kWriteFileMaxChunkSize = 512 * 1024 ;
10
-
11
- // 2 ** 32 - 1
12
- const kMaxUserId = 4294967295 ;
13
-
14
3
const {
15
4
ArrayPrototypePush,
16
5
Error,
@@ -48,6 +37,13 @@ const {
48
37
const { isArrayBufferView } = require ( 'internal/util/types' ) ;
49
38
const { rimrafPromises } = require ( 'internal/fs/rimraf' ) ;
50
39
const {
40
+ constants : {
41
+ kIoMaxLength,
42
+ kMaxUserId,
43
+ kReadFileBufferLength,
44
+ kReadFileUnknownBufferLength,
45
+ kWriteFileMaxChunkSize,
46
+ } ,
51
47
copyObject,
52
48
emitRecursiveRmdirWarning,
53
49
getDirents,
Original file line number Diff line number Diff line change 6
6
ReflectApply,
7
7
} = primordials ;
8
8
9
+ const {
10
+ constants : {
11
+ kReadFileBufferLength,
12
+ kReadFileUnknownBufferLength,
13
+ }
14
+ } = require ( 'internal/fs/utils' ) ;
15
+
9
16
const { Buffer } = require ( 'buffer' ) ;
10
17
11
18
const { FSReqCallback, close, read } = internalBinding ( 'fs' ) ;
@@ -15,15 +22,6 @@ const {
15
22
aggregateTwoErrors,
16
23
} = require ( 'internal/errors' ) ;
17
24
18
- // Use 64kb in case the file type is not a regular file and thus do not know the
19
- // actual file size. Increasing the value further results in more frequent over
20
- // allocation for small files and consumes CPU time and memory that should be
21
- // used else wise.
22
- // Use up to 512kb per read otherwise to partition reading big files to prevent
23
- // blocking other threads in case the available threads are all in use.
24
- const kReadFileUnknownBufferLength = 64 * 1024 ;
25
- const kReadFileBufferLength = 512 * 1024 ;
26
-
27
25
function readFileAfterRead ( err , bytesRead ) {
28
26
const context = this . context ;
29
27
Original file line number Diff line number Diff line change @@ -120,6 +120,23 @@ const kMaximumCopyMode = COPYFILE_EXCL |
120
120
COPYFILE_FICLONE |
121
121
COPYFILE_FICLONE_FORCE ;
122
122
123
+ // Most platforms don't allow reads or writes >= 2 GB.
124
+ // See https://github.com./libuv/libuv/pull/1501.
125
+ const kIoMaxLength = 2 ** 31 - 1 ;
126
+
127
+ // Use 64kb in case the file type is not a regular file and thus do not know the
128
+ // actual file size. Increasing the value further results in more frequent over
129
+ // allocation for small files and consumes CPU time and memory that should be
130
+ // used else wise.
131
+ // Use up to 512kb per read otherwise to partition reading big files to prevent
132
+ // blocking other threads in case the available threads are all in use.
133
+ const kReadFileUnknownBufferLength = 64 * 1024 ;
134
+ const kReadFileBufferLength = 512 * 1024 ;
135
+
136
+ const kWriteFileMaxChunkSize = 512 * 1024 ;
137
+
138
+ const kMaxUserId = 2 ** 32 - 1 ;
139
+
123
140
const isWindows = process . platform === 'win32' ;
124
141
125
142
let fs ;
@@ -843,6 +860,13 @@ const validatePosition = hideStackFrames((position, name) => {
843
860
} ) ;
844
861
845
862
module . exports = {
863
+ constants : {
864
+ kIoMaxLength,
865
+ kMaxUserId,
866
+ kReadFileBufferLength,
867
+ kReadFileUnknownBufferLength,
868
+ kWriteFileMaxChunkSize,
869
+ } ,
846
870
assertEncoding,
847
871
BigIntStats, // for testing
848
872
copyObject,
You can’t perform that action at this time.
0 commit comments