Merge pull request #437 from fkooman/issue-436
[project/luci.git] / documentation / api / modules / nixio.fs.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
5     <title>Reference</title>
6     <link rel="stylesheet" href="../luadoc.css" type="text/css" />
7         <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
8 </head>
9
10 <body>
11 <div id="container">
12
13 <div id="product">
14         <div id="product_logo"></div>
15         <div id="product_name"><big><b></b></big></div>
16         <div id="product_description"></div>
17 </div> <!-- id="product" -->
18
19 <div id="main">
20
21 <div id="navigation">
22
23
24 <h1>LuaDoc</h1>
25 <ul>
26         
27         <li><a href="../index.html">Index</a></li>
28         
29 </ul>
30
31
32 <!-- Module list -->
33
34 <h1>Modules</h1>
35 <ul>
36
37         <li>
38                 <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
39         </li>
40
41         <li>
42                 <a href="../modules/luci.http.html">luci.http</a>
43         </li>
44
45         <li>
46                 <a href="../modules/luci.http.protocol.html">luci.http.protocol</a>
47         </li>
48
49         <li>
50                 <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
51         </li>
52
53         <li>
54                 <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
55         </li>
56
57         <li>
58                 <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
59         </li>
60
61         <li>
62                 <a href="../modules/luci.i18n.html">luci.i18n</a>
63         </li>
64
65         <li>
66                 <a href="../modules/luci.ip.html">luci.ip</a>
67         </li>
68
69         <li>
70                 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
71         </li>
72
73         <li>
74                 <a href="../modules/luci.json.html">luci.json</a>
75         </li>
76
77         <li>
78                 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
79         </li>
80
81         <li>
82                 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
83         </li>
84
85         <li>
86                 <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
87         </li>
88
89         <li>
90                 <a href="../modules/luci.model.uci.html">luci.model.uci</a>
91         </li>
92
93         <li>
94                 <a href="../modules/luci.rpcc.html">luci.rpcc</a>
95         </li>
96
97         <li>
98                 <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
99         </li>
100
101         <li>
102                 <a href="../modules/luci.sys.html">luci.sys</a>
103         </li>
104
105         <li>
106                 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
107         </li>
108
109         <li>
110                 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
111         </li>
112
113         <li>
114                 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
115         </li>
116
117         <li>
118                 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
119         </li>
120
121         <li>
122                 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
123         </li>
124
125         <li>
126                 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
127         </li>
128
129         <li>
130                 <a href="../modules/luci.util.html">luci.util</a>
131         </li>
132
133         <li>
134                 <a href="../modules/nixio.html">nixio</a>
135         </li>
136
137         <li>
138                 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
139         </li>
140
141         <li>
142                 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
143         </li>
144
145         <li>
146                 <a href="../modules/nixio.File.html">nixio.File</a>
147         </li>
148
149         <li>
150                 <a href="../modules/nixio.README.html">nixio.README</a>
151         </li>
152
153         <li>
154                 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
155         </li>
156
157         <li>
158                 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
159         </li>
160
161         <li>
162                 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
163         </li>
164
165         <li>
166                 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
167         </li>
168
169         <li>
170                 <a href="../modules/nixio.bin.html">nixio.bin</a>
171         </li>
172
173         <li>
174                 <a href="../modules/nixio.bit.html">nixio.bit</a>
175         </li>
176
177         <li>
178                 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
179         </li>
180
181         <li><strong>nixio.fs</strong></li>
182         
183 </ul>
184
185
186
187 <!-- File list -->
188
189
190
191
192
193
194
195 </div><!-- id="navigation" -->
196
197 <div id="content">
198
199 <h1>Class <code>nixio.fs</code></h1>
200
201 <p>
202  Low-level and high-level filesystem manipulation library.</p>
203
204
205
206
207
208
209
210 <h2>Functions</h2>
211 <table class="function_list">
212
213         <tr>
214         <td class="name" nowrap><a href="#nixio.fs.access">access</a>&nbsp;(path, mode1, ...)</td>
215         <td class="summary">
216  Check user's permission on a file.</td>
217         </tr>
218
219         <tr>
220         <td class="name" nowrap><a href="#nixio.fs.basename">basename</a>&nbsp;(path)</td>
221         <td class="summary">
222  Strip the directory part from a path.</td>
223         </tr>
224
225         <tr>
226         <td class="name" nowrap><a href="#nixio.fs.chmod">chmod</a>&nbsp;(path, mode)</td>
227         <td class="summary">
228  Change the file mode.</td>
229         </tr>
230
231         <tr>
232         <td class="name" nowrap><a href="#nixio.fs.chown">chown</a>&nbsp;(path, user, group)</td>
233         <td class="summary">
234  (POSIX) Change owner and group of a file.</td>
235         </tr>
236
237         <tr>
238         <td class="name" nowrap><a href="#nixio.fs.copy">copy</a>&nbsp;(src, dest)</td>
239         <td class="summary">
240  Copy a file, directory or symlink non-recursively preserving file mode, 
241  timestamps, owner and group.</td>
242         </tr>
243
244         <tr>
245         <td class="name" nowrap><a href="#nixio.fs.copyr">copyr</a>&nbsp;(src, dest)</td>
246         <td class="summary">
247  Copy a file, directory or symlink recursively preserving file mode, 
248  timestamps, owner and group.</td>
249         </tr>
250
251         <tr>
252         <td class="name" nowrap><a href="#nixio.fs.datacopy">datacopy</a>&nbsp;(src, dest, limit)</td>
253         <td class="summary">
254  Copy data between files.</td>
255         </tr>
256
257         <tr>
258         <td class="name" nowrap><a href="#nixio.fs.dir">dir</a>&nbsp;(path)</td>
259         <td class="summary">
260  Iterate over the entries of a directory.</td>
261         </tr>
262
263         <tr>
264         <td class="name" nowrap><a href="#nixio.fs.dirname">dirname</a>&nbsp;(path)</td>
265         <td class="summary">
266  Strip the base from a path.</td>
267         </tr>
268
269         <tr>
270         <td class="name" nowrap><a href="#nixio.fs.glob">glob</a>&nbsp;(pattern)</td>
271         <td class="summary">
272  (POSIX) Find pathnames matching a pattern.</td>
273         </tr>
274
275         <tr>
276         <td class="name" nowrap><a href="#nixio.fs.lchown">lchown</a>&nbsp;(path, user, group)</td>
277         <td class="summary">
278  (POSIX) Change owner and group of a file and do not resolve 
279  if target is a symlink.</td>
280         </tr>
281
282         <tr>
283         <td class="name" nowrap><a href="#nixio.fs.link">link</a>&nbsp;(oldpath, newpath)</td>
284         <td class="summary">
285  Create a hard link.</td>
286         </tr>
287
288         <tr>
289         <td class="name" nowrap><a href="#nixio.fs.lstat">lstat</a>&nbsp;(path, field)</td>
290         <td class="summary">
291  Get file status and attributes and do not resolve if target is a symlink.</td>
292         </tr>
293
294         <tr>
295         <td class="name" nowrap><a href="#nixio.fs.mkdir">mkdir</a>&nbsp;(path, mode)</td>
296         <td class="summary">
297  Create a new directory.</td>
298         </tr>
299
300         <tr>
301         <td class="name" nowrap><a href="#nixio.fs.mkdirr">mkdirr</a>&nbsp;(dest, mode)</td>
302         <td class="summary">
303  Create a directory and all needed parent directories recursively.</td>
304         </tr>
305
306         <tr>
307         <td class="name" nowrap><a href="#nixio.fs.mkfifo">mkfifo</a>&nbsp;(path, mode)</td>
308         <td class="summary">
309  (POSIX) Create a FIFO (named pipe).</td>
310         </tr>
311
312         <tr>
313         <td class="name" nowrap><a href="#nixio.fs.move">move</a>&nbsp;(src, dest)</td>
314         <td class="summary">
315  Rename a file, directory or symlink non-recursively across filesystems.</td>
316         </tr>
317
318         <tr>
319         <td class="name" nowrap><a href="#nixio.fs.mover">mover</a>&nbsp;(src, dest)</td>
320         <td class="summary">
321  Rename a file, directory or symlink recursively across filesystems.</td>
322         </tr>
323
324         <tr>
325         <td class="name" nowrap><a href="#nixio.fs.readfile">readfile</a>&nbsp;(path, limit)</td>
326         <td class="summary">
327  Read the contents of a file into a buffer.</td>
328         </tr>
329
330         <tr>
331         <td class="name" nowrap><a href="#nixio.fs.readlink">readlink</a>&nbsp;(path)</td>
332         <td class="summary">
333  (POSIX) Read the target of a symbolic link.</td>
334         </tr>
335
336         <tr>
337         <td class="name" nowrap><a href="#nixio.fs.realpath">realpath</a>&nbsp;(path)</td>
338         <td class="summary">
339  Return the cannonicalized absolute pathname.</td>
340         </tr>
341
342         <tr>
343         <td class="name" nowrap><a href="#nixio.fs.remove">remove</a>&nbsp;(path)</td>
344         <td class="summary">
345  Remove a file or directory.</td>
346         </tr>
347
348         <tr>
349         <td class="name" nowrap><a href="#nixio.fs.rename">rename</a>&nbsp;(src, dest)</td>
350         <td class="summary">
351  Renames a file or directory.</td>
352         </tr>
353
354         <tr>
355         <td class="name" nowrap><a href="#nixio.fs.rmdir">rmdir</a>&nbsp;(path)</td>
356         <td class="summary">
357  Remove an empty directory.</td>
358         </tr>
359
360         <tr>
361         <td class="name" nowrap><a href="#nixio.fs.stat">stat</a>&nbsp;(path, field)</td>
362         <td class="summary">
363  Get file status and attributes.</td>
364         </tr>
365
366         <tr>
367         <td class="name" nowrap><a href="#nixio.fs.statvfs">statvfs</a>&nbsp;(path)</td>
368         <td class="summary">
369  (POSIX) Get filesystem statistics.</td>
370         </tr>
371
372         <tr>
373         <td class="name" nowrap><a href="#nixio.fs.symlink">symlink</a>&nbsp;(oldpath, newpath)</td>
374         <td class="summary">
375  (POSIX) Create a symbolic link.</td>
376         </tr>
377
378         <tr>
379         <td class="name" nowrap><a href="#nixio.fs.unlink">unlink</a>&nbsp;(path)</td>
380         <td class="summary">
381  Delete a name and - if no links are left - the associated file.</td>
382         </tr>
383
384         <tr>
385         <td class="name" nowrap><a href="#nixio.fs.utimes">utimes</a>&nbsp;(path, actime, mtime)</td>
386         <td class="summary">
387  Change file last access and last modification time.</td>
388         </tr>
389
390         <tr>
391         <td class="name" nowrap><a href="#nixio.fs.writefile">writefile</a>&nbsp;(path, data)</td>
392         <td class="summary">
393  Write a buffer into a file truncating the file first.</td>
394         </tr>
395
396 </table>
397
398
399
400
401
402
403 <br/>
404 <br/>
405
406
407 <h2><a name="functions"></a>Functions</h2>
408 <dl class="function">
409
410
411
412 <dt><a name="nixio.fs.access"></a><strong>access</strong>&nbsp;(path, mode1, ...)</dt>
413 <dd>
414
415  Check user's permission on a file.
416
417
418 <h3>Parameters</h3>
419 <ul>
420         
421         <li>
422           path: Path
423         </li>
424         
425         <li>
426           mode1: First Mode to check ["f", "r", "w", "x"]
427         </li>
428         
429         <li>
430           ...: More Modes to check      [-"-]
431         </li>
432         
433 </ul>
434
435
436
437
438
439
440 <h3>Return value:</h3>
441 true
442
443
444
445 </dd>
446
447
448
449
450 <dt><a name="nixio.fs.basename"></a><strong>basename</strong>&nbsp;(path)</dt>
451 <dd>
452
453  Strip the directory part from a path.
454
455
456 <h3>Parameters</h3>
457 <ul>
458         
459         <li>
460           path: Path
461         </li>
462         
463 </ul>
464
465
466
467
468 <h3>Usage:</h3>
469 This function cannot fail and will never return nil.
470
471
472
473 <h3>Return value:</h3>
474 basename
475
476
477
478 </dd>
479
480
481
482
483 <dt><a name="nixio.fs.chmod"></a><strong>chmod</strong>&nbsp;(path, mode)</dt>
484 <dd>
485
486  Change the file mode.
487
488
489 <h3>Parameters</h3>
490 <ul>
491         
492         <li>
493           path: Path
494         </li>
495         
496         <li>
497           mode: File mode        
498  [decimal mode number, "[-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]"]
499         </li>
500         
501 </ul>
502
503
504
505
506 <h3>Usage</h3>
507 <ul>
508         
509         <li>Windows only supports setting the write-protection through the 
510  "Writable to others" bit.
511         
512         <li><strong>Notice:</strong> The mode-flag for the functions 
513  open, mkdir, mkfifo are affected by the umask. 
514         
515 </ul>
516
517
518
519 <h3>Return value:</h3>
520 true
521
522
523
524 <h3>See also:</h3>
525 <ul>
526         
527         <li><a href="">
528                 umask
529         </a>
530         
531 </ul>
532
533 </dd>
534
535
536
537
538 <dt><a name="nixio.fs.chown"></a><strong>chown</strong>&nbsp;(path, user, group)</dt>
539 <dd>
540
541  (POSIX) Change owner and group of a file.
542
543
544 <h3>Parameters</h3>
545 <ul>
546         
547         <li>
548           path: Path
549         </li>
550         
551         <li>
552           user: User ID or Username             (optional)
553         </li>
554         
555         <li>
556           group: Group ID or Groupname  (optional)
557         </li>
558         
559 </ul>
560
561
562
563
564
565
566 <h3>Return value:</h3>
567 true
568
569
570
571 </dd>
572
573
574
575
576 <dt><a name="nixio.fs.copy"></a><strong>copy</strong>&nbsp;(src, dest)</dt>
577 <dd>
578
579  Copy a file, directory or symlink non-recursively preserving file mode, 
580  timestamps, owner and group.
581
582
583 <h3>Parameters</h3>
584 <ul>
585         
586         <li>
587           src: Source path
588         </li>
589         
590         <li>
591           dest: Destination path
592         </li>
593         
594 </ul>
595
596
597
598
599 <h3>Usage:</h3>
600 The destination must always be a full destination path e.g. do not 
601  omit the basename even if source and destination basename are equal. 
602
603
604
605 <h3>Return value:</h3>
606 true
607
608
609
610 </dd>
611
612
613
614
615 <dt><a name="nixio.fs.copyr"></a><strong>copyr</strong>&nbsp;(src, dest)</dt>
616 <dd>
617
618  Copy a file, directory or symlink recursively preserving file mode, 
619  timestamps, owner and group.
620
621
622 <h3>Parameters</h3>
623 <ul>
624         
625         <li>
626           src: Source path
627         </li>
628         
629         <li>
630           dest: Destination path
631         </li>
632         
633 </ul>
634
635
636
637
638 <h3>Usage:</h3>
639 The destination must always be a full destination path e.g. do not 
640  omit the basename even if source and destination basename are equal. 
641
642
643
644 <h3>Return value:</h3>
645 true
646
647
648
649 </dd>
650
651
652
653
654 <dt><a name="nixio.fs.datacopy"></a><strong>datacopy</strong>&nbsp;(src, dest, limit)</dt>
655 <dd>
656
657  Copy data between files.
658
659
660 <h3>Parameters</h3>
661 <ul>
662         
663         <li>
664           src: Source file path
665         </li>
666         
667         <li>
668           dest: Destination file path
669         </li>
670         
671         <li>
672           limit: Maximum bytes to copy (optional)
673         </li>
674         
675 </ul>
676
677
678
679
680
681
682 <h3>Return value:</h3>
683 true
684
685
686
687 </dd>
688
689
690
691
692 <dt><a name="nixio.fs.dir"></a><strong>dir</strong>&nbsp;(path)</dt>
693 <dd>
694
695  Iterate over the entries of a directory.
696
697
698 <h3>Parameters</h3>
699 <ul>
700         
701         <li>
702           path: Path
703         </li>
704         
705 </ul>
706
707
708
709
710 <h3>Usage:</h3>
711 The special entries "." and ".." are omitted.
712
713
714
715 <h3>Return value:</h3>
716 directory iterator returning one entry per call
717
718
719
720 </dd>
721
722
723
724
725 <dt><a name="nixio.fs.dirname"></a><strong>dirname</strong>&nbsp;(path)</dt>
726 <dd>
727
728  Strip the base from a path.
729
730
731 <h3>Parameters</h3>
732 <ul>
733         
734         <li>
735           path: Path
736         </li>
737         
738 </ul>
739
740
741
742
743 <h3>Usage:</h3>
744 This function cannot fail and will never return nil.
745
746
747
748 <h3>Return value:</h3>
749 dirname
750
751
752
753 </dd>
754
755
756
757
758 <dt><a name="nixio.fs.glob"></a><strong>glob</strong>&nbsp;(pattern)</dt>
759 <dd>
760
761  (POSIX) Find pathnames matching a pattern.
762
763
764 <h3>Parameters</h3>
765 <ul>
766         
767         <li>
768           pattern: Pattern
769         </li>
770         
771 </ul>
772
773
774
775
776
777
778 <h3>Return values:</h3>
779 <ol>
780         
781         <li>path iterator
782         
783         <li>number of matches
784         
785 </ol>
786
787
788
789 </dd>
790
791
792
793
794 <dt><a name="nixio.fs.lchown"></a><strong>lchown</strong>&nbsp;(path, user, group)</dt>
795 <dd>
796
797  (POSIX) Change owner and group of a file and do not resolve 
798  if target is a symlink.
799
800
801 <h3>Parameters</h3>
802 <ul>
803         
804         <li>
805           path: Path
806         </li>
807         
808         <li>
809           user: User ID or Username             (optional)
810         </li>
811         
812         <li>
813           group: Group ID or Groupname  (optional)
814         </li>
815         
816 </ul>
817
818
819
820
821
822
823 <h3>Return value:</h3>
824 true
825
826
827
828 </dd>
829
830
831
832
833 <dt><a name="nixio.fs.link"></a><strong>link</strong>&nbsp;(oldpath, newpath)</dt>
834 <dd>
835
836  Create a hard link.
837
838
839 <h3>Parameters</h3>
840 <ul>
841         
842         <li>
843           oldpath: Path
844         </li>
845         
846         <li>
847           newpath: Path
848         </li>
849         
850 </ul>
851
852
853
854
855 <h3>Usage:</h3>
856 This function calls link() on POSIX and CreateHardLink() on Windows.
857
858
859
860 <h3>Return value:</h3>
861 true
862
863
864
865 </dd>
866
867
868
869
870 <dt><a name="nixio.fs.lstat"></a><strong>lstat</strong>&nbsp;(path, field)</dt>
871 <dd>
872
873  Get file status and attributes and do not resolve if target is a symlink.
874
875
876 <h3>Parameters</h3>
877 <ul>
878         
879         <li>
880           path: Path
881         </li>
882         
883         <li>
884           field: Only return a specific field, not the whole table (optional)
885         </li>
886         
887 </ul>
888
889
890
891
892
893
894 <h3>Return value:</h3>
895 Table containing attributes (see stat for a detailed description)
896
897
898
899 <h3>See also:</h3>
900 <ul>
901         
902         <li><a href="#nixio.fs.stat">
903                 stat
904         </a>
905         
906 </ul>
907
908 </dd>
909
910
911
912
913 <dt><a name="nixio.fs.mkdir"></a><strong>mkdir</strong>&nbsp;(path, mode)</dt>
914 <dd>
915
916  Create a new directory.
917
918
919 <h3>Parameters</h3>
920 <ul>
921         
922         <li>
923           path: Path
924         </li>
925         
926         <li>
927           mode: File mode (optional, see chmod and umask)
928         </li>
929         
930 </ul>
931
932
933
934
935
936
937 <h3>Return value:</h3>
938 true
939
940
941
942 <h3>See also:</h3>
943 <ul>
944         
945         <li><a href="#nixio.fs.chmod">
946                 chmod
947         </a>
948         
949         <li><a href="">
950                 umask
951         </a>
952         
953 </ul>
954
955 </dd>
956
957
958
959
960 <dt><a name="nixio.fs.mkdirr"></a><strong>mkdirr</strong>&nbsp;(dest, mode)</dt>
961 <dd>
962
963  Create a directory and all needed parent directories recursively. 
964
965
966 <h3>Parameters</h3>
967 <ul>
968         
969         <li>
970           dest: Destination path
971         </li>
972         
973         <li>
974           mode: File mode (optional, see chmod and umask)
975         </li>
976         
977 </ul>
978
979
980
981
982
983
984 <h3>Return value:</h3>
985 true
986
987
988
989 <h3>See also:</h3>
990 <ul>
991         
992         <li><a href="#nixio.fs.chmod">
993                 chmod
994         </a>
995         
996         <li><a href="">
997                 umask
998         </a>
999         
1000 </ul>
1001
1002 </dd>
1003
1004
1005
1006
1007 <dt><a name="nixio.fs.mkfifo"></a><strong>mkfifo</strong>&nbsp;(path, mode)</dt>
1008 <dd>
1009
1010  (POSIX) Create a FIFO (named pipe).
1011
1012
1013 <h3>Parameters</h3>
1014 <ul>
1015         
1016         <li>
1017           path: Path
1018         </li>
1019         
1020         <li>
1021           mode: File mode (optional, see chmod and umask)
1022         </li>
1023         
1024 </ul>
1025
1026
1027
1028
1029
1030
1031 <h3>Return value:</h3>
1032 true
1033
1034
1035
1036 <h3>See also:</h3>
1037 <ul>
1038         
1039         <li><a href="#nixio.fs.chmod">
1040                 chmod
1041         </a>
1042         
1043         <li><a href="">
1044                 umask
1045         </a>
1046         
1047 </ul>
1048
1049 </dd>
1050
1051
1052
1053
1054 <dt><a name="nixio.fs.move"></a><strong>move</strong>&nbsp;(src, dest)</dt>
1055 <dd>
1056
1057  Rename a file, directory or symlink non-recursively across filesystems.
1058
1059
1060 <h3>Parameters</h3>
1061 <ul>
1062         
1063         <li>
1064           src: Source path
1065         </li>
1066         
1067         <li>
1068           dest: Destination path
1069         </li>
1070         
1071 </ul>
1072
1073
1074
1075
1076 <h3>Usage:</h3>
1077 The destination must always be a full destination path e.g. do not 
1078  omit the basename even if source and destination basename are equal. 
1079
1080
1081
1082 <h3>Return value:</h3>
1083 true
1084
1085
1086
1087 </dd>
1088
1089
1090
1091
1092 <dt><a name="nixio.fs.mover"></a><strong>mover</strong>&nbsp;(src, dest)</dt>
1093 <dd>
1094
1095  Rename a file, directory or symlink recursively across filesystems.
1096
1097
1098 <h3>Parameters</h3>
1099 <ul>
1100         
1101         <li>
1102           src: Source path
1103         </li>
1104         
1105         <li>
1106           dest: Destination path
1107         </li>
1108         
1109 </ul>
1110
1111
1112
1113
1114 <h3>Usage:</h3>
1115 The destination must always be a full destination path e.g. do not 
1116  omit the basename even if source and destination basename are equal. 
1117
1118
1119
1120 <h3>Return value:</h3>
1121 true
1122
1123
1124
1125 </dd>
1126
1127
1128
1129
1130 <dt><a name="nixio.fs.readfile"></a><strong>readfile</strong>&nbsp;(path, limit)</dt>
1131 <dd>
1132
1133  Read the contents of a file into a buffer.
1134
1135
1136 <h3>Parameters</h3>
1137 <ul>
1138         
1139         <li>
1140           path: Path
1141         </li>
1142         
1143         <li>
1144           limit: Maximum bytes to read (optional)
1145         </li>
1146         
1147 </ul>
1148
1149
1150
1151
1152
1153
1154 <h3>Return value:</h3>
1155 file contents
1156
1157
1158
1159 </dd>
1160
1161
1162
1163
1164 <dt><a name="nixio.fs.readlink"></a><strong>readlink</strong>&nbsp;(path)</dt>
1165 <dd>
1166
1167  (POSIX) Read the target of a symbolic link.
1168
1169
1170 <h3>Parameters</h3>
1171 <ul>
1172         
1173         <li>
1174           path: Path
1175         </li>
1176         
1177 </ul>
1178
1179
1180
1181
1182
1183
1184 <h3>Return value:</h3>
1185 target path
1186
1187
1188
1189 </dd>
1190
1191
1192
1193
1194 <dt><a name="nixio.fs.realpath"></a><strong>realpath</strong>&nbsp;(path)</dt>
1195 <dd>
1196
1197  Return the cannonicalized absolute pathname.
1198
1199
1200 <h3>Parameters</h3>
1201 <ul>
1202         
1203         <li>
1204           path: Path
1205         </li>
1206         
1207 </ul>
1208
1209
1210
1211
1212
1213
1214 <h3>Return value:</h3>
1215 absolute path
1216
1217
1218
1219 </dd>
1220
1221
1222
1223
1224 <dt><a name="nixio.fs.remove"></a><strong>remove</strong>&nbsp;(path)</dt>
1225 <dd>
1226
1227  Remove a file or directory.
1228
1229
1230 <h3>Parameters</h3>
1231 <ul>
1232         
1233         <li>
1234           path: Path
1235         </li>
1236         
1237 </ul>
1238
1239
1240
1241
1242
1243
1244 <h3>Return value:</h3>
1245 true
1246
1247
1248
1249 </dd>
1250
1251
1252
1253
1254 <dt><a name="nixio.fs.rename"></a><strong>rename</strong>&nbsp;(src, dest)</dt>
1255 <dd>
1256
1257  Renames a file or directory.
1258
1259
1260 <h3>Parameters</h3>
1261 <ul>
1262         
1263         <li>
1264           src: Source path
1265         </li>
1266         
1267         <li>
1268           dest: Destination path
1269         </li>
1270         
1271 </ul>
1272
1273
1274
1275
1276 <h3>Usage:</h3>
1277 It is normally not possible to rename files accross fileystems.
1278
1279
1280
1281 <h3>Return value:</h3>
1282 true
1283
1284
1285
1286 </dd>
1287
1288
1289
1290
1291 <dt><a name="nixio.fs.rmdir"></a><strong>rmdir</strong>&nbsp;(path)</dt>
1292 <dd>
1293
1294  Remove an empty directory.
1295
1296
1297 <h3>Parameters</h3>
1298 <ul>
1299         
1300         <li>
1301           path: Path
1302         </li>
1303         
1304 </ul>
1305
1306
1307
1308
1309
1310
1311 <h3>Return value:</h3>
1312 true
1313
1314
1315
1316 </dd>
1317
1318
1319
1320
1321 <dt><a name="nixio.fs.stat"></a><strong>stat</strong>&nbsp;(path, field)</dt>
1322 <dd>
1323
1324  Get file status and attributes.
1325
1326
1327 <h3>Parameters</h3>
1328 <ul>
1329         
1330         <li>
1331           path: Path
1332         </li>
1333         
1334         <li>
1335           field: Only return a specific field, not the whole table (optional)
1336         </li>
1337         
1338 </ul>
1339
1340
1341
1342
1343
1344
1345 <h3>Return value:</h3>
1346 Table containing: <ul> 
1347  <li>atime = Last access timestamp</li> 
1348  <li>blksize = Blocksize (POSIX only)</li> 
1349  <li>blocks = Blocks used (POSIX only)</li> 
1350  <li>ctime = Creation timestamp</li> 
1351  <li>dev = Device ID</li> 
1352  <li>gid = Group ID</li> 
1353  <li>ino = Inode</li> 
1354  <li>modedec = Mode converted into a decimal number</li> 
1355  <li>modestr = Mode as string as returned by <code>ls -l</code></li> 
1356  <li>mtime = Last modification timestamp</li> 
1357  <li>nlink = Number of links</li> 
1358  <li>rdev = Device ID (if special file)</li> 
1359  <li>size = Size in bytes</li> 
1360  <li>type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]</li> 
1361  <li>uid = User ID</li> 
1362  </ul>
1363
1364
1365
1366 </dd>
1367
1368
1369
1370
1371 <dt><a name="nixio.fs.statvfs"></a><strong>statvfs</strong>&nbsp;(path)</dt>
1372 <dd>
1373
1374  (POSIX) Get filesystem statistics.
1375
1376
1377 <h3>Parameters</h3>
1378 <ul>
1379         
1380         <li>
1381           path: Path to any file within the filesystem.
1382         </li>
1383         
1384 </ul>
1385
1386
1387
1388
1389
1390
1391 <h3>Return value:</h3>
1392 Table containing: <ul> 
1393  <li>bavail = available blocks</li> 
1394  <li>bfree = free blocks</li> 
1395  <li>blocks = number of fragments</li> 
1396  <li>frsize = fragment size</li> 
1397  <li>favail = available inodes</li> 
1398  <li>ffree = free inodes</li> 
1399  <li>files = inodes</li> 
1400  <li>flag = flags</li> 
1401  <li>fsid = filesystem ID</li> 
1402  <li>namemax = maximum filename length</li> 
1403  </ul>
1404
1405
1406
1407 </dd>
1408
1409
1410
1411
1412 <dt><a name="nixio.fs.symlink"></a><strong>symlink</strong>&nbsp;(oldpath, newpath)</dt>
1413 <dd>
1414
1415  (POSIX) Create a symbolic link.
1416
1417
1418 <h3>Parameters</h3>
1419 <ul>
1420         
1421         <li>
1422           oldpath: Path
1423         </li>
1424         
1425         <li>
1426           newpath: Path
1427         </li>
1428         
1429 </ul>
1430
1431
1432
1433
1434
1435
1436 <h3>Return value:</h3>
1437 true
1438
1439
1440
1441 </dd>
1442
1443
1444
1445
1446 <dt><a name="nixio.fs.unlink"></a><strong>unlink</strong>&nbsp;(path)</dt>
1447 <dd>
1448
1449  Delete a name and - if no links are left - the associated file.
1450
1451
1452 <h3>Parameters</h3>
1453 <ul>
1454         
1455         <li>
1456           path: Path
1457         </li>
1458         
1459 </ul>
1460
1461
1462
1463
1464
1465
1466 <h3>Return value:</h3>
1467 true
1468
1469
1470
1471 </dd>
1472
1473
1474
1475
1476 <dt><a name="nixio.fs.utimes"></a><strong>utimes</strong>&nbsp;(path, actime, mtime)</dt>
1477 <dd>
1478
1479  Change file last access and last modification time.
1480
1481
1482 <h3>Parameters</h3>
1483 <ul>
1484         
1485         <li>
1486           path: Path
1487         </li>
1488         
1489         <li>
1490           actime: Last access timestamp (optional, default: current time)
1491         </li>
1492         
1493         <li>
1494           mtime: Last modification timestamp (optional, default: actime)
1495         </li>
1496         
1497 </ul>
1498
1499
1500
1501
1502
1503
1504 <h3>Return value:</h3>
1505 true
1506
1507
1508
1509 </dd>
1510
1511
1512
1513
1514 <dt><a name="nixio.fs.writefile"></a><strong>writefile</strong>&nbsp;(path, data)</dt>
1515 <dd>
1516
1517  Write a buffer into a file truncating the file first.
1518
1519
1520 <h3>Parameters</h3>
1521 <ul>
1522         
1523         <li>
1524           path: Path
1525         </li>
1526         
1527         <li>
1528           data: Data to write
1529         </li>
1530         
1531 </ul>
1532
1533
1534
1535
1536
1537
1538 <h3>Return value:</h3>
1539 true
1540
1541
1542
1543 </dd>
1544
1545
1546 </dl>
1547
1548
1549
1550
1551
1552 </div> <!-- id="content" -->
1553
1554 </div> <!-- id="main" -->
1555
1556 <div id="about">
1557         <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
1558 </div> <!-- id="about" -->
1559
1560 </div> <!-- id="container" -->
1561 </body>
1562 </html>