Mercurial > hg > nginx-site
comparison xml/en/docs/njs/reference.xml @ 2563:428a8cf1911b
Documented mkdirSync, readdirSync, rmdirSync, fs.Dirent in njs.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Tue, 07 Jul 2020 14:26:27 +0100 |
parents | 6093e9f3615e |
children | 5aa57c656cbf |
comparison
equal
deleted
inserted
replaced
2562:55da8df41bfd | 2563:428a8cf1911b |
---|---|
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="43"> | 12 rev="44"> |
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 |
1333 </tag-desc> | 1333 </tag-desc> |
1334 | 1334 |
1335 </list> | 1335 </list> |
1336 </tag-desc> | 1336 </tag-desc> |
1337 | 1337 |
1338 <tag-name id="fs_mkdirsync"><literal>mkdirSync(<value>path</value>[, | |
1339 <value>options</value>])</literal></tag-name> | |
1340 <tag-desc> | |
1341 Synchronously creates a directory at the specified <literal>path</literal> | |
1342 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). | |
1343 The <literal>options</literal> parameter is expected to be an | |
1344 <literal>integer</literal> that specifies | |
1345 the <link id="fs_mkdirsync_mode">mode</link>, | |
1346 or an object with the following keys: | |
1347 <list type="tag"> | |
1348 | |
1349 <tag-name id="fs_mkdirsync_mode"><literal>mode</literal></tag-name> | |
1350 <tag-desc> | |
1351 mode option, by default is <literal>0o777</literal>. | |
1352 </tag-desc> | |
1353 | |
1354 </list> | |
1355 </tag-desc> | |
1356 | |
1357 <tag-name id="fs_readdirsync"><literal>readdirSync(<value>path</value>[, | |
1358 <value>options</value>])</literal></tag-name> | |
1359 <tag-desc> | |
1360 Synchronously reads the contents of a directory | |
1361 at the specified <literal>path</literal> | |
1362 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). | |
1363 The <literal>options</literal> parameter is expected to be | |
1364 a string that specifies <link id="fs_readdirsync_encoding">encoding</link> | |
1365 or an object with the following keys: | |
1366 <list type="tag"> | |
1367 | |
1368 <tag-name id="fs_readdirsync_encoding"><literal>encoding</literal></tag-name> | |
1369 <tag-desc> | |
1370 encoding, by default is not specified. | |
1371 The encoding can be <literal>utf8</literal>. | |
1372 </tag-desc> | |
1373 | |
1374 <tag-name id="fs_readdirsync_withfiletypes"><literal>withFileTypes</literal></tag-name> | |
1375 <tag-desc> | |
1376 if set to <literal>true</literal>, the files array will contain | |
1377 <link id="fs_dirent"><literal>fs.Dirent</literal></link> objects, | |
1378 by default is <literal>false</literal>. | |
1379 </tag-desc> | |
1380 | |
1381 </list> | |
1382 </tag-desc> | |
1383 | |
1338 <tag-name id="readfilesync"><literal>readFileSync(<value>filename</value>[, | 1384 <tag-name id="readfilesync"><literal>readFileSync(<value>filename</value>[, |
1339 <value>options</value>])</literal></tag-name> | 1385 <value>options</value>])</literal></tag-name> |
1340 <tag-desc> | 1386 <tag-desc> |
1341 Synchronously returns the contents of the file | 1387 Synchronously returns the contents of the file |
1342 with provided <literal>filename</literal>. | 1388 with provided <literal>filename</literal>. |
1395 >> var file = fs.renameSync('hello.txt', 'HelloWorld.txt') | 1441 >> var file = fs.renameSync('hello.txt', 'HelloWorld.txt') |
1396 undefined | 1442 undefined |
1397 </example> | 1443 </example> |
1398 </tag-desc> | 1444 </tag-desc> |
1399 | 1445 |
1446 <tag-name id="fs_rmdirsync"><literal>rmdirSync(<value>path</value>)</literal></tag-name> | |
1447 <tag-desc> | |
1448 Synchronously removes a directory at the specified <literal>path</literal> | |
1449 (<link doc="changes.xml" id="njs0.4.2">0.4.2</link>). | |
1450 </tag-desc> | |
1451 | |
1400 <tag-name id="fs_symlinksync"><literal>symlinkSync(<value>target</value>, | 1452 <tag-name id="fs_symlinksync"><literal>symlinkSync(<value>target</value>, |
1401 <value>path</value>)</literal></tag-name> | 1453 <value>path</value>)</literal></tag-name> |
1402 <tag-desc> | 1454 <tag-desc> |
1403 Synchronously creates the link called <literal>path</literal> | 1455 Synchronously creates the link called <literal>path</literal> |
1404 pointing to <literal>target</literal> using | 1456 pointing to <literal>target</literal> using |
1446 | 1498 |
1447 </list> | 1499 </list> |
1448 </para> | 1500 </para> |
1449 | 1501 |
1450 | 1502 |
1503 <section id="fs_dirent" name="fs.Dirent"> | |
1504 | |
1505 <para> | |
1506 <literal>fs.Dirent</literal> is a representation of a directory entry— | |
1507 a file or a subdirectory. | |
1508 When | |
1509 <link id="fs_readdirsync"><literal>readdirSync()</literal></link> | |
1510 is called with the | |
1511 <link id="fs_readdirsync_withfiletypes"><literal>withFileTypes</literal></link> | |
1512 option, | |
1513 the resulting array contains <literal>fs.Dirent</literal> objects. | |
1514 | |
1515 <list type= "bullet" compact="no"> | |
1516 | |
1517 <listitem> | |
1518 <literal>dirent.isBlockDevice()</literal>—returns | |
1519 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1520 a block device. | |
1521 </listitem> | |
1522 | |
1523 <listitem> | |
1524 <literal>dirent.isCharacterDevice()</literal>—returns | |
1525 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1526 a character device. | |
1527 </listitem> | |
1528 | |
1529 <listitem> | |
1530 <literal>dirent.isDirectory()</literal>—returns | |
1531 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1532 a file system directory. | |
1533 </listitem> | |
1534 | |
1535 <listitem> | |
1536 <literal>dirent.isFIFO()</literal>—returns | |
1537 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1538 a first-in-first-out (FIFO) pipe. | |
1539 </listitem> | |
1540 | |
1541 <listitem> | |
1542 <literal>dirent.isFile()</literal>—returns | |
1543 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1544 a regular file. | |
1545 </listitem> | |
1546 | |
1547 <listitem> | |
1548 <literal>dirent.isSocket()</literal>—returns | |
1549 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1550 a socket. | |
1551 </listitem> | |
1552 | |
1553 <listitem> | |
1554 <literal>dirent.isSymbolicLink()</literal>—returns | |
1555 <literal>true</literal> if the <literal>fs.Dirent</literal> object describes | |
1556 a symbolic link. | |
1557 </listitem> | |
1558 | |
1559 <listitem> | |
1560 <literal>dirent.name</literal>— | |
1561 the name of the file <literal>fs.Dirent</literal> object refers to. | |
1562 </listitem> | |
1563 | |
1564 </list> | |
1565 </para> | |
1566 | |
1567 </section> | |
1568 | |
1569 | |
1451 <section id="access_const" name="File Access Constants"> | 1570 <section id="access_const" name="File Access Constants"> |
1452 | 1571 |
1453 <para> | 1572 <para> |
1454 The <link id="fs_accesssync"><literal>access()</literal></link> method | 1573 The <link id="fs_accesssync"><literal>access()</literal></link> method |
1455 can accept the following flags. | 1574 can accept the following flags. |