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/Posix/posix-filesys.sml
ViewVC logotype

Diff of /sml/branches/blume-private-devel/src/system/Basis/Implementation/Posix/posix-filesys.sml

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

revision 1452, Mon Feb 9 20:33:28 2004 UTC revision 1453, Mon Feb 9 20:33:28 2004 UTC
# Line 96  Line 96 
96    
97      structure S =      structure S =
98        struct        struct
99          datatype flags = MODE of word          local structure BF = BitFlagsFn ()
100            in
101                open BF
102          type mode = flags          type mode = flags
103            end
104    
105          fun fromWord w = MODE w          val irwxu = fromWord (w_osval "irwxu")
106          fun toWord (MODE w) = w          val irusr = fromWord (w_osval "irusr")
107            val iwusr = fromWord (w_osval "iwusr")
108          fun flags ms = MODE(List.foldl (fn (MODE m,acc) => m ++ acc) 0w0 ms)          val ixusr = fromWord (w_osval "ixusr")
109          fun anySet (MODE m, MODE m') = (m & m') <> 0w0          val irwxg = fromWord (w_osval "irwxg")
110          fun allSet (MODE m, MODE m') = (m & m') = m          val irgrp = fromWord (w_osval "irgrp")
111            val iwgrp = fromWord (w_osval "iwgrp")
112          val irwxu = MODE(w_osval "irwxu")          val ixgrp = fromWord (w_osval "ixgrp")
113          val irusr = MODE(w_osval "irusr")          val irwxo = fromWord (w_osval "irwxo")
114          val iwusr = MODE(w_osval "iwusr")          val iroth = fromWord (w_osval "iroth")
115          val ixusr = MODE(w_osval "ixusr")          val iwoth = fromWord (w_osval "iwoth")
116          val irwxg = MODE(w_osval "irwxg")          val ixoth = fromWord (w_osval "ixoth")
117          val irgrp = MODE(w_osval "irgrp")          val isuid = fromWord (w_osval "isuid")
118          val iwgrp = MODE(w_osval "iwgrp")          val isgid = fromWord (w_osval "isgid")
         val ixgrp = MODE(w_osval "ixgrp")  
         val irwxo = MODE(w_osval "irwxo")  
         val iroth = MODE(w_osval "iroth")  
         val iwoth = MODE(w_osval "iwoth")  
         val ixoth = MODE(w_osval "ixoth")  
         val isuid = MODE(w_osval "isuid")  
         val isgid = MODE(w_osval "isgid")  
119    
120        end        end
121    
122      structure O =      structure O =
123        struct        struct
124          datatype flags = OFL of word          local structure BF = BitFlagsFn ()
125            in
126          fun fromWord w = OFL w              open BF
127          fun toWord (OFL w) = w          end
128    
129          fun flags ms = OFL(List.foldl (fn (OFL m,acc) => m ++ acc) 0w0 ms)          val append   = fromWord (w_osval "O_APPEND")
130          fun anySet (OFL m, OFL m') = (m & m') <> 0w0          val dsync    = fromWord (w_osval "O_DSYNC")
131          fun allSet (OFL m, OFL m') = (m & m') = m          val excl     = fromWord (w_osval "O_EXCL")
132            val noctty   = fromWord (w_osval "O_NOCTTY")
133          val append   = OFL(w_osval "O_APPEND")          val nonblock = fromWord (w_osval "O_NONBLOCK")
134          val dsync    = OFL(w_osval "O_DSYNC")          val rsync    = fromWord (w_osval "O_RSYNC")
135          val excl     = OFL(w_osval "O_EXCL")          val sync     = fromWord (w_osval "O_SYNC")
         val noctty   = OFL(w_osval "O_NOCTTY")  
         val nonblock = OFL(w_osval "O_NONBLOCK")  
         val rsync    = OFL(w_osval "O_RSYNC")  
         val sync     = OFL(w_osval "O_SYNC")  
136          val o_trunc  = w_osval "O_TRUNC"          val o_trunc  = w_osval "O_TRUNC"
137          val trunc    = OFL o_trunc          val trunc    = fromWord  o_trunc
138          val o_creat  = w_osval "O_CREAT"          val o_creat  = w_osval "O_CREAT"
139          val crflags  = o_wronly ++ o_creat ++ o_trunc          val crflags  = o_wronly ++ o_creat ++ o_trunc
140    
141        end        end
142    
143      val openf' : string * word * word -> s_int = cfun "openf"      val openf' : string * word * word -> s_int = cfun "openf"
144      fun openf (fname, omode, O.OFL flags) =      fun openf (fname, omode, flags) =
145            fd(openf'(fname, flags ++ (omodeToWord omode), 0w0))            fd(openf'(fname, O.toWord flags ++ (omodeToWord omode), 0w0))
146      fun createf (fname, omode, O.OFL oflags, S.MODE mode) = let      fun createf (fname, omode, oflags, mode) = let
147            val flags = O.o_creat ++ oflags ++ (omodeToWord omode)            val flags = O.o_creat ++ O.toWord oflags ++ (omodeToWord omode)
148            in            in
149              fd(openf'(fname, flags, mode))              fd(openf'(fname, flags, S.toWord mode))
150            end            end
151      fun creat (fname, S.MODE mode) =      fun creat (fname, mode) =
152            fd(openf'(fname, O.crflags, mode))            fd(openf'(fname, O.crflags, S.toWord mode))
153    
154      val umask' : word -> word = cfun "umask"      val umask' : word -> word = cfun "umask"
155      fun umask (S.MODE mode) = S.MODE(umask' mode)      fun umask mode = S.fromWord (umask' (S.toWord mode))
156    
157      val link' : string * string -> unit = cfun "link"      val link' : string * string -> unit = cfun "link"
158      fun link {old, new} = link'(old,new)      fun link {old, new} = link'(old,new)
# Line 170  Line 162 
162      fun symlink {old, new} = symlink'(old,new)      fun symlink {old, new} = symlink'(old,new)
163    
164      val mkdir' : string * word -> unit = cfun "mkdir"      val mkdir' : string * word -> unit = cfun "mkdir"
165      fun mkdir (dirname, S.MODE mode) = mkdir'(dirname,mode)      fun mkdir (dirname, mode) = mkdir'(dirname, S.toWord mode)
166    
167      val mkfifo' : string * word -> unit = cfun "mkfifo"      val mkfifo' : string * word -> unit = cfun "mkfifo"
168      fun mkfifo (name, S.MODE mode) = mkfifo'(name,mode)      fun mkfifo (name, mode) = mkfifo'(name, S.toWord mode)
169    
170      val unlink : string -> unit = cfun "unlink"      val unlink : string -> unit = cfun "unlink"
171      val rmdir : string -> unit = cfun "rmdir"      val rmdir : string -> unit = cfun "rmdir"
# Line 245  Line 237 
237        )        )
238      fun mkStat (sr : statrep) = ST.ST{      fun mkStat (sr : statrep) = ST.ST{
239              ftype = #1 sr,              ftype = #1 sr,
240              mode = S.MODE (#2 sr),              mode = S.fromWord (#2 sr),
241              ino = INO (#3 sr),              ino = INO (#3 sr),
242              dev = DEV (#4 sr),              dev = DEV (#4 sr),
243              nlink = SysWord.toInt(#5 sr),       (* probably should be an int in              nlink = SysWord.toInt(#5 sr),       (* probably should be an int in
# Line 283  Line 275 
275      fun access (fname, aml) = access'(fname, amodeToWord aml)      fun access (fname, aml) = access'(fname, amodeToWord aml)
276    
277      val chmod' : string * word -> unit = cfun "chmod"      val chmod' : string * word -> unit = cfun "chmod"
278      fun chmod (fname, S.MODE m) = chmod'(fname, m)      fun chmod (fname, m) = chmod'(fname, S.toWord m)
279    
280      val fchmod' : s_int * word -> unit = cfun "fchmod"      val fchmod' : s_int * word -> unit = cfun "fchmod"
281      fun fchmod (FD{fd}, S.MODE m) = fchmod'(fd, m)      fun fchmod (FD{fd}, m) = fchmod'(fd, S.toWord m)
282    
283      val chown' : string * word * word -> unit = cfun "chown"      val chown' : string * word * word -> unit = cfun "chown"
284      fun chown (fname, UID uid, GID gid) = chown'(fname, uid, gid)      fun chown (fname, UID uid, GID gid) = chown'(fname, uid, gid)

Legend:
Removed from v.1452  
changed lines
  Added in v.1453

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