home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libposixfile.tex / libposixfile.txt
LaTeX Document  |  1994-08-12  |  5.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libposixfile.txt

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file Python script text executable default (weak)
98% file LaTeX document, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% gt2 Textdatei (UNIX) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 4d 61 6e 75 61 6c | 20 74 65 78 74 20 61 6e |% Manual| text an|
|00000010| 64 20 69 6d 70 6c 65 6d | 65 6e 74 61 74 69 6f 6e |d implem|entation|
|00000020| 20 62 79 20 4a 61 61 70 | 20 56 65 72 6d 65 75 6c | by Jaap| Vermeul|
|00000030| 65 6e 0a 5c 73 65 63 74 | 69 6f 6e 7b 53 74 61 6e |en.\sect|ion{Stan|
|00000040| 64 61 72 64 20 4d 6f 64 | 75 6c 65 20 5c 73 65 63 |dard Mod|ule \sec|
|00000050| 74 63 6f 64 65 7b 70 6f | 73 69 78 66 69 6c 65 7d |tcode{po|sixfile}|
|00000060| 7d 0a 5c 62 69 6d 6f 64 | 69 6e 64 65 78 7b 70 6f |}.\bimod|index{po|
|00000070| 73 69 78 66 69 6c 65 7d | 0a 5c 69 6e 64 65 78 69 |sixfile}|.\indexi|
|00000080| 69 7b 70 6f 73 69 78 7d | 7b 66 69 6c 65 20 6f 62 |i{posix}|{file ob|
|00000090| 6a 65 63 74 7d 0a 54 68 | 69 73 20 6d 6f 64 75 6c |ject}.Th|is modul|
|000000a0| 65 20 69 6d 70 6c 65 6d | 65 6e 74 73 20 73 6f 6d |e implem|ents som|
|000000b0| 65 20 61 64 64 69 74 69 | 6f 6e 61 6c 20 66 75 6e |e additi|onal fun|
|000000c0| 63 74 69 6f 6e 61 6c 69 | 74 79 20 6f 76 65 72 20 |ctionali|ty over |
|000000d0| 74 68 65 20 62 75 69 6c | 74 2d 69 6e 0a 66 69 6c |the buil|t-in.fil|
|000000e0| 65 20 6f 62 6a 65 63 74 | 73 2e 20 20 49 6e 20 70 |e object|s. In p|
|000000f0| 61 72 74 69 63 75 6c 61 | 72 2c 20 69 74 20 69 6d |articula|r, it im|
|00000100| 70 6c 65 6d 65 6e 74 73 | 20 66 69 6c 65 20 6c 6f |plements| file lo|
|00000110| 63 6b 69 6e 67 2c 20 63 | 6f 6e 74 72 6f 6c 20 6f |cking, c|ontrol o|
|00000120| 76 65 72 0a 74 68 65 20 | 66 69 6c 65 20 66 6c 61 |ver.the |file fla|
|00000130| 67 73 2c 20 61 6e 64 20 | 61 6e 20 65 61 73 79 20 |gs, and |an easy |
|00000140| 69 6e 74 65 72 66 61 63 | 65 20 74 6f 20 64 75 70 |interfac|e to dup|
|00000150| 6c 69 63 61 74 65 20 74 | 68 65 20 66 69 6c 65 20 |licate t|he file |
|00000160| 6f 62 6a 65 63 74 2e 0a | 54 68 65 20 6d 6f 64 75 |object..|The modu|
|00000170| 6c 65 20 64 65 66 69 6e | 65 73 20 61 20 6e 65 77 |le defin|es a new|
|00000180| 20 66 69 6c 65 20 6f 62 | 6a 65 63 74 2c 20 74 68 | file ob|ject, th|
|00000190| 65 20 70 6f 73 69 78 66 | 69 6c 65 20 6f 62 6a 65 |e posixf|ile obje|
|000001a0| 63 74 2e 20 20 49 74 0a | 69 6e 68 65 72 69 74 73 |ct. It.|inherits|
|000001b0| 20 61 6c 6c 20 74 68 65 | 20 73 74 61 6e 64 61 72 | all the| standar|
|000001c0| 64 20 66 69 6c 65 20 6f | 62 6a 65 63 74 20 6d 65 |d file o|bject me|
|000001d0| 74 68 6f 64 73 20 61 6e | 64 20 61 64 64 73 20 74 |thods an|d adds t|
|000001e0| 68 65 20 6d 65 74 68 6f | 64 73 0a 64 65 73 63 72 |he metho|ds.descr|
|000001f0| 69 62 65 64 20 62 65 6c | 6f 77 2e 0a 54 6f 20 69 |ibed bel|ow..To i|
|00000200| 6e 73 74 61 6e 74 69 61 | 74 65 20 61 20 70 6f 73 |nstantia|te a pos|
|00000210| 69 78 66 69 6c 65 20 6f | 62 6a 65 63 74 2c 20 75 |ixfile o|bject, u|
|00000220| 73 65 20 74 68 65 20 5c | 63 6f 64 65 7b 6f 70 65 |se the \|code{ope|
|00000230| 6e 28 29 7d 20 66 75 6e | 63 74 69 6f 6e 20 69 6e |n()} fun|ction in|
|00000240| 0a 74 68 65 20 70 6f 73 | 69 78 66 69 6c 65 20 6d |.the pos|ixfile m|
|00000250| 6f 64 75 6c 65 2e 20 20 | 54 68 65 20 72 65 73 75 |odule. |The resu|
|00000260| 6c 74 69 6e 67 20 6f 62 | 6a 65 63 74 20 6c 6f 6f |lting ob|ject loo|
|00000270| 6b 73 20 61 6e 64 20 66 | 65 65 6c 73 20 74 68 65 |ks and f|eels the|
|00000280| 20 73 61 6d 65 20 61 73 | 0a 61 20 73 74 61 6e 64 | same as|.a stand|
|00000290| 61 72 64 20 66 69 6c 65 | 20 6f 62 6a 65 63 74 2e |ard file| object.|
|000002a0| 0a 54 68 65 20 70 6f 73 | 69 78 66 69 6c 65 20 6d |.The pos|ixfile m|
|000002b0| 6f 64 75 6c 65 20 64 65 | 66 69 6e 65 73 20 74 68 |odule de|fines th|
|000002c0| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 63 6f 6e 73 |e follow|ing cons|
|000002d0| 74 61 6e 74 73 3a 0a 5c | 72 65 6e 65 77 63 6f 6d |tants:.\|renewcom|
|000002e0| 6d 61 6e 64 7b 5c 69 6e | 64 65 78 73 75 62 69 74 |mand{\in|dexsubit|
|000002f0| 65 6d 7d 7b 28 69 6e 20 | 6d 6f 64 75 6c 65 20 70 |em}{(in |module p|
|00000300| 6f 73 69 78 66 69 6c 65 | 29 7d 0a 5c 62 65 67 69 |osixfile|)}.\begi|
|00000310| 6e 7b 64 61 74 61 64 65 | 73 63 7d 7b 53 45 45 4b |n{datade|sc}{SEEK|
|00000320| 5f 53 45 54 7d 0a 6f 66 | 66 73 65 74 20 69 73 20 |_SET}.of|fset is |
|00000330| 63 61 6c 63 75 6c 61 74 | 65 64 20 66 72 6f 6d 20 |calculat|ed from |
|00000340| 74 68 65 20 73 74 61 72 | 74 20 6f 66 20 74 68 65 |the star|t of the|
|00000350| 20 66 69 6c 65 0a 5c 65 | 6e 64 7b 64 61 74 61 64 | file.\e|nd{datad|
|00000360| 65 73 63 7d 0a 5c 62 65 | 67 69 6e 7b 64 61 74 61 |esc}.\be|gin{data|
|00000370| 64 65 73 63 7d 7b 53 45 | 45 4b 5f 43 55 52 7d 0a |desc}{SE|EK_CUR}.|
|00000380| 6f 66 66 73 65 74 20 69 | 73 20 63 61 6c 63 75 6c |offset i|s calcul|
|00000390| 61 74 65 64 20 66 72 6f | 6d 20 74 68 65 20 63 75 |ated fro|m the cu|
|000003a0| 72 72 65 6e 74 20 70 6f | 73 69 74 69 6f 6e 20 69 |rrent po|sition i|
|000003b0| 6e 20 74 68 65 20 66 69 | 6c 65 0a 5c 65 6e 64 7b |n the fi|le.\end{|
|000003c0| 64 61 74 61 64 65 73 63 | 7d 0a 5c 62 65 67 69 6e |datadesc|}.\begin|
|000003d0| 7b 64 61 74 61 64 65 73 | 63 7d 7b 53 45 45 4b 5f |{datades|c}{SEEK_|
|000003e0| 45 4e 44 7d 0a 6f 66 66 | 73 65 74 20 69 73 20 63 |END}.off|set is c|
|000003f0| 61 6c 63 75 6c 61 74 65 | 64 20 66 72 6f 6d 20 74 |alculate|d from t|
|00000400| 68 65 20 65 6e 64 20 6f | 66 20 74 68 65 20 66 69 |he end o|f the fi|
|00000410| 6c 65 0a 5c 65 6e 64 7b | 64 61 74 61 64 65 73 63 |le.\end{|datadesc|
|00000420| 7d 0a 54 68 65 20 70 6f | 73 69 78 66 69 6c 65 20 |}.The po|sixfile |
|00000430| 6d 6f 64 75 6c 65 20 64 | 65 66 69 6e 65 73 20 74 |module d|efines t|
|00000440| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 66 75 6e |he follo|wing fun|
|00000450| 63 74 69 6f 6e 73 3a 0a | 5c 72 65 6e 65 77 63 6f |ctions:.|\renewco|
|00000460| 6d 6d 61 6e 64 7b 5c 69 | 6e 64 65 78 73 75 62 69 |mmand{\i|ndexsubi|
|00000470| 74 65 6d 7d 7b 28 69 6e | 20 6d 6f 64 75 6c 65 20 |tem}{(in| module |
|00000480| 70 6f 73 69 78 66 69 6c | 65 29 7d 0a 5c 62 65 67 |posixfil|e)}.\beg|
|00000490| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 6f 70 65 |in{funcd|esc}{ope|
|000004a0| 6e 7d 7b 66 69 6c 65 6e | 61 6d 65 5c 2c 20 6d 6f |n}{filen|ame\, mo|
|000004b0| 64 65 7d 0a 20 43 72 65 | 61 74 65 20 61 20 6e 65 |de}. Cre|ate a ne|
|000004c0| 77 20 70 6f 73 69 78 66 | 69 6c 65 20 6f 62 6a 65 |w posixf|ile obje|
|000004d0| 63 74 20 77 69 74 68 20 | 74 68 65 20 67 69 76 65 |ct with |the give|
|000004e0| 6e 20 66 69 6c 65 6e 61 | 6d 65 20 61 6e 64 20 6d |n filena|me and m|
|000004f0| 6f 64 65 2e 20 20 54 68 | 65 0a 20 66 69 6c 65 6e |ode. Th|e. filen|
|00000500| 61 6d 65 20 61 6e 64 20 | 6d 6f 64 65 20 61 72 65 |ame and |mode are|
|00000510| 20 69 6e 74 65 72 70 72 | 65 74 65 64 20 74 68 65 | interpr|eted the|
|00000520| 20 73 61 6d 65 20 77 61 | 79 20 61 73 20 74 68 65 | same wa|y as the|
|00000530| 20 5c 63 6f 64 65 7b 6f | 70 65 6e 28 29 7d 0a 20 | \code{o|pen()}. |
|00000540| 62 75 69 6c 74 69 6e 20 | 66 75 6e 63 74 69 6f 6e |builtin |function|
|00000550| 2e 0a 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00000560| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00000570| 7d 7b 6f 70 65 6e 66 69 | 6c 65 7d 7b 66 69 6c 65 |}{openfi|le}{file|
|00000580| 6f 62 6a 65 63 74 7d 0a | 20 43 72 65 61 74 65 20 |object}.| Create |
|00000590| 61 20 6e 65 77 20 70 6f | 73 69 78 66 69 6c 65 20 |a new po|sixfile |
|000005a0| 6f 62 6a 65 63 74 20 77 | 69 74 68 20 74 68 65 20 |object w|ith the |
|000005b0| 67 69 76 65 6e 20 73 74 | 61 6e 64 61 72 64 20 66 |given st|andard f|
|000005c0| 69 6c 65 20 6f 62 6a 65 | 63 74 2e 0a 20 54 68 65 |ile obje|ct.. The|
|000005d0| 20 72 65 73 75 6c 74 69 | 6e 67 20 6f 62 6a 65 63 | resulti|ng objec|
|000005e0| 74 20 68 61 73 20 74 68 | 65 20 73 61 6d 65 20 66 |t has th|e same f|
|000005f0| 69 6c 65 6e 61 6d 65 20 | 61 6e 64 20 6d 6f 64 65 |ilename |and mode|
|00000600| 20 61 73 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c | as the |original|
|00000610| 0a 20 66 69 6c 65 20 6f | 62 6a 65 63 74 2e 0a 5c |. file o|bject..\|
|00000620| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 54 68 |end{func|desc}.Th|
|00000630| 65 20 70 6f 73 69 78 66 | 69 6c 65 20 6f 62 6a 65 |e posixf|ile obje|
|00000640| 63 74 20 64 65 66 69 6e | 65 73 20 74 68 65 20 66 |ct defin|es the f|
|00000650| 6f 6c 6c 6f 77 69 6e 67 | 20 61 64 64 69 74 69 6f |ollowing| additio|
|00000660| 6e 61 6c 20 6d 65 74 68 | 6f 64 73 3a 0a 5c 72 65 |nal meth|ods:.\re|
|00000670| 6e 65 77 63 6f 6d 6d 61 | 6e 64 7b 5c 69 6e 64 65 |newcomma|nd{\inde|
|00000680| 78 73 75 62 69 74 65 6d | 7d 7b 28 70 6f 73 69 78 |xsubitem|}{(posix|
|00000690| 66 69 6c 65 20 6d 65 74 | 68 6f 64 29 7d 0a 5c 62 |file met|hod)}.\b|
|000006a0| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 6c |egin{fun|cdesc}{l|
|000006b0| 6f 63 6b 7d 7b 66 6d 74 | 5c 2c 20 5c 6f 70 74 69 |ock}{fmt|\, \opti|
|000006c0| 6f 6e 61 6c 7b 6c 65 6e | 5c 6f 70 74 69 6f 6e 61 |onal{len|\optiona|
|000006d0| 6c 7b 5c 2c 20 73 74 61 | 72 74 0a 5c 6f 70 74 69 |l{\, sta|rt.\opti|
|000006e0| 6f 6e 61 6c 7b 5c 2c 20 | 77 68 65 6e 63 65 7d 7d |onal{\, |whence}}|
|000006f0| 7d 7d 0a 20 4c 6f 63 6b | 20 74 68 65 20 73 70 65 |}}. Lock| the spe|
|00000700| 63 69 66 69 65 64 20 73 | 65 63 74 69 6f 6e 20 6f |cified s|ection o|
|00000710| 66 20 74 68 65 20 66 69 | 6c 65 20 74 68 61 74 20 |f the fi|le that |
|00000720| 74 68 65 20 66 69 6c 65 | 20 6f 62 6a 65 63 74 20 |the file| object |
|00000730| 69 73 0a 20 72 65 66 65 | 72 72 69 6e 67 20 74 6f |is. refe|rring to|
|00000740| 2e 20 20 54 68 65 20 66 | 6f 72 6d 61 74 20 69 73 |. The f|ormat is|
|00000750| 20 65 78 70 6c 61 69 6e | 65 64 0a 20 62 65 6c 6f | explain|ed. belo|
|00000760| 77 20 69 6e 20 61 20 74 | 61 62 6c 65 2e 20 20 54 |w in a t|able. T|
|00000770| 68 65 20 5c 76 61 72 7b | 6c 65 6e 7d 20 61 72 67 |he \var{|len} arg|
|00000780| 75 6d 65 6e 74 20 73 70 | 65 63 69 66 69 65 73 20 |ument sp|ecifies |
|00000790| 74 68 65 20 6c 65 6e 67 | 74 68 20 6f 66 20 74 68 |the leng|th of th|
|000007a0| 65 0a 20 73 65 63 74 69 | 6f 6e 20 74 68 61 74 20 |e. secti|on that |
|000007b0| 73 68 6f 75 6c 64 20 62 | 65 20 6c 6f 63 6b 65 64 |should b|e locked|
|000007c0| 2e 20 54 68 65 20 64 65 | 66 61 75 6c 74 20 69 73 |. The de|fault is|
|000007d0| 20 5c 63 6f 64 65 7b 30 | 7d 2e 20 5c 76 61 72 7b | \code{0|}. \var{|
|000007e0| 73 74 61 72 74 7d 0a 20 | 73 70 65 63 69 66 69 65 |start}. |specifie|
|000007f0| 73 20 74 68 65 20 73 74 | 61 72 74 69 6e 67 20 6f |s the st|arting o|
|00000800| 66 66 73 65 74 20 6f 66 | 20 74 68 65 20 73 65 63 |ffset of| the sec|
|00000810| 74 69 6f 6e 2c 20 77 68 | 65 72 65 20 74 68 65 20 |tion, wh|ere the |
|00000820| 64 65 66 61 75 6c 74 20 | 69 73 0a 20 5c 63 6f 64 |default |is. \cod|
|00000830| 65 7b 30 7d 2e 20 20 54 | 68 65 20 5c 76 61 72 7b |e{0}. T|he \var{|
|00000840| 77 68 65 6e 63 65 7d 20 | 61 72 67 75 6d 65 6e 74 |whence} |argument|
|00000850| 20 73 70 65 63 69 66 69 | 65 73 20 77 68 65 72 65 | specifi|es where|
|00000860| 20 74 68 65 20 6f 66 66 | 73 65 74 20 69 73 0a 20 | the off|set is. |
|00000870| 72 65 6c 61 74 69 76 65 | 20 74 6f 2e 20 49 74 20 |relative| to. It |
|00000880| 61 63 63 65 70 74 73 20 | 6f 6e 65 20 6f 66 20 74 |accepts |one of t|
|00000890| 68 65 20 63 6f 6e 73 74 | 61 6e 74 73 20 5c 63 6f |he const|ants \co|
|000008a0| 64 65 7b 53 45 45 4b 5f | 53 45 54 7d 2c 0a 20 5c |de{SEEK_|SET},. \|
|000008b0| 63 6f 64 65 7b 53 45 45 | 4b 5f 43 55 52 7d 20 6f |code{SEE|K_CUR} o|
|000008c0| 72 20 5c 63 6f 64 65 7b | 53 45 45 4b 5f 45 4e 44 |r \code{|SEEK_END|
|000008d0| 7d 2e 20 20 54 68 65 20 | 64 65 66 61 75 6c 74 20 |}. The |default |
|000008e0| 69 73 20 5c 63 6f 64 65 | 7b 53 45 45 4b 5f 53 45 |is \code|{SEEK_SE|
|000008f0| 54 7d 2e 0a 20 46 6f 72 | 20 6d 6f 72 65 20 69 6e |T}.. For| more in|
|00000900| 66 6f 72 6d 61 74 69 6f | 6e 20 61 62 6f 75 74 20 |formatio|n about |
|00000910| 74 68 65 20 61 72 67 75 | 6d 65 6e 74 73 20 72 65 |the argu|ments re|
|00000920| 66 65 72 20 74 6f 20 74 | 68 65 20 66 63 6e 74 6c |fer to t|he fcntl|
|00000930| 0a 20 6d 61 6e 75 61 6c | 20 70 61 67 65 20 6f 6e |. manual| page on|
|00000940| 20 79 6f 75 72 20 73 79 | 73 74 65 6d 2e 0a 5c 65 | your sy|stem..\e|
|00000950| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0a 5c 62 65 |nd{funcd|esc}.\be|
|00000960| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 66 6c |gin{func|desc}{fl|
|00000970| 61 67 73 7d 7b 66 6d 74 | 7d 0a 20 53 65 74 20 74 |ags}{fmt|}. Set t|
|00000980| 68 65 20 73 70 65 63 69 | 66 69 65 64 20 66 6c 61 |he speci|fied fla|
|00000990| 67 73 20 66 6f 72 20 74 | 68 65 20 66 69 6c 65 20 |gs for t|he file |
|000009a0| 74 68 61 74 20 74 68 65 | 20 66 69 6c 65 20 6f 62 |that the| file ob|
|000009b0| 6a 65 63 74 20 69 73 20 | 72 65 66 65 72 72 69 6e |ject is |referrin|
|000009c0| 67 0a 20 74 6f 2e 20 20 | 54 68 65 20 6e 65 77 20 |g. to. |The new |
|000009d0| 66 6c 61 67 73 20 61 72 | 65 20 4f 52 65 64 20 77 |flags ar|e ORed w|
|000009e0| 69 74 68 20 74 68 65 20 | 6f 6c 64 20 66 6c 61 67 |ith the |old flag|
|000009f0| 73 2c 20 75 6e 6c 65 73 | 73 20 73 70 65 63 69 66 |s, unles|s specif|
|00000a00| 69 65 64 0a 20 6f 74 68 | 65 72 77 69 73 65 2e 20 |ied. oth|erwise. |
|00000a10| 20 54 68 65 20 66 6f 72 | 6d 61 74 20 69 73 20 65 | The for|mat is e|
|00000a20| 78 70 6c 61 69 6e 65 64 | 20 62 65 6c 6f 77 20 69 |xplained| below i|
|00000a30| 6e 20 61 20 74 61 62 6c | 65 2e 20 20 57 69 74 68 |n a tabl|e. With|
|00000a40| 6f 75 74 0a 20 61 72 67 | 75 6d 65 6e 74 73 20 61 |out. arg|uments a|
|00000a50| 20 73 74 72 69 6e 67 20 | 69 6e 64 69 63 61 74 69 | string |indicati|
|00000a60| 6e 67 20 74 68 65 20 63 | 75 72 72 65 6e 74 20 66 |ng the c|urrent f|
|00000a70| 6c 61 67 73 20 69 73 20 | 72 65 74 75 72 6e 65 64 |lags is |returned|
|00000a80| 20 28 74 68 69 73 20 69 | 73 0a 20 74 68 65 20 73 | (this i|s. the s|
|00000a90| 61 6d 65 20 61 73 20 74 | 68 65 20 27 3f 27 20 6d |ame as t|he '?' m|
|00000aa0| 6f 64 69 66 69 65 72 29 | 2e 20 20 46 6f 72 20 6d |odifier)|. For m|
|00000ab0| 6f 72 65 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ore info|rmation |
|00000ac0| 61 62 6f 75 74 20 74 68 | 65 20 66 6c 61 67 73 0a |about th|e flags.|
|00000ad0| 20 72 65 66 65 72 20 74 | 6f 20 74 68 65 20 66 63 | refer t|o the fc|
|00000ae0| 6e 74 6c 20 6d 61 6e 75 | 61 6c 20 70 61 67 65 20 |ntl manu|al page |
|00000af0| 6f 6e 20 79 6f 75 72 20 | 73 79 73 74 65 6d 2e 0a |on your |system..|
|00000b00| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 5c |\end{fun|cdesc}.\|
|00000b10| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00000b20| 64 75 70 7d 7b 7d 0a 20 | 44 75 70 6c 69 63 61 74 |dup}{}. |Duplicat|
|00000b30| 65 20 74 68 65 20 66 69 | 6c 65 20 6f 62 6a 65 63 |e the fi|le objec|
|00000b40| 74 20 61 6e 64 20 74 68 | 65 20 75 6e 64 65 72 6c |t and th|e underl|
|00000b50| 79 69 6e 67 20 66 69 6c | 65 20 70 6f 69 6e 74 65 |ying fil|e pointe|
|00000b60| 72 20 61 6e 64 20 66 69 | 6c 65 0a 20 64 65 73 63 |r and fi|le. desc|
|00000b70| 72 69 70 74 6f 72 2e 20 | 20 54 68 65 20 72 65 73 |riptor. | The res|
|00000b80| 75 6c 74 69 6e 67 20 6f | 62 6a 65 63 74 20 62 65 |ulting o|bject be|
|00000b90| 68 61 76 65 73 20 61 73 | 20 69 66 20 69 74 20 77 |haves as| if it w|
|00000ba0| 65 72 65 20 6e 65 77 6c | 79 0a 20 6f 70 65 6e 65 |ere newl|y. opene|
|00000bb0| 64 2e 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |d..\end{|funcdesc|
|00000bc0| 7d 0a 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |}.\begin|{funcdes|
|00000bd0| 63 7d 7b 64 75 70 32 7d | 7b 66 64 7d 0a 20 44 75 |c}{dup2}|{fd}. Du|
|00000be0| 70 6c 69 63 61 74 65 20 | 74 68 65 20 66 69 6c 65 |plicate |the file|
|00000bf0| 20 6f 62 6a 65 63 74 20 | 61 6e 64 20 74 68 65 20 | object |and the |
|00000c00| 75 6e 64 65 72 6c 79 69 | 6e 67 20 66 69 6c 65 20 |underlyi|ng file |
|00000c10| 70 6f 69 6e 74 65 72 20 | 61 6e 64 20 66 69 6c 65 |pointer |and file|
|00000c20| 0a 20 64 65 73 63 72 69 | 70 74 6f 72 2e 20 20 54 |. descri|ptor. T|
|00000c30| 68 65 20 6e 65 77 20 6f | 62 6a 65 63 74 20 77 69 |he new o|bject wi|
|00000c40| 6c 6c 20 68 61 76 65 20 | 74 68 65 20 67 69 76 65 |ll have |the give|
|00000c50| 6e 20 66 69 6c 65 20 64 | 65 73 63 72 69 70 74 6f |n file d|escripto|
|00000c60| 72 2e 0a 20 4f 74 68 65 | 72 77 69 73 65 20 74 68 |r.. Othe|rwise th|
|00000c70| 65 20 72 65 73 75 6c 74 | 69 6e 67 20 6f 62 6a 65 |e result|ing obje|
|00000c80| 63 74 20 62 65 68 61 76 | 65 73 20 61 73 20 69 66 |ct behav|es as if|
|00000c90| 20 69 74 20 77 65 72 65 | 20 6e 65 77 6c 79 20 6f | it were| newly o|
|00000ca0| 70 65 6e 65 64 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |pened..\|end{func|
|00000cb0| 64 65 73 63 7d 0a 5c 62 | 65 67 69 6e 7b 66 75 6e |desc}.\b|egin{fun|
|00000cc0| 63 64 65 73 63 7d 7b 66 | 69 6c 65 7d 7b 7d 0a 20 |cdesc}{f|ile}{}. |
|00000cd0| 52 65 74 75 72 6e 20 74 | 68 65 20 73 74 61 6e 64 |Return t|he stand|
|00000ce0| 61 72 64 20 66 69 6c 65 | 20 6f 62 6a 65 63 74 20 |ard file| object |
|00000cf0| 74 68 61 74 20 74 68 65 | 20 70 6f 73 69 78 66 69 |that the| posixfi|
|00000d00| 6c 65 20 6f 62 6a 65 63 | 74 20 69 73 20 62 61 73 |le objec|t is bas|
|00000d10| 65 64 0a 20 6f 6e 2e 20 | 20 54 68 69 73 20 69 73 |ed. on. | This is|
|00000d20| 20 73 6f 6d 65 74 69 6d | 65 73 20 6e 65 63 65 73 | sometim|es neces|
|00000d30| 73 61 72 79 20 66 6f 72 | 20 66 75 6e 63 74 69 6f |sary for| functio|
|00000d40| 6e 73 20 74 68 61 74 20 | 69 6e 73 69 73 74 20 6f |ns that |insist o|
|00000d50| 6e 20 61 0a 20 73 74 61 | 6e 64 61 72 64 20 66 69 |n a. sta|ndard fi|
|00000d60| 6c 65 20 6f 62 6a 65 63 | 74 2e 0a 5c 65 6e 64 7b |le objec|t..\end{|
|00000d70| 66 75 6e 63 64 65 73 63 | 7d 0a 41 6c 6c 20 6d 65 |funcdesc|}.All me|
|00000d80| 74 68 6f 64 73 20 72 65 | 74 75 72 6e 20 5c 63 6f |thods re|turn \co|
|00000d90| 64 65 7b 49 4f 45 72 72 | 6f 72 7d 20 77 68 65 6e |de{IOErr|or} when|
|00000da0| 20 74 68 65 20 72 65 71 | 75 65 73 74 20 66 61 69 | the req|uest fai|
|00000db0| 6c 73 2e 0a 46 6f 72 6d | 61 74 20 63 68 61 72 61 |ls..Form|at chara|
|00000dc0| 63 74 65 72 73 20 66 6f | 72 20 74 68 65 20 5c 63 |cters fo|r the \c|
|00000dd0| 6f 64 65 7b 6c 6f 63 6b | 28 29 7d 20 6d 65 74 68 |ode{lock|()} meth|
|00000de0| 6f 64 20 68 61 76 65 20 | 74 68 65 20 66 6f 6c 6c |od have |the foll|
|00000df0| 6f 77 69 6e 67 20 6d 65 | 61 6e 69 6e 67 3a 0a 5c |owing me|aning:.\|
|00000e00| 62 65 67 69 6e 7b 74 61 | 62 6c 65 69 69 69 7d 7b |begin{ta|bleiii}{|
|00000e10| 7c 63 7c 6c 7c 63 7c 7d | 7b 73 61 6d 70 7d 7b 46 ||c|l|c|}|{samp}{F|
|00000e20| 6f 72 6d 61 74 7d 7b 4d | 65 61 6e 69 6e 67 7d 7b |ormat}{M|eaning}{|
|00000e30| 7d 0a 20 20 5c 6c 69 6e | 65 69 69 69 7b 75 7d 7b |}. \lin|eiii{u}{|
|00000e40| 75 6e 6c 6f 63 6b 20 74 | 68 65 20 73 70 65 63 69 |unlock t|he speci|
|00000e50| 66 69 65 64 20 72 65 67 | 69 6f 6e 7d 7b 7d 0a 20 |fied reg|ion}{}. |
|00000e60| 20 5c 6c 69 6e 65 69 69 | 69 7b 72 7d 7b 72 65 71 | \lineii|i{r}{req|
|00000e70| 75 65 73 74 20 61 20 72 | 65 61 64 20 6c 6f 63 6b |uest a r|ead lock|
|00000e80| 20 66 6f 72 20 74 68 65 | 20 73 70 65 63 69 66 69 | for the| specifi|
|00000e90| 65 64 20 73 65 63 74 69 | 6f 6e 7d 7b 7d 0a 20 20 |ed secti|on}{}. |
|00000ea0| 5c 6c 69 6e 65 69 69 69 | 7b 77 7d 7b 72 65 71 75 |\lineiii|{w}{requ|
|00000eb0| 65 73 74 20 61 20 77 72 | 69 74 65 20 6c 6f 63 6b |est a wr|ite lock|
|00000ec0| 20 66 6f 72 20 74 68 65 | 20 73 70 65 63 69 66 69 | for the| specifi|
|00000ed0| 65 64 20 73 65 63 74 69 | 6f 6e 7d 7b 7d 0a 5c 65 |ed secti|on}{}.\e|
|00000ee0| 6e 64 7b 74 61 62 6c 65 | 69 69 69 7d 0a 49 6e 20 |nd{table|iii}.In |
|00000ef0| 61 64 64 69 74 69 6f 6e | 20 74 68 65 20 66 6f 6c |addition| the fol|
|00000f00| 6c 6f 77 69 6e 67 20 6d | 6f 64 69 66 69 65 72 73 |lowing m|odifiers|
|00000f10| 20 63 61 6e 20 62 65 20 | 61 64 64 65 64 20 74 6f | can be |added to|
|00000f20| 20 74 68 65 20 66 6f 72 | 6d 61 74 3a 0a 5c 62 65 | the for|mat:.\be|
|00000f30| 67 69 6e 7b 74 61 62 6c | 65 69 69 69 7d 7b 7c 63 |gin{tabl|eiii}{|c|
|00000f40| 7c 6c 7c 63 7c 7d 7b 73 | 61 6d 70 7d 7b 4d 6f 64 ||l|c|}{s|amp}{Mod|
|00000f50| 69 66 69 65 72 7d 7b 4d | 65 61 6e 69 6e 67 7d 7b |ifier}{M|eaning}{|
|00000f60| 4e 6f 74 65 73 7d 0a 20 | 20 5c 6c 69 6e 65 69 69 |Notes}. | \lineii|
|00000f70| 69 7b 7c 7d 7b 77 61 69 | 74 20 75 6e 74 69 6c 20 |i{|}{wai|t until |
|00000f80| 74 68 65 20 6c 6f 63 6b | 20 68 61 73 20 62 65 65 |the lock| has bee|
|00000f90| 6e 20 67 72 61 6e 74 65 | 64 7d 7b 7d 0a 20 20 5c |n grante|d}{}. \|
|00000fa0| 6c 69 6e 65 69 69 69 7b | 3f 7d 7b 72 65 74 75 72 |lineiii{|?}{retur|
|00000fb0| 6e 20 74 68 65 20 66 69 | 72 73 74 20 6c 6f 63 6b |n the fi|rst lock|
|00000fc0| 20 63 6f 6e 66 6c 69 63 | 74 69 6e 67 20 77 69 74 | conflic|ting wit|
|00000fd0| 68 20 74 68 65 20 72 65 | 71 75 65 73 74 65 64 20 |h the re|quested |
|00000fe0| 6c 6f 63 6b 2c 7d 7b 28 | 31 29 7d 0a 20 20 7b 7d |lock,}{(|1)}. {}|
|00000ff0| 26 7b 5c 68 73 6b 69 70 | 30 2e 35 63 6d 20 6f 72 |&{\hskip|0.5cm or|
|00001000| 20 5c 63 6f 64 65 7b 4e | 6f 6e 65 7d 20 69 66 20 | \code{N|one} if |
|00001010| 74 68 65 72 65 20 69 73 | 20 6e 6f 20 63 6f 6e 66 |there is| no conf|
|00001020| 6c 69 63 74 2e 7d 26 7b | 7d 5c 5c 0a 5c 65 6e 64 |lict.}&{|}\\.\end|
|00001030| 7b 74 61 62 6c 65 69 69 | 69 7d 0a 4e 6f 74 65 3a |{tableii|i}.Note:|
|00001040| 0a 28 31 29 20 54 68 65 | 20 6c 6f 63 6b 20 72 65 |.(1) The| lock re|
|00001050| 74 75 72 6e 65 64 20 69 | 73 20 69 6e 20 74 68 65 |turned i|s in the|
|00001060| 20 66 6f 72 6d 61 74 20 | 5c 63 6f 64 65 7b 28 6d | format |\code{(m|
|00001070| 6f 64 65 2c 20 6c 65 6e | 2c 20 73 74 61 72 74 2c |ode, len|, start,|
|00001080| 0a 77 68 65 6e 63 65 2c | 20 70 69 64 29 7d 20 77 |.whence,| pid)} w|
|00001090| 68 65 72 65 20 6d 6f 64 | 65 20 69 73 20 61 20 63 |here mod|e is a c|
|000010a0| 68 61 72 61 63 74 65 72 | 20 72 65 70 72 65 73 65 |haracter| represe|
|000010b0| 6e 74 69 6e 67 20 74 68 | 65 20 74 79 70 65 20 6f |nting th|e type o|
|000010c0| 66 20 6c 6f 63 6b 0a 28 | 27 72 27 20 6f 72 20 27 |f lock.(|'r' or '|
|000010d0| 77 27 29 2e 20 20 54 68 | 69 73 20 6d 6f 64 69 66 |w'). Th|is modif|
|000010e0| 69 65 72 20 70 72 65 76 | 65 6e 74 73 20 61 20 72 |ier prev|ents a r|
|000010f0| 65 71 75 65 73 74 20 66 | 72 6f 6d 20 62 65 69 6e |equest f|rom bein|
|00001100| 67 20 67 72 61 6e 74 65 | 64 3b 20 69 74 0a 69 73 |g grante|d; it.is|
|00001110| 20 66 6f 72 20 71 75 65 | 72 79 20 70 75 72 70 6f | for que|ry purpo|
|00001120| 73 65 73 20 6f 6e 6c 79 | 2e 0a 46 6f 72 6d 61 74 |ses only|..Format|
|00001130| 20 63 68 61 72 61 63 74 | 65 72 20 66 6f 72 20 74 | charact|er for t|
|00001140| 68 65 20 5c 63 6f 64 65 | 7b 66 6c 61 67 73 28 29 |he \code|{flags()|
|00001150| 7d 20 6d 65 74 68 6f 64 | 20 68 61 76 65 20 74 68 |} method| have th|
|00001160| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 6d 65 61 6e |e follow|ing mean|
|00001170| 69 6e 67 3a 0a 5c 62 65 | 67 69 6e 7b 74 61 62 6c |ing:.\be|gin{tabl|
|00001180| 65 69 69 69 7d 7b 7c 63 | 7c 6c 7c 63 7c 7d 7b 73 |eiii}{|c||l|c|}{s|
|00001190| 61 6d 70 7d 7b 46 6f 72 | 6d 61 74 7d 7b 4d 65 61 |amp}{For|mat}{Mea|
|000011a0| 6e 69 6e 67 7d 7b 7d 0a | 20 20 5c 6c 69 6e 65 69 |ning}{}.| \linei|
|000011b0| 69 69 7b 61 7d 7b 61 70 | 70 65 6e 64 20 6f 6e 6c |ii{a}{ap|pend onl|
|000011c0| 79 20 66 6c 61 67 7d 7b | 7d 0a 20 20 5c 6c 69 6e |y flag}{|}. \lin|
|000011d0| 65 69 69 69 7b 63 7d 7b | 63 6c 6f 73 65 20 6f 6e |eiii{c}{|close on|
|000011e0| 20 65 78 65 63 20 66 6c | 61 67 7d 7b 7d 0a 20 20 | exec fl|ag}{}. |
|000011f0| 5c 6c 69 6e 65 69 69 69 | 7b 6e 7d 7b 6e 6f 20 64 |\lineiii|{n}{no d|
|00001200| 65 6c 61 79 20 66 6c 61 | 67 20 28 61 6c 73 6f 20 |elay fla|g (also |
|00001210| 63 61 6c 6c 65 64 20 6e | 6f 6e 2d 62 6c 6f 63 6b |called n|on-block|
|00001220| 69 6e 67 20 66 6c 61 67 | 29 7d 7b 7d 0a 20 20 5c |ing flag|)}{}. \|
|00001230| 6c 69 6e 65 69 69 69 7b | 73 7d 7b 73 79 6e 63 68 |lineiii{|s}{synch|
|00001240| 72 6f 6e 69 7a 61 74 69 | 6f 6e 20 66 6c 61 67 7d |ronizati|on flag}|
|00001250| 7b 7d 0a 5c 65 6e 64 7b | 74 61 62 6c 65 69 69 69 |{}.\end{|tableiii|
|00001260| 7d 0a 49 6e 20 61 64 64 | 69 74 69 6f 6e 20 74 68 |}.In add|ition th|
|00001270| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 6d 6f 64 69 |e follow|ing modi|
|00001280| 66 69 65 72 73 20 63 61 | 6e 20 62 65 20 61 64 64 |fiers ca|n be add|
|00001290| 65 64 20 74 6f 20 74 68 | 65 20 66 6f 72 6d 61 74 |ed to th|e format|
|000012a0| 3a 0a 5c 62 65 67 69 6e | 7b 74 61 62 6c 65 69 69 |:.\begin|{tableii|
|000012b0| 69 7d 7b 7c 63 7c 6c 7c | 63 7c 7d 7b 73 61 6d 70 |i}{|c|l||c|}{samp|
|000012c0| 7d 7b 4d 6f 64 69 66 69 | 65 72 7d 7b 4d 65 61 6e |}{Modifi|er}{Mean|
|000012d0| 69 6e 67 7d 7b 4e 6f 74 | 65 73 7d 0a 20 20 5c 6c |ing}{Not|es}. \l|
|000012e0| 69 6e 65 69 69 69 7b 21 | 7d 7b 74 75 72 6e 20 74 |ineiii{!|}{turn t|
|000012f0| 68 65 20 73 70 65 63 69 | 66 69 65 64 20 66 6c 61 |he speci|fied fla|
|00001300| 67 73 20 27 6f 66 66 27 | 2c 20 69 6e 73 74 65 61 |gs 'off'|, instea|
|00001310| 64 20 6f 66 20 74 68 65 | 20 64 65 66 61 75 6c 74 |d of the| default|
|00001320| 20 27 6f 6e 27 7d 7b 28 | 31 29 7d 0a 20 20 5c 6c | 'on'}{(|1)}. \l|
|00001330| 69 6e 65 69 69 69 7b 3d | 7d 7b 72 65 70 6c 61 63 |ineiii{=|}{replac|
|00001340| 65 20 74 68 65 20 66 6c | 61 67 73 2c 20 69 6e 73 |e the fl|ags, ins|
|00001350| 74 65 61 64 20 6f 66 20 | 74 68 65 20 64 65 66 61 |tead of |the defa|
|00001360| 75 6c 74 20 27 4f 52 27 | 20 6f 70 65 72 61 74 69 |ult 'OR'| operati|
|00001370| 6f 6e 7d 7b 28 31 29 7d | 0a 20 20 5c 6c 69 6e 65 |on}{(1)}|. \line|
|00001380| 69 69 69 7b 3f 7d 7b 72 | 65 74 75 72 6e 20 61 20 |iii{?}{r|eturn a |
|00001390| 73 74 72 69 6e 67 20 69 | 6e 20 77 68 69 63 68 20 |string i|n which |
|000013a0| 74 68 65 20 63 68 61 72 | 61 63 74 65 72 73 20 72 |the char|acters r|
|000013b0| 65 70 72 65 73 65 6e 74 | 20 74 68 65 20 66 6c 61 |epresent| the fla|
|000013c0| 67 73 20 74 68 61 74 0a | 20 20 61 72 65 20 73 65 |gs that.| are se|
|000013d0| 74 2e 7d 7b 28 32 29 7d | 0a 5c 65 6e 64 7b 74 61 |t.}{(2)}|.\end{ta|
|000013e0| 62 6c 65 69 69 69 7d 0a | 4e 6f 74 65 3a 0a 28 31 |bleiii}.|Note:.(1|
|000013f0| 29 20 54 68 65 20 5c 63 | 6f 64 65 7b 21 7d 20 61 |) The \c|ode{!} a|
|00001400| 6e 64 20 5c 63 6f 64 65 | 7b 3d 7d 20 6d 6f 64 69 |nd \code|{=} modi|
|00001410| 66 69 65 72 73 20 61 72 | 65 20 6d 75 74 75 61 6c |fiers ar|e mutual|
|00001420| 6c 79 20 65 78 63 6c 75 | 73 69 76 65 2e 0a 28 32 |ly exclu|sive..(2|
|00001430| 29 20 54 68 69 73 20 73 | 74 72 69 6e 67 20 72 65 |) This s|tring re|
|00001440| 70 72 65 73 65 6e 74 73 | 20 74 68 65 20 66 6c 61 |presents| the fla|
|00001450| 67 73 20 61 66 74 65 72 | 20 74 68 65 79 20 6d 61 |gs after| they ma|
|00001460| 79 20 68 61 76 65 20 62 | 65 65 6e 20 61 6c 74 65 |y have b|een alte|
|00001470| 72 65 64 0a 62 79 20 74 | 68 65 20 73 61 6d 65 20 |red.by t|he same |
|00001480| 63 61 6c 6c 2e 0a 45 78 | 61 6d 70 6c 65 73 3a 0a |call..Ex|amples:.|
|00001490| 5c 62 63 6f 64 65 5c 62 | 65 67 69 6e 7b 76 65 72 |\bcode\b|egin{ver|
|000014a0| 62 61 74 69 6d 7d 0a 66 | 72 6f 6d 20 70 6f 73 69 |batim}.f|rom posi|
|000014b0| 78 66 69 6c 65 20 69 6d | 70 6f 72 74 20 2a 0a 66 |xfile im|port *.f|
|000014c0| 69 6c 65 20 3d 20 6f 70 | 65 6e 28 27 2f 74 6d 70 |ile = op|en('/tmp|
|000014d0| 2f 74 65 73 74 27 2c 20 | 27 77 27 29 0a 66 69 6c |/test', |'w').fil|
|000014e0| 65 2e 6c 6f 63 6b 28 27 | 77 7c 27 29 0a 66 69 6c |e.lock('|w|').fil|
|000014f0| 65 2e 6c 6f 63 6b 28 27 | 75 27 29 0a 66 69 6c 65 |e.lock('|u').file|
|00001500| 2e 63 6c 6f 73 65 28 29 | 0a 5c 65 6e 64 7b 76 65 |.close()|.\end{ve|
|00001510| 72 62 61 74 69 6d 7d 5c | 65 63 6f 64 65 0a |rbatim}\|ecode. |
+--------+-------------------------+-------------------------+--------+--------+