home *** CD-ROM | disk | FTP | other *** search
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.tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
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 0d 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 0d 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 | 0d 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 0d 0d 54 | 68 69 73 20 6d 6f 64 75 |ject}..T|his modu|
|000000a0| 6c 65 20 69 6d 70 6c 65 | 6d 65 6e 74 73 20 73 6f |le imple|ments so|
|000000b0| 6d 65 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 66 75 |me addit|ional fu|
|000000c0| 6e 63 74 69 6f 6e 61 6c | 69 74 79 20 6f 76 65 72 |nctional|ity over|
|000000d0| 20 74 68 65 20 62 75 69 | 6c 74 2d 69 6e 0d 66 69 | the bui|lt-in.fi|
|000000e0| 6c 65 20 6f 62 6a 65 63 | 74 73 2e 20 20 49 6e 20 |le objec|ts. In |
|000000f0| 70 61 72 74 69 63 75 6c | 61 72 2c 20 69 74 20 69 |particul|ar, it i|
|00000100| 6d 70 6c 65 6d 65 6e 74 | 73 20 66 69 6c 65 20 6c |mplement|s file l|
|00000110| 6f 63 6b 69 6e 67 2c 20 | 63 6f 6e 74 72 6f 6c 20 |ocking, |control |
|00000120| 6f 76 65 72 0d 74 68 65 | 20 66 69 6c 65 20 66 6c |over.the| file fl|
|00000130| 61 67 73 2c 20 61 6e 64 | 20 61 6e 20 65 61 73 79 |ags, and| an easy|
|00000140| 20 69 6e 74 65 72 66 61 | 63 65 20 74 6f 20 64 75 | interfa|ce to du|
|00000150| 70 6c 69 63 61 74 65 20 | 74 68 65 20 66 69 6c 65 |plicate |the file|
|00000160| 20 6f 62 6a 65 63 74 2e | 0d 54 68 65 20 6d 6f 64 | object.|.The mod|
|00000170| 75 6c 65 20 64 65 66 69 | 6e 65 73 20 61 20 6e 65 |ule defi|nes a ne|
|00000180| 77 20 66 69 6c 65 20 6f | 62 6a 65 63 74 2c 20 74 |w file o|bject, t|
|00000190| 68 65 20 70 6f 73 69 78 | 66 69 6c 65 20 6f 62 6a |he posix|file obj|
|000001a0| 65 63 74 2e 20 20 49 74 | 0d 69 6e 68 65 72 69 74 |ect. It|.inherit|
|000001b0| 73 20 61 6c 6c 20 74 68 | 65 20 73 74 61 6e 64 61 |s all th|e standa|
|000001c0| 72 64 20 66 69 6c 65 20 | 6f 62 6a 65 63 74 20 6d |rd file |object m|
|000001d0| 65 74 68 6f 64 73 20 61 | 6e 64 20 61 64 64 73 20 |ethods a|nd adds |
|000001e0| 74 68 65 20 6d 65 74 68 | 6f 64 73 0d 64 65 73 63 |the meth|ods.desc|
|000001f0| 72 69 62 65 64 20 62 65 | 6c 6f 77 2e 0d 0d 54 6f |ribed be|low...To|
|00000200| 20 69 6e 73 74 61 6e 74 | 69 61 74 65 20 61 20 70 | instant|iate a p|
|00000210| 6f 73 69 78 66 69 6c 65 | 20 6f 62 6a 65 63 74 2c |osixfile| object,|
|00000220| 20 75 73 65 20 74 68 65 | 20 5c 63 6f 64 65 7b 6f | use the| \code{o|
|00000230| 70 65 6e 28 29 7d 20 66 | 75 6e 63 74 69 6f 6e 20 |pen()} f|unction |
|00000240| 69 6e 0d 74 68 65 20 70 | 6f 73 69 78 66 69 6c 65 |in.the p|osixfile|
|00000250| 20 6d 6f 64 75 6c 65 2e | 20 20 54 68 65 20 72 65 | module.| The re|
|00000260| 73 75 6c 74 69 6e 67 20 | 6f 62 6a 65 63 74 20 6c |sulting |object l|
|00000270| 6f 6f 6b 73 20 61 6e 64 | 20 66 65 65 6c 73 20 74 |ooks and| feels t|
|00000280| 68 65 20 73 61 6d 65 20 | 61 73 0d 61 20 73 74 61 |he same |as.a sta|
|00000290| 6e 64 61 72 64 20 66 69 | 6c 65 20 6f 62 6a 65 63 |ndard fi|le objec|
|000002a0| 74 2e 0d 0d 54 68 65 20 | 70 6f 73 69 78 66 69 6c |t...The |posixfil|
|000002b0| 65 20 6d 6f 64 75 6c 65 | 20 64 65 66 69 6e 65 73 |e module| defines|
|000002c0| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 63 | the fol|lowing c|
|000002d0| 6f 6e 73 74 61 6e 74 73 | 3a 0d 0d 5c 72 65 6e 65 |onstants|:..\rene|
|000002e0| 77 63 6f 6d 6d 61 6e 64 | 7b 5c 69 6e 64 65 78 73 |wcommand|{\indexs|
|000002f0| 75 62 69 74 65 6d 7d 7b | 28 69 6e 20 6d 6f 64 75 |ubitem}{|(in modu|
|00000300| 6c 65 20 70 6f 73 69 78 | 66 69 6c 65 29 7d 0d 5c |le posix|file)}.\|
|00000310| 62 65 67 69 6e 7b 64 61 | 74 61 64 65 73 63 7d 7b |begin{da|tadesc}{|
|00000320| 53 45 45 4b 5f 53 45 54 | 7d 0d 6f 66 66 73 65 74 |SEEK_SET|}.offset|
|00000330| 20 69 73 20 63 61 6c 63 | 75 6c 61 74 65 64 20 66 | is calc|ulated f|
|00000340| 72 6f 6d 20 74 68 65 20 | 73 74 61 72 74 20 6f 66 |rom the |start of|
|00000350| 20 74 68 65 20 66 69 6c | 65 0d 5c 65 6e 64 7b 64 | the fil|e.\end{d|
|00000360| 61 74 61 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |atadesc}|..\begin|
|00000370| 7b 64 61 74 61 64 65 73 | 63 7d 7b 53 45 45 4b 5f |{datades|c}{SEEK_|
|00000380| 43 55 52 7d 0d 6f 66 66 | 73 65 74 20 69 73 20 63 |CUR}.off|set is c|
|00000390| 61 6c 63 75 6c 61 74 65 | 64 20 66 72 6f 6d 20 74 |alculate|d from t|
|000003a0| 68 65 20 63 75 72 72 65 | 6e 74 20 70 6f 73 69 74 |he curre|nt posit|
|000003b0| 69 6f 6e 20 69 6e 20 74 | 68 65 20 66 69 6c 65 0d |ion in t|he file.|
|000003c0| 5c 65 6e 64 7b 64 61 74 | 61 64 65 73 63 7d 0d 0d |\end{dat|adesc}..|
|000003d0| 5c 62 65 67 69 6e 7b 64 | 61 74 61 64 65 73 63 7d |\begin{d|atadesc}|
|000003e0| 7b 53 45 45 4b 5f 45 4e | 44 7d 0d 6f 66 66 73 65 |{SEEK_EN|D}.offse|
|000003f0| 74 20 69 73 20 63 61 6c | 63 75 6c 61 74 65 64 20 |t is cal|culated |
|00000400| 66 72 6f 6d 20 74 68 65 | 20 65 6e 64 20 6f 66 20 |from the| end of |
|00000410| 74 68 65 20 66 69 6c 65 | 0d 5c 65 6e 64 7b 64 61 |the file|.\end{da|
|00000420| 74 61 64 65 73 63 7d 0d | 0d 54 68 65 20 70 6f 73 |tadesc}.|.The pos|
|00000430| 69 78 66 69 6c 65 20 6d | 6f 64 75 6c 65 20 64 65 |ixfile m|odule de|
|00000440| 66 69 6e 65 73 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |fines th|e follow|
|00000450| 69 6e 67 20 66 75 6e 63 | 74 69 6f 6e 73 3a 0d 0d |ing func|tions:..|
|00000460| 5c 72 65 6e 65 77 63 6f | 6d 6d 61 6e 64 7b 5c 69 |\renewco|mmand{\i|
|00000470| 6e 64 65 78 73 75 62 69 | 74 65 6d 7d 7b 28 69 6e |ndexsubi|tem}{(in|
|00000480| 20 6d 6f 64 75 6c 65 20 | 70 6f 73 69 78 66 69 6c | module |posixfil|
|00000490| 65 29 7d 0d 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |e)}.\beg|in{funcd|
|000004a0| 65 73 63 7d 7b 6f 70 65 | 6e 7d 7b 66 69 6c 65 6e |esc}{ope|n}{filen|
|000004b0| 61 6d 65 5c 2c 20 6d 6f | 64 65 7d 0d 20 43 72 65 |ame\, mo|de}. Cre|
|000004c0| 61 74 65 20 61 20 6e 65 | 77 20 70 6f 73 69 78 66 |ate a ne|w posixf|
|000004d0| 69 6c 65 20 6f 62 6a 65 | 63 74 20 77 69 74 68 20 |ile obje|ct with |
|000004e0| 74 68 65 20 67 69 76 65 | 6e 20 66 69 6c 65 6e 61 |the give|n filena|
|000004f0| 6d 65 20 61 6e 64 20 6d | 6f 64 65 2e 20 20 54 68 |me and m|ode. Th|
|00000500| 65 0d 20 66 69 6c 65 6e | 61 6d 65 20 61 6e 64 20 |e. filen|ame and |
|00000510| 6d 6f 64 65 20 61 72 65 | 20 69 6e 74 65 72 70 72 |mode are| interpr|
|00000520| 65 74 65 64 20 74 68 65 | 20 73 61 6d 65 20 77 61 |eted the| same wa|
|00000530| 79 20 61 73 20 74 68 65 | 20 5c 63 6f 64 65 7b 6f |y as the| \code{o|
|00000540| 70 65 6e 28 29 7d 0d 20 | 62 75 69 6c 74 69 6e 20 |pen()}. |builtin |
|00000550| 66 75 6e 63 74 69 6f 6e | 2e 0d 5c 65 6e 64 7b 66 |function|..\end{f|
|00000560| 75 6e 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00000570| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 6f 70 65 6e 66 |{funcdes|c}{openf|
|00000580| 69 6c 65 7d 7b 66 69 6c | 65 6f 62 6a 65 63 74 7d |ile}{fil|eobject}|
|00000590| 0d 20 43 72 65 61 74 65 | 20 61 20 6e 65 77 20 70 |. Create| a new p|
|000005a0| 6f 73 69 78 66 69 6c 65 | 20 6f 62 6a 65 63 74 20 |osixfile| object |
|000005b0| 77 69 74 68 20 74 68 65 | 20 67 69 76 65 6e 20 73 |with the| given s|
|000005c0| 74 61 6e 64 61 72 64 20 | 66 69 6c 65 20 6f 62 6a |tandard |file obj|
|000005d0| 65 63 74 2e 0d 20 54 68 | 65 20 72 65 73 75 6c 74 |ect.. Th|e result|
|000005e0| 69 6e 67 20 6f 62 6a 65 | 63 74 20 68 61 73 20 74 |ing obje|ct has t|
|000005f0| 68 65 20 73 61 6d 65 20 | 66 69 6c 65 6e 61 6d 65 |he same |filename|
|00000600| 20 61 6e 64 20 6d 6f 64 | 65 20 61 73 20 74 68 65 | and mod|e as the|
|00000610| 20 6f 72 69 67 69 6e 61 | 6c 0d 20 66 69 6c 65 20 | origina|l. file |
|00000620| 6f 62 6a 65 63 74 2e 0d | 5c 65 6e 64 7b 66 75 6e |object..|\end{fun|
|00000630| 63 64 65 73 63 7d 0d 0d | 54 68 65 20 70 6f 73 69 |cdesc}..|The posi|
|00000640| 78 66 69 6c 65 20 6f 62 | 6a 65 63 74 20 64 65 66 |xfile ob|ject def|
|00000650| 69 6e 65 73 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |ines the| followi|
|00000660| 6e 67 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 6d 65 |ng addit|ional me|
|00000670| 74 68 6f 64 73 3a 0d 0d | 5c 72 65 6e 65 77 63 6f |thods:..|\renewco|
|00000680| 6d 6d 61 6e 64 7b 5c 69 | 6e 64 65 78 73 75 62 69 |mmand{\i|ndexsubi|
|00000690| 74 65 6d 7d 7b 28 70 6f | 73 69 78 66 69 6c 65 20 |tem}{(po|sixfile |
|000006a0| 6d 65 74 68 6f 64 29 7d | 0d 5c 62 65 67 69 6e 7b |method)}|.\begin{|
|000006b0| 66 75 6e 63 64 65 73 63 | 7d 7b 6c 6f 63 6b 7d 7b |funcdesc|}{lock}{|
|000006c0| 66 6d 74 5c 2c 20 5c 6f | 70 74 69 6f 6e 61 6c 7b |fmt\, \o|ptional{|
|000006d0| 6c 65 6e 5c 6f 70 74 69 | 6f 6e 61 6c 7b 5c 2c 20 |len\opti|onal{\, |
|000006e0| 73 74 61 72 74 0d 5c 6f | 70 74 69 6f 6e 61 6c 7b |start.\o|ptional{|
|000006f0| 5c 2c 20 77 68 65 6e 63 | 65 7d 7d 7d 7d 0d 20 4c |\, whenc|e}}}}. L|
|00000700| 6f 63 6b 20 74 68 65 20 | 73 70 65 63 69 66 69 65 |ock the |specifie|
|00000710| 64 20 73 65 63 74 69 6f | 6e 20 6f 66 20 74 68 65 |d sectio|n of the|
|00000720| 20 66 69 6c 65 20 74 68 | 61 74 20 74 68 65 20 66 | file th|at the f|
|00000730| 69 6c 65 20 6f 62 6a 65 | 63 74 20 69 73 0d 20 72 |ile obje|ct is. r|
|00000740| 65 66 65 72 72 69 6e 67 | 20 74 6f 2e 20 20 54 68 |eferring| to. Th|
|00000750| 65 20 66 6f 72 6d 61 74 | 20 69 73 20 65 78 70 6c |e format| is expl|
|00000760| 61 69 6e 65 64 0d 20 62 | 65 6c 6f 77 20 69 6e 20 |ained. b|elow in |
|00000770| 61 20 74 61 62 6c 65 2e | 20 20 54 68 65 20 5c 76 |a table.| The \v|
|00000780| 61 72 7b 6c 65 6e 7d 20 | 61 72 67 75 6d 65 6e 74 |ar{len} |argument|
|00000790| 20 73 70 65 63 69 66 69 | 65 73 20 74 68 65 20 6c | specifi|es the l|
|000007a0| 65 6e 67 74 68 20 6f 66 | 20 74 68 65 0d 20 73 65 |ength of| the. se|
|000007b0| 63 74 69 6f 6e 20 74 68 | 61 74 20 73 68 6f 75 6c |ction th|at shoul|
|000007c0| 64 20 62 65 20 6c 6f 63 | 6b 65 64 2e 20 54 68 65 |d be loc|ked. The|
|000007d0| 20 64 65 66 61 75 6c 74 | 20 69 73 20 5c 63 6f 64 | default| is \cod|
|000007e0| 65 7b 30 7d 2e 20 5c 76 | 61 72 7b 73 74 61 72 74 |e{0}. \v|ar{start|
|000007f0| 7d 0d 20 73 70 65 63 69 | 66 69 65 73 20 74 68 65 |}. speci|fies the|
|00000800| 20 73 74 61 72 74 69 6e | 67 20 6f 66 66 73 65 74 | startin|g offset|
|00000810| 20 6f 66 20 74 68 65 20 | 73 65 63 74 69 6f 6e 2c | of the |section,|
|00000820| 20 77 68 65 72 65 20 74 | 68 65 20 64 65 66 61 75 | where t|he defau|
|00000830| 6c 74 20 69 73 0d 20 5c | 63 6f 64 65 7b 30 7d 2e |lt is. \|code{0}.|
|00000840| 20 20 54 68 65 20 5c 76 | 61 72 7b 77 68 65 6e 63 | The \v|ar{whenc|
|00000850| 65 7d 20 61 72 67 75 6d | 65 6e 74 20 73 70 65 63 |e} argum|ent spec|
|00000860| 69 66 69 65 73 20 77 68 | 65 72 65 20 74 68 65 20 |ifies wh|ere the |
|00000870| 6f 66 66 73 65 74 20 69 | 73 0d 20 72 65 6c 61 74 |offset i|s. relat|
|00000880| 69 76 65 20 74 6f 2e 20 | 49 74 20 61 63 63 65 70 |ive to. |It accep|
|00000890| 74 73 20 6f 6e 65 20 6f | 66 20 74 68 65 20 63 6f |ts one o|f the co|
|000008a0| 6e 73 74 61 6e 74 73 20 | 5c 63 6f 64 65 7b 53 45 |nstants |\code{SE|
|000008b0| 45 4b 5f 53 45 54 7d 2c | 0d 20 5c 63 6f 64 65 7b |EK_SET},|. \code{|
|000008c0| 53 45 45 4b 5f 43 55 52 | 7d 20 6f 72 20 5c 63 6f |SEEK_CUR|} or \co|
|000008d0| 64 65 7b 53 45 45 4b 5f | 45 4e 44 7d 2e 20 20 54 |de{SEEK_|END}. T|
|000008e0| 68 65 20 64 65 66 61 75 | 6c 74 20 69 73 20 5c 63 |he defau|lt is \c|
|000008f0| 6f 64 65 7b 53 45 45 4b | 5f 53 45 54 7d 2e 0d 20 |ode{SEEK|_SET}.. |
|00000900| 46 6f 72 20 6d 6f 72 65 | 20 69 6e 66 6f 72 6d 61 |For more| informa|
|00000910| 74 69 6f 6e 20 61 62 6f | 75 74 20 74 68 65 20 61 |tion abo|ut the a|
|00000920| 72 67 75 6d 65 6e 74 73 | 20 72 65 66 65 72 20 74 |rguments| refer t|
|00000930| 6f 20 74 68 65 20 66 63 | 6e 74 6c 0d 20 6d 61 6e |o the fc|ntl. man|
|00000940| 75 61 6c 20 70 61 67 65 | 20 6f 6e 20 79 6f 75 72 |ual page| on your|
|00000950| 20 73 79 73 74 65 6d 2e | 0d 5c 65 6e 64 7b 66 75 | system.|.\end{fu|
|00000960| 6e 63 64 65 73 63 7d 0d | 0d 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|00000970| 66 75 6e 63 64 65 73 63 | 7d 7b 66 6c 61 67 73 7d |funcdesc|}{flags}|
|00000980| 7b 66 6d 74 7d 0d 20 53 | 65 74 20 74 68 65 20 73 |{fmt}. S|et the s|
|00000990| 70 65 63 69 66 69 65 64 | 20 66 6c 61 67 73 20 66 |pecified| flags f|
|000009a0| 6f 72 20 74 68 65 20 66 | 69 6c 65 20 74 68 61 74 |or the f|ile that|
|000009b0| 20 74 68 65 20 66 69 6c | 65 20 6f 62 6a 65 63 74 | the fil|e object|
|000009c0| 20 69 73 20 72 65 66 65 | 72 72 69 6e 67 0d 20 74 | is refe|rring. t|
|000009d0| 6f 2e 20 20 54 68 65 20 | 6e 65 77 20 66 6c 61 67 |o. The |new flag|
|000009e0| 73 20 61 72 65 20 4f 52 | 65 64 20 77 69 74 68 20 |s are OR|ed with |
|000009f0| 74 68 65 20 6f 6c 64 20 | 66 6c 61 67 73 2c 20 75 |the old |flags, u|
|00000a00| 6e 6c 65 73 73 20 73 70 | 65 63 69 66 69 65 64 0d |nless sp|ecified.|
|00000a10| 20 6f 74 68 65 72 77 69 | 73 65 2e 20 20 54 68 65 | otherwi|se. The|
|00000a20| 20 66 6f 72 6d 61 74 20 | 69 73 20 65 78 70 6c 61 | format |is expla|
|00000a30| 69 6e 65 64 20 62 65 6c | 6f 77 20 69 6e 20 61 20 |ined bel|ow in a |
|00000a40| 74 61 62 6c 65 2e 20 20 | 57 69 74 68 6f 75 74 0d |table. |Without.|
|00000a50| 20 61 72 67 75 6d 65 6e | 74 73 20 61 20 73 74 72 | argumen|ts a str|
|00000a60| 69 6e 67 20 69 6e 64 69 | 63 61 74 69 6e 67 20 74 |ing indi|cating t|
|00000a70| 68 65 20 63 75 72 72 65 | 6e 74 20 66 6c 61 67 73 |he curre|nt flags|
|00000a80| 20 69 73 20 72 65 74 75 | 72 6e 65 64 20 28 74 68 | is retu|rned (th|
|00000a90| 69 73 20 69 73 0d 20 74 | 68 65 20 73 61 6d 65 20 |is is. t|he same |
|00000aa0| 61 73 20 74 68 65 20 27 | 3f 27 20 6d 6f 64 69 66 |as the '|?' modif|
|00000ab0| 69 65 72 29 2e 20 20 46 | 6f 72 20 6d 6f 72 65 20 |ier). F|or more |
|00000ac0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 61 62 6f 75 |informat|ion abou|
|00000ad0| 74 20 74 68 65 20 66 6c | 61 67 73 0d 20 72 65 66 |t the fl|ags. ref|
|00000ae0| 65 72 20 74 6f 20 74 68 | 65 20 66 63 6e 74 6c 20 |er to th|e fcntl |
|00000af0| 6d 61 6e 75 61 6c 20 70 | 61 67 65 20 6f 6e 20 79 |manual p|age on y|
|00000b00| 6f 75 72 20 73 79 73 74 | 65 6d 2e 0d 5c 65 6e 64 |our syst|em..\end|
|00000b10| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 5c 62 65 67 |{funcdes|c}..\beg|
|00000b20| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 64 75 70 |in{funcd|esc}{dup|
|00000b30| 7d 7b 7d 0d 20 44 75 70 | 6c 69 63 61 74 65 20 74 |}{}. Dup|licate t|
|00000b40| 68 65 20 66 69 6c 65 20 | 6f 62 6a 65 63 74 20 61 |he file |object a|
|00000b50| 6e 64 20 74 68 65 20 75 | 6e 64 65 72 6c 79 69 6e |nd the u|nderlyin|
|00000b60| 67 20 66 69 6c 65 20 70 | 6f 69 6e 74 65 72 20 61 |g file p|ointer a|
|00000b70| 6e 64 20 66 69 6c 65 0d | 20 64 65 73 63 72 69 70 |nd file.| descrip|
|00000b80| 74 6f 72 2e 20 20 54 68 | 65 20 72 65 73 75 6c 74 |tor. Th|e result|
|00000b90| 69 6e 67 20 6f 62 6a 65 | 63 74 20 62 65 68 61 76 |ing obje|ct behav|
|00000ba0| 65 73 20 61 73 20 69 66 | 20 69 74 20 77 65 72 65 |es as if| it were|
|00000bb0| 20 6e 65 77 6c 79 0d 20 | 6f 70 65 6e 65 64 2e 0d | newly. |opened..|
|00000bc0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000bd0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000be0| 7b 64 75 70 32 7d 7b 66 | 64 7d 0d 20 44 75 70 6c |{dup2}{f|d}. Dupl|
|00000bf0| 69 63 61 74 65 20 74 68 | 65 20 66 69 6c 65 20 6f |icate th|e file o|
|00000c00| 62 6a 65 63 74 20 61 6e | 64 20 74 68 65 20 75 6e |bject an|d the un|
|00000c10| 64 65 72 6c 79 69 6e 67 | 20 66 69 6c 65 20 70 6f |derlying| file po|
|00000c20| 69 6e 74 65 72 20 61 6e | 64 20 66 69 6c 65 0d 20 |inter an|d file. |
|00000c30| 64 65 73 63 72 69 70 74 | 6f 72 2e 20 20 54 68 65 |descript|or. The|
|00000c40| 20 6e 65 77 20 6f 62 6a | 65 63 74 20 77 69 6c 6c | new obj|ect will|
|00000c50| 20 68 61 76 65 20 74 68 | 65 20 67 69 76 65 6e 20 | have th|e given |
|00000c60| 66 69 6c 65 20 64 65 73 | 63 72 69 70 74 6f 72 2e |file des|criptor.|
|00000c70| 0d 20 4f 74 68 65 72 77 | 69 73 65 20 74 68 65 20 |. Otherw|ise the |
|00000c80| 72 65 73 75 6c 74 69 6e | 67 20 6f 62 6a 65 63 74 |resultin|g object|
|00000c90| 20 62 65 68 61 76 65 73 | 20 61 73 20 69 66 20 69 | behaves| as if i|
|00000ca0| 74 20 77 65 72 65 20 6e | 65 77 6c 79 20 6f 70 65 |t were n|ewly ope|
|00000cb0| 6e 65 64 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ned..\en|d{funcde|
|00000cc0| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|00000cd0| 64 65 73 63 7d 7b 66 69 | 6c 65 7d 7b 7d 0d 20 52 |desc}{fi|le}{}. R|
|00000ce0| 65 74 75 72 6e 20 74 68 | 65 20 73 74 61 6e 64 61 |eturn th|e standa|
|00000cf0| 72 64 20 66 69 6c 65 20 | 6f 62 6a 65 63 74 20 74 |rd file |object t|
|00000d00| 68 61 74 20 74 68 65 20 | 70 6f 73 69 78 66 69 6c |hat the |posixfil|
|00000d10| 65 20 6f 62 6a 65 63 74 | 20 69 73 20 62 61 73 65 |e object| is base|
|00000d20| 64 0d 20 6f 6e 2e 20 20 | 54 68 69 73 20 69 73 20 |d. on. |This is |
|00000d30| 73 6f 6d 65 74 69 6d 65 | 73 20 6e 65 63 65 73 73 |sometime|s necess|
|00000d40| 61 72 79 20 66 6f 72 20 | 66 75 6e 63 74 69 6f 6e |ary for |function|
|00000d50| 73 20 74 68 61 74 20 69 | 6e 73 69 73 74 20 6f 6e |s that i|nsist on|
|00000d60| 20 61 0d 20 73 74 61 6e | 64 61 72 64 20 66 69 6c | a. stan|dard fil|
|00000d70| 65 20 6f 62 6a 65 63 74 | 2e 0d 5c 65 6e 64 7b 66 |e object|..\end{f|
|00000d80| 75 6e 63 64 65 73 63 7d | 0d 0d 41 6c 6c 20 6d 65 |uncdesc}|..All me|
|00000d90| 74 68 6f 64 73 20 72 65 | 74 75 72 6e 20 5c 63 6f |thods re|turn \co|
|00000da0| 64 65 7b 49 4f 45 72 72 | 6f 72 7d 20 77 68 65 6e |de{IOErr|or} when|
|00000db0| 20 74 68 65 20 72 65 71 | 75 65 73 74 20 66 61 69 | the req|uest fai|
|00000dc0| 6c 73 2e 0d 0d 46 6f 72 | 6d 61 74 20 63 68 61 72 |ls...For|mat char|
|00000dd0| 61 63 74 65 72 73 20 66 | 6f 72 20 74 68 65 20 5c |acters f|or the \|
|00000de0| 63 6f 64 65 7b 6c 6f 63 | 6b 28 29 7d 20 6d 65 74 |code{loc|k()} met|
|00000df0| 68 6f 64 20 68 61 76 65 | 20 74 68 65 20 66 6f 6c |hod have| the fol|
|00000e00| 6c 6f 77 69 6e 67 20 6d | 65 61 6e 69 6e 67 3a 0d |lowing m|eaning:.|
|00000e10| 0d 5c 62 65 67 69 6e 7b | 74 61 62 6c 65 69 69 69 |.\begin{|tableiii|
|00000e20| 7d 7b 7c 63 7c 6c 7c 63 | 7c 7d 7b 73 61 6d 70 7d |}{|c|l|c||}{samp}|
|00000e30| 7b 46 6f 72 6d 61 74 7d | 7b 4d 65 61 6e 69 6e 67 |{Format}|{Meaning|
|00000e40| 7d 7b 7d 0d 20 20 5c 6c | 69 6e 65 69 69 69 7b 75 |}{}. \l|ineiii{u|
|00000e50| 7d 7b 75 6e 6c 6f 63 6b | 20 74 68 65 20 73 70 65 |}{unlock| the spe|
|00000e60| 63 69 66 69 65 64 20 72 | 65 67 69 6f 6e 7d 7b 7d |cified r|egion}{}|
|00000e70| 0d 20 20 5c 6c 69 6e 65 | 69 69 69 7b 72 7d 7b 72 |. \line|iii{r}{r|
|00000e80| 65 71 75 65 73 74 20 61 | 20 72 65 61 64 20 6c 6f |equest a| read lo|
|00000e90| 63 6b 20 66 6f 72 20 74 | 68 65 20 73 70 65 63 69 |ck for t|he speci|
|00000ea0| 66 69 65 64 20 73 65 63 | 74 69 6f 6e 7d 7b 7d 0d |fied sec|tion}{}.|
|00000eb0| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 77 7d 7b 72 65 | \linei|ii{w}{re|
|00000ec0| 71 75 65 73 74 20 61 20 | 77 72 69 74 65 20 6c 6f |quest a |write lo|
|00000ed0| 63 6b 20 66 6f 72 20 74 | 68 65 20 73 70 65 63 69 |ck for t|he speci|
|00000ee0| 66 69 65 64 20 73 65 63 | 74 69 6f 6e 7d 7b 7d 0d |fied sec|tion}{}.|
|00000ef0| 5c 65 6e 64 7b 74 61 62 | 6c 65 69 69 69 7d 0d 0d |\end{tab|leiii}..|
|00000f00| 49 6e 20 61 64 64 69 74 | 69 6f 6e 20 74 68 65 20 |In addit|ion the |
|00000f10| 66 6f 6c 6c 6f 77 69 6e | 67 20 6d 6f 64 69 66 69 |followin|g modifi|
|00000f20| 65 72 73 20 63 61 6e 20 | 62 65 20 61 64 64 65 64 |ers can |be added|
|00000f30| 20 74 6f 20 74 68 65 20 | 66 6f 72 6d 61 74 3a 0d | to the |format:.|
|00000f40| 0d 5c 62 65 67 69 6e 7b | 74 61 62 6c 65 69 69 69 |.\begin{|tableiii|
|00000f50| 7d 7b 7c 63 7c 6c 7c 63 | 7c 7d 7b 73 61 6d 70 7d |}{|c|l|c||}{samp}|
|00000f60| 7b 4d 6f 64 69 66 69 65 | 72 7d 7b 4d 65 61 6e 69 |{Modifie|r}{Meani|
|00000f70| 6e 67 7d 7b 4e 6f 74 65 | 73 7d 0d 20 20 5c 6c 69 |ng}{Note|s}. \li|
|00000f80| 6e 65 69 69 69 7b 7c 7d | 7b 77 61 69 74 20 75 6e |neiii{|}|{wait un|
|00000f90| 74 69 6c 20 74 68 65 20 | 6c 6f 63 6b 20 68 61 73 |til the |lock has|
|00000fa0| 20 62 65 65 6e 20 67 72 | 61 6e 74 65 64 7d 7b 7d | been gr|anted}{}|
|00000fb0| 0d 20 20 5c 6c 69 6e 65 | 69 69 69 7b 3f 7d 7b 72 |. \line|iii{?}{r|
|00000fc0| 65 74 75 72 6e 20 74 68 | 65 20 66 69 72 73 74 20 |eturn th|e first |
|00000fd0| 6c 6f 63 6b 20 63 6f 6e | 66 6c 69 63 74 69 6e 67 |lock con|flicting|
|00000fe0| 20 77 69 74 68 20 74 68 | 65 20 72 65 71 75 65 73 | with th|e reques|
|00000ff0| 74 65 64 20 6c 6f 63 6b | 2c 7d 7b 28 31 29 7d 0d |ted lock|,}{(1)}.|
|00001000| 20 20 7b 7d 26 7b 5c 68 | 73 6b 69 70 30 2e 35 63 | {}&{\h|skip0.5c|
|00001010| 6d 20 6f 72 20 5c 63 6f | 64 65 7b 4e 6f 6e 65 7d |m or \co|de{None}|
|00001020| 20 69 66 20 74 68 65 72 | 65 20 69 73 20 6e 6f 20 | if ther|e is no |
|00001030| 63 6f 6e 66 6c 69 63 74 | 2e 7d 26 7b 7d 5c 5c 0d |conflict|.}&{}\\.|
|00001040| 5c 65 6e 64 7b 74 61 62 | 6c 65 69 69 69 7d 0d 0d |\end{tab|leiii}..|
|00001050| 4e 6f 74 65 3a 0d 0d 28 | 31 29 20 54 68 65 20 6c |Note:..(|1) The l|
|00001060| 6f 63 6b 20 72 65 74 75 | 72 6e 65 64 20 69 73 20 |ock retu|rned is |
|00001070| 69 6e 20 74 68 65 20 66 | 6f 72 6d 61 74 20 5c 63 |in the f|ormat \c|
|00001080| 6f 64 65 7b 28 6d 6f 64 | 65 2c 20 6c 65 6e 2c 20 |ode{(mod|e, len, |
|00001090| 73 74 61 72 74 2c 0d 77 | 68 65 6e 63 65 2c 20 70 |start,.w|hence, p|
|000010a0| 69 64 29 7d 20 77 68 65 | 72 65 20 6d 6f 64 65 20 |id)} whe|re mode |
|000010b0| 69 73 20 61 20 63 68 61 | 72 61 63 74 65 72 20 72 |is a cha|racter r|
|000010c0| 65 70 72 65 73 65 6e 74 | 69 6e 67 20 74 68 65 20 |epresent|ing the |
|000010d0| 74 79 70 65 20 6f 66 20 | 6c 6f 63 6b 0d 28 27 72 |type of |lock.('r|
|000010e0| 27 20 6f 72 20 27 77 27 | 29 2e 20 20 54 68 69 73 |' or 'w'|). This|
|000010f0| 20 6d 6f 64 69 66 69 65 | 72 20 70 72 65 76 65 6e | modifie|r preven|
|00001100| 74 73 20 61 20 72 65 71 | 75 65 73 74 20 66 72 6f |ts a req|uest fro|
|00001110| 6d 20 62 65 69 6e 67 20 | 67 72 61 6e 74 65 64 3b |m being |granted;|
|00001120| 20 69 74 0d 69 73 20 66 | 6f 72 20 71 75 65 72 79 | it.is f|or query|
|00001130| 20 70 75 72 70 6f 73 65 | 73 20 6f 6e 6c 79 2e 0d | purpose|s only..|
|00001140| 0d 46 6f 72 6d 61 74 20 | 63 68 61 72 61 63 74 65 |.Format |characte|
|00001150| 72 20 66 6f 72 20 74 68 | 65 20 5c 63 6f 64 65 7b |r for th|e \code{|
|00001160| 66 6c 61 67 73 28 29 7d | 20 6d 65 74 68 6f 64 20 |flags()}| method |
|00001170| 68 61 76 65 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |have the| followi|
|00001180| 6e 67 20 6d 65 61 6e 69 | 6e 67 3a 0d 0d 5c 62 65 |ng meani|ng:..\be|
|00001190| 67 69 6e 7b 74 61 62 6c | 65 69 69 69 7d 7b 7c 63 |gin{tabl|eiii}{|c|
|000011a0| 7c 6c 7c 63 7c 7d 7b 73 | 61 6d 70 7d 7b 46 6f 72 ||l|c|}{s|amp}{For|
|000011b0| 6d 61 74 7d 7b 4d 65 61 | 6e 69 6e 67 7d 7b 7d 0d |mat}{Mea|ning}{}.|
|000011c0| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 61 7d 7b 61 70 | \linei|ii{a}{ap|
|000011d0| 70 65 6e 64 20 6f 6e 6c | 79 20 66 6c 61 67 7d 7b |pend onl|y flag}{|
|000011e0| 7d 0d 20 20 5c 6c 69 6e | 65 69 69 69 7b 63 7d 7b |}. \lin|eiii{c}{|
|000011f0| 63 6c 6f 73 65 20 6f 6e | 20 65 78 65 63 20 66 6c |close on| exec fl|
|00001200| 61 67 7d 7b 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |ag}{}. |\lineiii|
|00001210| 7b 6e 7d 7b 6e 6f 20 64 | 65 6c 61 79 20 66 6c 61 |{n}{no d|elay fla|
|00001220| 67 20 28 61 6c 73 6f 20 | 63 61 6c 6c 65 64 20 6e |g (also |called n|
|00001230| 6f 6e 2d 62 6c 6f 63 6b | 69 6e 67 20 66 6c 61 67 |on-block|ing flag|
|00001240| 29 7d 7b 7d 0d 20 20 5c | 6c 69 6e 65 69 69 69 7b |)}{}. \|lineiii{|
|00001250| 73 7d 7b 73 79 6e 63 68 | 72 6f 6e 69 7a 61 74 69 |s}{synch|ronizati|
|00001260| 6f 6e 20 66 6c 61 67 7d | 7b 7d 0d 5c 65 6e 64 7b |on flag}|{}.\end{|
|00001270| 74 61 62 6c 65 69 69 69 | 7d 0d 0d 49 6e 20 61 64 |tableiii|}..In ad|
|00001280| 64 69 74 69 6f 6e 20 74 | 68 65 20 66 6f 6c 6c 6f |dition t|he follo|
|00001290| 77 69 6e 67 20 6d 6f 64 | 69 66 69 65 72 73 20 63 |wing mod|ifiers c|
|000012a0| 61 6e 20 62 65 20 61 64 | 64 65 64 20 74 6f 20 74 |an be ad|ded to t|
|000012b0| 68 65 20 66 6f 72 6d 61 | 74 3a 0d 0d 5c 62 65 67 |he forma|t:..\beg|
|000012c0| 69 6e 7b 74 61 62 6c 65 | 69 69 69 7d 7b 7c 63 7c |in{table|iii}{|c||
|000012d0| 6c 7c 63 7c 7d 7b 73 61 | 6d 70 7d 7b 4d 6f 64 69 |l|c|}{sa|mp}{Modi|
|000012e0| 66 69 65 72 7d 7b 4d 65 | 61 6e 69 6e 67 7d 7b 4e |fier}{Me|aning}{N|
|000012f0| 6f 74 65 73 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |otes}. |\lineiii|
|00001300| 7b 21 7d 7b 74 75 72 6e | 20 74 68 65 20 73 70 65 |{!}{turn| the spe|
|00001310| 63 69 66 69 65 64 20 66 | 6c 61 67 73 20 27 6f 66 |cified f|lags 'of|
|00001320| 66 27 2c 20 69 6e 73 74 | 65 61 64 20 6f 66 20 74 |f', inst|ead of t|
|00001330| 68 65 20 64 65 66 61 75 | 6c 74 20 27 6f 6e 27 7d |he defau|lt 'on'}|
|00001340| 7b 28 31 29 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |{(1)}. |\lineiii|
|00001350| 7b 3d 7d 7b 72 65 70 6c | 61 63 65 20 74 68 65 20 |{=}{repl|ace the |
|00001360| 66 6c 61 67 73 2c 20 69 | 6e 73 74 65 61 64 20 6f |flags, i|nstead o|
|00001370| 66 20 74 68 65 20 64 65 | 66 61 75 6c 74 20 27 4f |f the de|fault 'O|
|00001380| 52 27 20 6f 70 65 72 61 | 74 69 6f 6e 7d 7b 28 31 |R' opera|tion}{(1|
|00001390| 29 7d 0d 20 20 5c 6c 69 | 6e 65 69 69 69 7b 3f 7d |)}. \li|neiii{?}|
|000013a0| 7b 72 65 74 75 72 6e 20 | 61 20 73 74 72 69 6e 67 |{return |a string|
|000013b0| 20 69 6e 20 77 68 69 63 | 68 20 74 68 65 20 63 68 | in whic|h the ch|
|000013c0| 61 72 61 63 74 65 72 73 | 20 72 65 70 72 65 73 65 |aracters| represe|
|000013d0| 6e 74 20 74 68 65 20 66 | 6c 61 67 73 20 74 68 61 |nt the f|lags tha|
|000013e0| 74 0d 20 20 61 72 65 20 | 73 65 74 2e 7d 7b 28 32 |t. are |set.}{(2|
|000013f0| 29 7d 0d 5c 65 6e 64 7b | 74 61 62 6c 65 69 69 69 |)}.\end{|tableiii|
|00001400| 7d 0d 0d 4e 6f 74 65 3a | 0d 0d 28 31 29 20 54 68 |}..Note:|..(1) Th|
|00001410| 65 20 5c 63 6f 64 65 7b | 21 7d 20 61 6e 64 20 5c |e \code{|!} and \|
|00001420| 63 6f 64 65 7b 3d 7d 20 | 6d 6f 64 69 66 69 65 72 |code{=} |modifier|
|00001430| 73 20 61 72 65 20 6d 75 | 74 75 61 6c 6c 79 20 65 |s are mu|tually e|
|00001440| 78 63 6c 75 73 69 76 65 | 2e 0d 0d 28 32 29 20 54 |xclusive|...(2) T|
|00001450| 68 69 73 20 73 74 72 69 | 6e 67 20 72 65 70 72 65 |his stri|ng repre|
|00001460| 73 65 6e 74 73 20 74 68 | 65 20 66 6c 61 67 73 20 |sents th|e flags |
|00001470| 61 66 74 65 72 20 74 68 | 65 79 20 6d 61 79 20 68 |after th|ey may h|
|00001480| 61 76 65 20 62 65 65 6e | 20 61 6c 74 65 72 65 64 |ave been| altered|
|00001490| 0d 62 79 20 74 68 65 20 | 73 61 6d 65 20 63 61 6c |.by the |same cal|
|000014a0| 6c 2e 0d 0d 45 78 61 6d | 70 6c 65 73 3a 0d 0d 5c |l...Exam|ples:..\|
|000014b0| 62 63 6f 64 65 5c 62 65 | 67 69 6e 7b 76 65 72 62 |bcode\be|gin{verb|
|000014c0| 61 74 69 6d 7d 0d 66 72 | 6f 6d 20 70 6f 73 69 78 |atim}.fr|om posix|
|000014d0| 66 69 6c 65 20 69 6d 70 | 6f 72 74 20 2a 0d 0d 66 |file imp|ort *..f|
|000014e0| 69 6c 65 20 3d 20 6f 70 | 65 6e 28 27 2f 74 6d 70 |ile = op|en('/tmp|
|000014f0| 2f 74 65 73 74 27 2c 20 | 27 77 27 29 0d 66 69 6c |/test', |'w').fil|
|00001500| 65 2e 6c 6f 63 6b 28 27 | 77 7c 27 29 0d 2e 2e 2e |e.lock('|w|')....|
|00001510| 0d 66 69 6c 65 2e 6c 6f | 63 6b 28 27 75 27 29 0d |.file.lo|ck('u').|
|00001520| 66 69 6c 65 2e 63 6c 6f | 73 65 28 29 0d 5c 65 6e |file.clo|se().\en|
|00001530| 64 7b 76 65 72 62 61 74 | 69 6d 7d 5c 65 63 6f 64 |d{verbat|im}\ecod|
|00001540| 65 0d | |e. | |
+--------+-------------------------+-------------------------+--------+--------+