comparison xml/en/docs/njs/reference.xml @ 2818:2594d336342d

Documented fs.Stats, statSync and lstatSync in njs.
author Yaroslav Zhuravlev <yar@nginx.com>
date Wed, 29 Dec 2021 14:07:09 +0300
parents 3a146e49f9d4
children 3b705c0a5af7
comparison
equal deleted inserted replaced
2817:d84856836c20 2818:2594d336342d
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8 8
9 <article name="Reference" 9 <article name="Reference"
10 link="/en/docs/njs/reference.html" 10 link="/en/docs/njs/reference.html"
11 lang="en" 11 lang="en"
12 rev="78"> 12 rev="79">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 <link doc="index.xml">njs</link> provides objects, methods and properties 17 <link doc="index.xml">njs</link> provides objects, methods and properties
3314 </tag-desc> 3314 </tag-desc>
3315 3315
3316 </list> 3316 </list>
3317 </tag-desc> 3317 </tag-desc>
3318 3318
3319 <tag-name id="fs_lstatsync"><literal>lstatSync(<value>path</value>[,
3320 <value>options</value>])</literal></tag-name>
3321 <tag-desc>
3322 Synchronously retrieves
3323 the <link id="fs_stats"><literal>fs.Stats</literal></link> object
3324 for the symbolic link referred to by <literal>path</literal>
3325 (<link doc="changes.xml" id="njs0.7.1">0.7.1</link>).
3326 The <literal>options</literal> parameter is expected to be
3327 an object with the following keys:
3328 <list type="tag">
3329 <tag-name><literal>throwIfNoEntry</literal></tag-name>
3330 <tag-desc>
3331 a boolean value which indicates
3332 whether an exception is thrown if no file system entry exists,
3333 rather than returning <literal>undefined</literal>,
3334 by default is <literal>false</literal>.
3335 </tag-desc>
3336 </list>
3337 </tag-desc>
3338
3319 <tag-name id="fs_mkdirsync"><literal>mkdirSync(<value>path</value>[, 3339 <tag-name id="fs_mkdirsync"><literal>mkdirSync(<value>path</value>[,
3320 <value>options</value>])</literal></tag-name> 3340 <value>options</value>])</literal></tag-name>
3321 <tag-desc> 3341 <tag-desc>
3322 Synchronously creates a directory at the specified <literal>path</literal> 3342 Synchronously creates a directory at the specified <literal>path</literal>
3323 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). 3343 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>).
3441 <tag-desc> 3461 <tag-desc>
3442 Synchronously removes a directory at the specified <literal>path</literal> 3462 Synchronously removes a directory at the specified <literal>path</literal>
3443 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). 3463 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>).
3444 </tag-desc> 3464 </tag-desc>
3445 3465
3466 <tag-name id="fs_statsync"><literal>statSync(<value>path</value>,[
3467 <value>options</value>])</literal></tag-name>
3468 <tag-desc>
3469 Synchronously retrieves
3470 the <link id="fs_stats"><literal>fs.Stats</literal></link> object
3471 for the specified <literal>path</literal>
3472 (<link doc="changes.xml" id="njs0.7.1">0.7.1</link>).
3473 The <literal>path</literal> can be a
3474 <literal>string</literal> or
3475 <literal>buffer</literal>.
3476 The <literal>options</literal> parameter is expected to be
3477 an object with the following keys:
3478 <list type="tag">
3479 <tag-name><literal>throwIfNoEntry</literal></tag-name>
3480 <tag-desc>
3481 a boolean value which indicates whether
3482 an exception is thrown if no file system entry exists
3483 rather than returning <literal>undefined</literal>,
3484 by default is <literal>true</literal>.
3485 </tag-desc>
3486 </list>
3487 </tag-desc>
3488
3446 <tag-name id="fs_symlinksync"><literal>symlinkSync(<value>target</value>, 3489 <tag-name id="fs_symlinksync"><literal>symlinkSync(<value>target</value>,
3447 <value>path</value>)</literal></tag-name> 3490 <value>path</value>)</literal></tag-name>
3448 <tag-desc> 3491 <tag-desc>
3449 Synchronously creates the link called <literal>path</literal> 3492 Synchronously creates the link called <literal>path</literal>
3450 pointing to <literal>target</literal> using 3493 pointing to <literal>target</literal> using
3553 </listitem> 3596 </listitem>
3554 3597
3555 <listitem> 3598 <listitem>
3556 <literal>dirent.name</literal>&mdash; 3599 <literal>dirent.name</literal>&mdash;
3557 the name of the file <literal>fs.Dirent</literal> object refers to. 3600 the name of the file <literal>fs.Dirent</literal> object refers to.
3601 </listitem>
3602
3603 </list>
3604 </para>
3605
3606 </section>
3607
3608
3609 <section id="fs_stats" name="fs.Stats">
3610
3611 <para>
3612 The <literal>fs.Stats</literal> object provides information about a file.
3613 The object is returned from
3614 <link id="fs_statsync">fs.statSync()</link> and
3615 <link id="fs_lstatsync">fs.lstatSync()</link>.
3616
3617 <list type= "bullet" compact="no">
3618
3619 <listitem>
3620 <literal>stats.isBlockDevice()</literal>&mdash;returns
3621 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3622 a block device.
3623 </listitem>
3624
3625 <listitem>
3626 <literal>stats.isDirectory()</literal>&mdash;returns
3627 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3628 a file system directory.
3629 </listitem>
3630
3631 <listitem>
3632 <literal>stats.isFIFO()</literal>&mdash;returns
3633 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3634 a first-in-first-out (FIFO) pipe.
3635 </listitem>
3636
3637 <listitem>
3638 <literal>stats.isFile()</literal>&mdash;returns
3639 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3640 a regular file.
3641 </listitem>
3642
3643 <listitem>
3644 <literal>stats.isSocket()</literal>&mdash;returns
3645 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3646 a socket.
3647 </listitem>
3648
3649 <listitem>
3650 <literal>stats.isSymbolicLink()</literal>&mdash;returns
3651 <literal>true</literal> if the <literal>fs.Stats</literal> object describes
3652 a symbolic link.
3653 </listitem>
3654
3655 <listitem>
3656 <literal>stats.dev</literal>&mdash;
3657 the numeric identifier of the device containing the file.
3658 </listitem>
3659
3660 <listitem>
3661 <literal>stats.ino</literal>&mdash;
3662 the file system specific <literal>Inode</literal> number for the file.
3663 </listitem>
3664
3665 <listitem>
3666 <literal>stats.mode</literal>&mdash;
3667 a bit-field describing the file type and mode.
3668 </listitem>
3669
3670 <listitem>
3671 <literal>stats.nlink</literal>&mdash;
3672 the number of hard-links that exist for the file.
3673 </listitem>
3674
3675 <listitem>
3676 <literal>stats.uid</literal>&mdash;
3677 the numeric user identifier of the user that owns the file (POSIX).
3678 </listitem>
3679
3680 <listitem>
3681 <literal>stats.gid</literal>&mdash;
3682 the numeric group identifier of the group that owns the file (POSIX).
3683 </listitem>
3684
3685 <listitem>
3686 <literal>stats.rdev</literal>&mdash;
3687 the numeric device identifier if the file represents a device.
3688 </listitem>
3689
3690 <listitem>
3691 <literal>stats.size</literal>&mdash;
3692 the size of the file in bytes.
3693 </listitem>
3694
3695 <listitem>
3696 <literal>stats.blksize</literal>&mdash;
3697 the file system block size for i/o operations.
3698 </listitem>
3699
3700 <listitem>
3701 <literal>stats.blocks</literal>&mdash;
3702 the number of blocks allocated for this file.
3703 </listitem>
3704
3705 <listitem>
3706 <literal>stats.atimeMs</literal>&mdash;
3707 the timestamp indicating the last time this file was accessed expressed
3708 in milliseconds since the POSIX Epoch.
3709 </listitem>
3710
3711 <listitem>
3712 <literal>stats.mtimeMs</literal>&mdash;
3713 the timestamp indicating the last time this file was modified expressed
3714 in milliseconds since the POSIX Epoch.
3715 </listitem>
3716
3717 <listitem>
3718 <literal>stats.ctimeMs</literal>&mdash;
3719 the timestamp indicating the last time this file was changed expressed
3720 in milliseconds since the POSIX Epoch.
3721 </listitem>
3722
3723 <listitem>
3724 <literal>stats.birthtimeMs</literal>&mdash;
3725 the timestamp indicating the creation time of this file expressed
3726 in milliseconds since the POSIX Epoch.
3727 </listitem>
3728
3729 <listitem>
3730 <literal>stats.atime</literal>&mdash;
3731 the timestamp indicating the last time this file was accessed.
3732 </listitem>
3733
3734 <listitem>
3735 <literal>stats.mtime</literal>&mdash;
3736 the timestamp indicating the last time this file was modified.
3737 </listitem>
3738
3739 <listitem>
3740 <literal>stats.ctime</literal>&mdash;
3741 the timestamp indicating the last time this file was changed.
3742 </listitem>
3743
3744 <listitem>
3745 <literal>stats.birthtime</literal>&mdash;
3746 the timestamp indicating the creation time of this file.
3558 </listitem> 3747 </listitem>
3559 3748
3560 </list> 3749 </list>
3561 </para> 3750 </para>
3562 3751