Mercurial > repos > rhope
comparison file.rhope @ 79:80d8c9248f85
Began work on File
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 10 Jul 2010 18:02:04 -0400 |
parents | |
children | d78613686a38 |
comparison
equal
deleted
inserted
replaced
78:4d5ea487f810 | 79:80d8c9248f85 |
---|---|
1 | |
2 | |
3 Blueprint Stat | |
4 { | |
5 | |
6 } | |
7 | |
8 Blueprint File | |
9 { | |
10 Name | |
11 } | |
12 | |
13 Blueprint File Read | |
14 { | |
15 Name | |
16 Descriptor(Int32,Naked) | |
17 Info | |
18 Buffer | |
19 } | |
20 | |
21 Blueprint File Write | |
22 { | |
23 Name | |
24 Descriptor(Int32,Naked) | |
25 Info | |
26 Buffer | |
27 } | |
28 | |
29 Blueprint File ReadWrite | |
30 { | |
31 Name | |
32 Read Offset(Int64,Naked) | |
33 Descriptor(Int32,Naked) | |
34 Info | |
35 Buffer | |
36 } | |
37 | |
38 File[name:out] | |
39 { | |
40 out <- [Build[File()]]Name <<[name] | |
41 } | |
42 | |
43 | |
44 Open@File[file,mode:out,error] | |
45 { | |
46 If[[mode]=["r"]] | |
47 { | |
48 imode <- | |
49 type <- File Read() | |
50 out <- Val[ofile] | |
51 }{ | |
52 If[[mode]=["w"]] | |
53 { | |
54 imode <- | |
55 type <- File Write() | |
56 out <- Val[ofile] | |
57 }{ | |
58 ,error <- If[[mode]=["rw"]] | |
59 { | |
60 imode <- | |
61 type <- File ReadWrite() | |
62 out <- [ofile]Read Offset <<[0i64] | |
63 } | |
64 } | |
65 } | |
66 fd <- open[[file]Name >>] | |
67 error <- If[[fd]=[-1i32]] {} | |
68 { | |
69 ofile <- [[[[Build[type] | |
70 ]Name <<[ [file]Name >> ] | |
71 ]Descriptor <<[fd] | |
72 ]Info <<[Stat[fd]] | |
73 ]Buffer <<[Array[]] | |
74 } | |
75 } | |
76 | |
77 Read@File[file,bytes:data,outfile,error] | |
78 { | |
79 ,error <- [file]Open["r"] | |
80 { | |
81 data,outfile,error <- [~]Read[bytes] | |
82 } | |
83 } | |
84 | |
85 Append@File[file,data:out,error] | |
86 { | |
87 ,error <- [file]Open["w"] | |
88 { | |
89 out,error <- [~]Append[data] | |
90 } | |
91 } | |
92 | |
93 String@File[file:out,error] | |
94 { | |
95 ,error <- [file]Open["w"] | |
96 { | |
97 out,error <- String[~] | |
98 } | |
99 } | |
100 | |
101 Read@File Read[file,inbytes(Int32):data,outfile,error] | |
102 { | |
103 buflen <- [[file]Buffer >>]Length | |
104 If[buflen] | |
105 { | |
106 If[[inbytes]=[buflen]] | |
107 { | |
108 data <- [file]Buffer >> | |
109 outfile <- [file]Buffer <<[Array[]] | |
110 }{ | |
111 If[[inbytes]<[buflen]] | |
112 { | |
113 | |
114 }{ | |
115 | |
116 } | |
117 } | |
118 }{ | |
119 readbytes, mdata <- read[[file]Descriptor >>, [Array[]]Set[inbytes, 0u8], Int64[inbytes]] | |
120 error <- If[[readbytes]<[0i64]] {} | |
121 { | |
122 outfile <- file | |
123 data <- [mdata]Length <<[ Trunc Int32[readbytes] ] | |
124 } | |
125 | |
126 } | |
127 } | |
128 |