FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/node_file.cc at master · waveto/node · GitHub
waveto
/
node
Public
forked from
nodejs/node-v0.x-archive
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
src
/
node_file.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
659 lines (535 loc) · 17 KB
Breadcrumbs
node
/
src
/
node_file.cc
Copy path
File metadata and controls
659 lines (535 loc) · 17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
//
Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
#
include
<
node_file.h
>
#
include
<
node_buffer.h
>
#
include
<
sys/types.h
>
#
include
<
sys/stat.h
>
#
include
<
dirent.h
>
#
include
<
fcntl.h
>
#
include
<
stdlib.h
>
#
include
<
unistd.h
>
#
include
<
assert.h
>
#
include
<
string.h
>
#
include
<
errno.h
>
#
include
<
limits.h
>
/*
used for readlink, AIX doesn't provide it
*/
#
ifndef
PATH_MAX
#
define
PATH_MAX
4096
#
endif
namespace
node
{
using
namespace
v8
;
#
define
MIN
(
a,b
) ((a) < (b) ? (a) : (b))
#
define
THROW_BAD_ARGS
\
ThrowException
(Exception::TypeError(String::New(
"
Bad argument
"
)))
static
Persistent<String> encoding_symbol;
static
Persistent<String> errno_symbol;
static
inline
Local<Value>
errno_exception
(
int
errorno) {
Local<Value> e =
Exception::Error
(
String::NewSymbol
(
strerror
(errorno)));
Local<Object> obj = e->
ToObject
();
obj->
Set
(errno_symbol,
Integer::New
(errorno));
return
e;
}
static
int
After
(eio_req *req) {
HandleScope scope;
Persistent<Function> *callback =
cb_unwrap
(req->
data
);
ev_unref
(
EV_DEFAULT_UC
);
int
argc =
0
;
Local<Value> argv[
6
];
//
6 is the maximum number of args
if
(req->
errorno
!=
0
) {
argc =
1
;
argv[
0
] =
errno_exception
(req->
errorno
);
}
else
{
//
Note: the error is always given the first argument of the callback.
//
If there is no error then then the first argument is null.
argv[
0
] = Local<Value>::
New
(
Null
());
switch
(req->
type
) {
case
EIO_CLOSE
:
case
EIO_RENAME
:
case
EIO_UNLINK
:
case
EIO_RMDIR
:
case
EIO_MKDIR
:
case
EIO_FTRUNCATE
:
case
EIO_LINK
:
case
EIO_SYMLINK
:
case
EIO_CHMOD
:
argc =
0
;
break
;
case
EIO_OPEN
:
case
EIO_SENDFILE
:
argc =
2
;
argv[
1
] =
Integer::New
(req->
result
);
break
;
case
EIO_WRITE
:
argc =
2
;
argv[
1
] =
Integer::New
(req->
result
);
break
;
case
EIO_STAT
:
case
EIO_LSTAT
:
{
struct
stat
*s =
reinterpret_cast
<
struct
stat
*>(req->
ptr2
);
argc =
2
;
argv[
1
] =
BuildStatsObject
(s);
break
;
}
case
EIO_READLINK
:
{
argc =
2
;
argv[
1
] =
String::New
(
static_cast
<
char
*>(req->
ptr2
), req->
result
);
break
;
}
case
EIO_READ
:
{
argc =
3
;
Local<Object> obj = Local<Object>::
New
(*callback);
Local<Value> enc_val = obj->
GetHiddenValue
(encoding_symbol);
argv[
1
] =
Encode
(req->
ptr2
, req->
result
,
ParseEncoding
(enc_val));
argv[
2
] =
Integer::New
(req->
result
);
break
;
}
case
EIO_READDIR
:
{
char
*namebuf =
static_cast
<
char
*>(req->
ptr2
);
int
nnames = req->
result
;
Local<Array> names =
Array::New
(nnames);
for
(
int
i =
0
; i < nnames; i++) {
Local<String> name =
String::New
(namebuf);
names->
Set
(
Integer::New
(i), name);
#
ifndef
NDEBUG
namebuf +=
strlen
(namebuf);
assert
(*namebuf ==
'
\0
'
);
namebuf +=
1
;
#
else
namebuf +=
strlen
(namebuf) +
1
;
#
endif
}
argc =
2
;
argv[
1
] = names;
break
;
}
default
:
assert
(
0
&&
"
Unhandled eio response
"
);
}
}
if
(req->
type
==
EIO_WRITE
&& req->
int3
==
1
) {
assert
(req->
ptr2
);
delete []
reinterpret_cast
<
char
*>(req->
ptr2
);
}
TryCatch try_catch;
(*callback)->
Call
(
Context::GetCurrent
()->
Global
(), argc, argv);
if
(try_catch.
HasCaught
()) {
FatalException
(try_catch);
}
//
Dispose of the persistent handle
cb_destroy
(callback);
return
0
;
}
#
define
ASYNC_CALL
(func, callback, ...) \
eio_req *req = eio_##func(__VA_ARGS__,
EIO_PRI_DEFAULT
, After, \
cb_persist
(callback)); \
assert
(req); \
ev_ref
(
EV_DEFAULT_UC
); \
return
Undefined();
static
Handle<Value>
Close
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
int
fd = args[
0
]->
Int32Value
();
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(close, args[
1
], fd)
}
else
{
int
ret =
close
(fd);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
Stat
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(stat, args[
1
], *path)
}
else
{
struct
stat
s;
int
ret =
stat
(*path, &s);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
scope.
Close
(
BuildStatsObject
(&s));
}
}
static
Handle<Value>
LStat
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(lstat, args[
1
], *path)
}
else
{
struct
stat
s;
int
ret =
lstat
(*path, &s);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
scope.
Close
(
BuildStatsObject
(&s));
}
}
static
Handle<Value>
Symlink
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsString
() || !args[
1
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
dest
(args[
0
]->
ToString
());
String::Utf8Value
path
(args[
1
]->
ToString
());
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(symlink, args[
2
], *dest, *path)
}
else
{
int
ret =
symlink
(*dest, *path);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
Link
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsString
() || !args[
1
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
orig_path
(args[
0
]->
ToString
());
String::Utf8Value
new_path
(args[
1
]->
ToString
());
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(link, args[
2
], *orig_path, *new_path)
}
else
{
int
ret =
link
(*orig_path, *new_path);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
ReadLink
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(readlink, args[
1
], *path)
}
else
{
char
buf[
PATH_MAX
];
ssize_t
bz =
readlink
(*path, buf,
PATH_MAX
);
if
(bz == -
1
)
return
ThrowException
(
errno_exception
(errno));
return
scope.
Close
(
String::New
(buf, bz));
}
}
static
Handle<Value>
Rename
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsString
() || !args[
1
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
old_path
(args[
0
]->
ToString
());
String::Utf8Value
new_path
(args[
1
]->
ToString
());
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(rename, args[
2
], *old_path, *new_path)
}
else
{
int
ret =
rename
(*old_path, *new_path);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
Truncate
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
int
fd = args[
0
]->
Int32Value
();
off_t
len = args[
1
]->
Uint32Value
();
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(ftruncate, args[
2
], fd, len)
}
else
{
int
ret =
ftruncate
(fd, len);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
Unlink
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(unlink, args[
1
], *path)
}
else
{
int
ret =
unlink
(*path);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
RMDir
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(rmdir, args[
1
], *path)
}
else
{
int
ret =
rmdir
(*path);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
MKDir
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsString
() || !args[
1
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
mode_t
mode =
static_cast
<
mode_t
>(args[
1
]->
Int32Value
());
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(mkdir, args[
2
], *path, mode)
}
else
{
int
ret =
mkdir
(*path, mode);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
static
Handle<Value>
SendFile
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
4
||
!args[
0
]->
IsInt32
() ||
!args[
1
]->
IsInt32
() ||
!args[
3
]->
IsNumber
()) {
return
THROW_BAD_ARGS
;
}
int
out_fd = args[
0
]->
Int32Value
();
int
in_fd = args[
1
]->
Int32Value
();
off_t
in_offset = args[
2
]->
IsNumber
() ? args[
2
]->
IntegerValue
() : -
1
;
size_t
length = args[
3
]->
IntegerValue
();
if
(args[
4
]->
IsFunction
()) {
ASYNC_CALL
(sendfile, args[
4
], out_fd, in_fd, in_offset, length)
}
else
{
ssize_t
sent =
eio_sendfile_sync
(out_fd, in_fd, in_offset, length);
//
XXX is this the right errno to use?
if
(sent <
0
)
return
ThrowException
(
errno_exception
(errno));
return
Integer::New
(sent);
}
}
static
Handle<Value>
ReadDir
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
1
|| !args[
0
]->
IsString
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
if
(args[
1
]->
IsFunction
()) {
ASYNC_CALL
(readdir, args[
1
], *path,
0
/*
flags
*/
)
}
else
{
DIR
*dir =
opendir
(*path);
if
(!dir)
return
ThrowException
(
errno_exception
(errno));
struct
dirent
*ent;
Local<Array> files =
Array::New
();
char
*name;
int
i =
0
;
while
(ent =
readdir
(dir)) {
name = ent->
d_name
;
if
(name[
0
] !=
'
.
'
|| (name[
1
] && (name[
1
] !=
'
.
'
|| name[
2
]))) {
files->
Set
(
Integer::New
(i),
String::New
(name));
i++;
}
}
closedir
(dir);
return
scope.
Close
(files);
}
}
static
Handle<Value>
Open
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
3
||
!args[
0
]->
IsString
() ||
!args[
1
]->
IsInt32
() ||
!args[
2
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
int
flags = args[
1
]->
Int32Value
();
mode_t
mode =
static_cast
<
mode_t
>(args[
2
]->
Int32Value
());
if
(args[
3
]->
IsFunction
()) {
ASYNC_CALL
(open, args[
3
], *path, flags, mode)
}
else
{
int
fd =
open
(*path, flags, mode);
if
(fd <
0
)
return
ThrowException
(
errno_exception
(errno));
return
scope.
Close
(
Integer::New
(fd));
}
}
//
write(fd, data, position, enc, callback)
//
Wrapper for write(2).
//
//
0 fd integer. file descriptor
//
1 buffer the data to write
//
2 offset where in the buffer to start from
//
3 length how much to write
//
4 position if integer, position to write at in the file.
//
if null, write from the current position
//
//
- OR -
//
//
0 fd integer. file descriptor
//
1 string the data to write
//
2 position if integer, position to write at in the file.
//
if null, write from the current position
//
3 encoding
static
Handle<Value>
Write
(
const
Arguments& args) {
HandleScope scope;
if
(!args[
0
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
int
fd = args[
0
]->
Int32Value
();
off_t
pos;
ssize_t
len;
char
* buf;
ssize_t
written;
Local<Value> cb;
bool
legacy;
if
(
Buffer::HasInstance
(args[
1
])) {
legacy =
false
;
//
buffer
//
//
0 fd integer. file descriptor
//
1 buffer the data to write
//
2 offset where in the buffer to start from
//
3 length how much to write
//
4 position if integer, position to write at in the file.
//
if null, write from the current position
Buffer * buffer = ObjectWrap::Unwrap<Buffer>(args[
1
]->
ToObject
());
size_t
off = args[
2
]->
Int32Value
();
if
(off >= buffer->
length
()) {
return
ThrowException
(
Exception::Error
(
String::New
(
"
Offset is out of bounds
"
)));
}
len = args[
3
]->
Int32Value
();
if
(off + len > buffer->
length
()) {
return
ThrowException
(
Exception::Error
(
String::New
(
"
Length is extends beyond buffer
"
)));
}
pos = args[
4
]->
IsNumber
() ? args[
4
]->
IntegerValue
() : -
1
;
buf = (
char
*)buffer->
data
() + off;
cb = args[
5
];
}
else
{
legacy =
true
;
//
legacy interface.. args[1] is a string
pos = args[
2
]->
IsNumber
() ? args[
2
]->
IntegerValue
() : -
1
;
enum
encoding enc =
ParseEncoding
(args[
3
]);
len =
DecodeBytes
(args[
1
], enc);
if
(len <
0
) {
Local<Value> exception =
Exception::TypeError
(
String::New
(
"
Bad argument
"
));
return
ThrowException
(exception);
}
buf =
new
char
[len];
written =
DecodeWrite
(buf, len, args[
1
], enc);
assert
(written == len);
cb = args[
4
];
}
if
(cb->
IsFunction
()) {
//
WARNING: HACK AHEAD, PROCEED WITH CAUTION
//
Normally here I would do
//
ASYNC_CALL(write, cb, fd, buf, len, pos)
//
however, I'm trying to support a legacy interface; where in the
//
String version a buffer is allocated to encode into. In the After()
//
function it is freed. However in the other version, we just increase
//
the reference count to a buffer. We have to let After() know which
//
version is being done so it can know if it needs to free 'buf' or
//
not. We do that by using req->int3.
//
req->int3 == 1 legacy, String version. Need to free `buf`.
//
req->int3 == 0 Buffer version. Don't do anything.
eio_req *req =
eio_write
(fd, buf, len, pos,
EIO_PRI_DEFAULT
,
After,
cb_persist
(cb));
assert
(req);
req->
int3
= legacy ?
1
:
0
;
ev_ref
(
EV_DEFAULT_UC
);
return
Undefined
();
}
else
{
if
(pos <
0
) {
written =
write
(fd, buf, len);
}
else
{
written =
pwrite
(fd, buf, len, pos);
}
if
(written <
0
)
return
ThrowException
(
errno_exception
(errno));
return
scope.
Close
(
Integer::New
(written));
}
}
/*
node.fs.read(fd, length, position, encoding)
* Wrapper for read(2).
*
* 0 fd integer. file descriptor
* 1 length integer. length to read
* 2 position if integer, position to read from in the file.
* if null, read from the current position
* 3 encoding
*/
static
Handle<Value>
Read
(
const
Arguments& args) {
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsInt32
() || !args[
1
]->
IsNumber
()) {
return
THROW_BAD_ARGS
;
}
int
fd = args[
0
]->
Int32Value
();
size_t
len = args[
1
]->
IntegerValue
();
off_t
offset = args[
2
]->
IsNumber
() ? args[
2
]->
IntegerValue
() : -
1
;
enum
encoding encoding =
ParseEncoding
(args[
3
]);
if
(args[
4
]->
IsFunction
()) {
Local<Object> obj = args[
4
]->
ToObject
();
obj->
SetHiddenValue
(encoding_symbol, args[
3
]);
ASYNC_CALL
(read, args[
4
], fd,
NULL
, len, offset)
}
else
{
#
define
READ_BUF_LEN
(
16
*
1024
)
char
*buf[
READ_BUF_LEN
];
ssize_t
ret;
if
(offset <
0
) {
ret =
read
(fd, buf,
MIN
(len,
READ_BUF_LEN
));
}
else
{
ret =
pread
(fd, buf,
MIN
(len,
READ_BUF_LEN
), offset);
}
if
(ret <
0
)
return
ThrowException
(
errno_exception
(errno));
Local<Array> a =
Array::New
(
2
);
a->
Set
(
Integer::New
(
0
),
Encode
(buf, ret, encoding));
a->
Set
(
Integer::New
(
1
),
Integer::New
(ret));
return
scope.
Close
(a);
}
}
/*
node.fs.chmod(fd, mode);
* Wrapper for chmod(1) / EIO_CHMOD
*/
static
Handle<Value>
Chmod
(
const
Arguments& args){
HandleScope scope;
if
(args.
Length
() <
2
|| !args[
0
]->
IsString
() || !args[
1
]->
IsInt32
()) {
return
THROW_BAD_ARGS
;
}
String::Utf8Value
path
(args[
0
]->
ToString
());
mode_t
mode =
static_cast
<
mode_t
>(args[
1
]->
Int32Value
());
if
(args[
2
]->
IsFunction
()) {
ASYNC_CALL
(chmod, args[
2
], *path, mode);
}
else
{
int
ret =
chmod
(*path, mode);
if
(ret !=
0
)
return
ThrowException
(
errno_exception
(errno));
return
Undefined
();
}
}
void
File::Initialize
(Handle<Object> target) {
HandleScope scope;
NODE_SET_METHOD
(target,
"
close
"
, Close);
NODE_SET_METHOD
(target,
"
open
"
, Open);
NODE_SET_METHOD
(target,
"
read
"
, Read);
NODE_SET_METHOD
(target,
"
rename
"
, Rename);
NODE_SET_METHOD
(target,
"
truncate
"
, Truncate);
NODE_SET_METHOD
(target,
"
rmdir
"
, RMDir);
NODE_SET_METHOD
(target,
"
mkdir
"
, MKDir);
NODE_SET_METHOD
(target,
"
sendfile
"
, SendFile);
NODE_SET_METHOD
(target,
"
readdir
"
, ReadDir);
NODE_SET_METHOD
(target,
"
stat
"
, Stat);
NODE_SET_METHOD
(target,
"
lstat
"
, LStat);
NODE_SET_METHOD
(target,
"
link
"
, Link);
NODE_SET_METHOD
(target,
"
symlink
"
, Symlink);
NODE_SET_METHOD
(target,
"
readlink
"
, ReadLink);
NODE_SET_METHOD
(target,
"
unlink
"
, Unlink);
NODE_SET_METHOD
(target,
"
write
"
, Write);
NODE_SET_METHOD
(target,
"
chmod
"
, Chmod);
errno_symbol =
NODE_PSYMBOL
(
"
errno
"
);
encoding_symbol =
NODE_PSYMBOL
(
"
node:encoding
"
);
}
}
//
end namespace node
Back
|
FazBrowse Home
|
New Git URL