Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/blume-private-devel/src/system/Basis/Implementation/Unix/posix-text-prim-io.sml
ViewVC logotype

Diff of /sml/branches/blume-private-devel/src/system/Basis/Implementation/Unix/posix-text-prim-io.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1492, Tue May 18 21:19:57 2004 UTC revision 1493, Tue May 18 21:19:57 2004 UTC
# Line 25  Line 25 
25    end = struct    end = struct
26    
27      structure PF = Posix.FileSys      structure PF = Posix.FileSys
28        structure PIO = Posix.IO
29      structure BinPrimIO = PosixBinPrimIO      structure BinPrimIO = PosixBinPrimIO
30      structure PrimIO = TextPrimIO      structure PrimIO = TextPrimIO
31    
# Line 32  Line 33 
33    
34      val bufferSzB = 4096      val bufferSzB = 4096
35    
36   (* If Char.char is really Word8.word, then very efficient versions of      val mkReader = PIO.mkTextReader
37    * translateIn and translateOut are possible:      val mkWriter = PIO.mkTextWriter
   *)  
     val translateIn : BinPrimIO.PrimIO.reader -> PrimIO.reader = InlineT.cast  
     val translateOut : BinPrimIO.PrimIO.writer -> PrimIO.writer = InlineT.cast  
   
     fun openRd fname = translateIn(BinPrimIO.openRd fname)  
     fun openWr fname = translateOut(BinPrimIO.openWr fname)  
     fun openApp fname = translateOut(BinPrimIO.openApp fname)  
38    
39      fun mkReader args = translateIn(BinPrimIO.mkReader args)      fun announce s x y = (
40      fun mkWriter args = translateOut(BinPrimIO.mkWriter args)            (*print "Posix: "; print (s:string); print "\n"; *)
41              x y)
42    
43        fun openRd name =
44            mkReader { fd = announce "openf"
45                                     PF.openf (name, PIO.O_RDONLY, PF.O.flags []),
46                       name = name,
47                       initBlkMode = true }
48    
49        val standardMode = PF.S.flags[      (* mode 0666 *)
50                PF.S.irusr, PF.S.iwusr,
51                PF.S.irgrp, PF.S.iwgrp,
52                PF.S.iroth, PF.S.iwoth
53              ]
54    
55        fun createFile (name, mode, flags) =
56            announce "createf" PF.createf (name, mode, flags, standardMode)
57    
58        fun openWr name =
59            mkWriter { fd = createFile (name, PIO.O_WRONLY, PF.O.trunc),
60                       name = name,
61                       initBlkMode = true,
62                       appendMode = false,
63                       chunkSize = bufferSzB }
64    
65        fun openApp name =
66            mkWriter { fd = createFile (name, PIO.O_WRONLY, PF.O.append),
67                       name = name,
68                       initBlkMode = true,
69                       appendMode = true,
70                       chunkSize = bufferSzB }
71    
72      fun stdIn () = mkReader{      fun stdIn () = mkReader{
73              fd          = PF.stdin,              fd          = PF.stdin,

Legend:
Removed from v.1492  
changed lines
  Added in v.1493

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0