annotate file.rhope @ 134:386f4a874821

More work on new parser
author Mike Pavone <pavone@retrodev.com>
date Wed, 10 Nov 2010 22:29:49 -0500
parents 25a205094f9b
children ac5c2d78663f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
2 //This implementation will change quite a bit once the transaction system is working
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
3 //and I've finalized how File I/O will fit into that. This is just a very basic
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
4 //implementation to allow the compiler to be self-hosting.
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
5
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
6 Foreign C:libc
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
7 {
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
8 open[name(Array,Raw Pointer),flags(Int32,Naked),mode(UInt32,Naked):filedes(Int32,Naked)]
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
9 close[filedes(Int32,Naked):status(Int32,Naked)]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
10 fsync[filedes(Int32,Naked):status(Int32,Naked)]
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
11 fstat[filedes(Int32,Naked),buf(Stat,Raw Pointer,Mutable):err(Int32,Naked),buf]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
12 lseek[filedes(Int32,Naked),offset(Int64,Naked),whence(Int32,Naked):out(Int64,Naked)]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
13 ftruncate[filedes(Int32,Naked),length(Int64,Naked):status(Int32,Naked)]
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
14 }
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 Blueprint Stat
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
18 Device(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
19 Inode(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
20 Link Count(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
21 Mode(UInt32,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
22 Owner ID(UInt32,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
23 Group ID(UInt32,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
24 Pad0(Int32,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
25 RDevice(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
26 Size(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
27 Block Size(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
28 Block Count(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
29 Access Time(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
30 Access Time Nano(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
31 Mod Time(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
32 Mod Time Nano(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
33 Status Time(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
34 Status Time Nano(UInt64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
35 Unused1(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
36 Unused2(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
37 Unused3(Int64,Naked)
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
38 }
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
39
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
40 Stat[fd:out]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
41 {
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
42 err,out <- fstat[fd, Build[Stat()]]
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 Blueprint File
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 Name
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 Blueprint File Read
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 Name
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 Descriptor(Int32,Naked)
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 Info
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 Blueprint File Write
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 Name
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 Descriptor(Int32,Naked)
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 Info
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 Blueprint File ReadWrite
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 Name
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 Read Offset(Int64,Naked)
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 Descriptor(Int32,Naked)
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 Info
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 File[name:out]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 out <- [Build[File()]]Name <<[name]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78 Open@File[file,mode:out,error]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 If[[mode]=["r"]]
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
81 {
82
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
82 imode <- 0i32
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
83 type <- File Read()
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84 out <- Val[ofile]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
85 }{
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
86 If[[mode]=["w"]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
87 {
82
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
88 imode <- 65i32
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
89 type <- File Write()
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90 out <- Val[ofile]
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
91 If[[fd]!=[-1i32]]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
92 { lseek[fd, 0i64, 2i32] }
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93 }{
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 ,error <- If[[mode]=["rw"]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95 {
82
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
96 imode <- 66i32
2e2e55fc12f9 Fix bug with conditionally assigning a literal or input to a named pipe
Mike Pavone <pavone@retrodev.com>
parents: 81
diff changeset
97 type <- File ReadWrite()
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 out <- [ofile]Read Offset <<[0i64]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
101 }
100
f51c4c17457c Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents: 82
diff changeset
102 fd <- open[[[[[file]Name >>]Flatten]Buffer >>]Append[0u8], imode, 438u32]
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
103 error <- If[[fd]=[-1i32]] {}
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 {
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
105 ofile <- [[[Build[type]
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 ]Name <<[ [file]Name >> ]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107 ]Descriptor <<[fd]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 ]Info <<[Stat[fd]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
110 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
111
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
112 Read@File[file,bytes:data,outfile,error]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
113 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
114 ,error <- [file]Open["r"]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
115 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
116 data,outfile,error <- [~]Read[bytes]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
117 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
118 }
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
119 /*
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
120 Append@File[file,data:out,error]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
121 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
122 ,error <- [file]Open["w"]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
123 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
124 out,error <- [~]Append[data]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
125 }
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
126 }*/
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
127
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
128 String@File[file:out,error]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
129 {
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
130 f,error <- [file]Open["r"]
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
131 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
132 out,error <- String[~]
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
133 { Close[f] }
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
134 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
135 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
136
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
137 Truncate@File[file:out,error]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
138 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
139 f,error <- [file]Open["w"]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
140 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
141 out,error <- Truncate[f]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
142 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
143 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
144
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
145 Write@File[file,data:out,error]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
146 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
147 f,error <- [file]Open["w"]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
148 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
149 out,error <- [f]Write[data]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
150 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
151 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
152
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
153
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
154 String@File Read[file:out,error]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
155 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
156 ,error <- [file]Read[[file]Length]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
157 { out <- String[~] }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
158 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
159
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
160 Read@File Read[file,inbytes(Int32):data,outfile,error]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
161 {
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
162 readbytes, mdata <- read[[file]Descriptor >>, [Array[]]Set[inbytes, 0u8], Int64[inbytes]]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
163 error <- If[[readbytes]<[0i64]] {}
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
164 {
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
165 outfile <- file
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
166 data <- [mdata]Length <<[ Trunc Int32[readbytes] ]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
167 }
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
168 /*
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
169 //Skip buffering for now. Buffering approach may need to change later anyway
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
170 buflen <- [[file]Buffer >>]Length
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
171 If[buflen]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
172 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
173 If[[inbytes]=[buflen]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
174 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
175 data <- [file]Buffer >>
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
176 outfile <- [file]Buffer <<[Array[]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
177 }{
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
178 If[[inbytes]<[buflen]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
179 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
180
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
181 }{
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
182
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
183 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
184 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
185 }{
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
186 readbytes, mdata <- read[[file]Descriptor >>, [Array[]]Set[inbytes, 0u8], Int64[inbytes]]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
187 error <- If[[readbytes]<[0i64]] {}
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
188 {
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
189 outfile <- file
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
190 data <- [mdata]Length <<[ Trunc Int32[readbytes] ]
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
191 }
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
192 } */
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
193 }
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
194
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
195 Length@File Read[file:out]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
196 {
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
197 out <- Trunc Int32[[[file]Info >>]Size >>]
79
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
198 }
80d8c9248f85 Began work on File
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
199
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
200 Close@File Read[file:out]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
201 {
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
202 close[[file]Descriptor >>]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
203 out <- File[[file]Name >>]
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
204 }
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
205
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
206 Length@File Write[file:out]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
207 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
208 out <- Trunc Int32[[[file]Info >>]Size >>]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
209 }
80
d78613686a38 Some progress on File
Mike Pavone <pavone@retrodev.com>
parents: 79
diff changeset
210
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
211 Truncate@File Write[file:out,err]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
212 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
213 err <- If[ftruncate[[file]Descriptor >>, 0i64]] {}
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
214 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
215 err <- If[lseek[[file]Descriptor >>, 0i64, 0i32]] {}
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
216 { out <- [file]Info <<[ [[file]Info >>]Size <<[0i64] ] }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
217 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
218 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
219
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
220 Write@File Write[file,data(Array):out,err]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
221 {
114
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
222 err <- If[[write[[file]Descriptor >>, data, Int64[[data]Length >>]]]<[0i32]] {}
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
223 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
224 out <- file
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
225 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
226 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
227
114
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
228 Write to File@String[str,file:out,err]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
229 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
230 out,err <- [file]Write[[str]Buffer >>]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
231 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
232
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
233 Write to File@String Slice[str,file:out,err]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
234 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
235 out,err <- [[str]Flatten]Write to File[file]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
236 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
237
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
238 Write to File@String Cat[str,file:out,err]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
239 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
240 ,err <- [[str]Left >>]Write to File[file]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
241 { out,err <- [[str]Right >>]Write to File[~] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
242 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents: 100
diff changeset
243
81
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
244 Close@File Write[file:out]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
245 {
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
246 fsync[[file]Descriptor >>]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
247 { close[[file]Descriptor >>] }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
248 out <- File[[file]Name >>]
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
249 }
dbe95bfec970 Very basic file access is now working; however, there's a bug involving assigning a literal to a named pipe inside a conditional block that needs fixing
Mike Pavone <pavone@retrodev.com>
parents: 80
diff changeset
250