Rev 7197 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7197 | Rev 7202 | ||
---|---|---|---|
1 | #ifndef INCLUDE_FILESYSTEM_H |
1 | #ifndef INCLUDE_FILESYSTEM_H |
2 | #define INCLUDE_FILESYSTEM_H |
2 | #define INCLUDE_FILESYSTEM_H |
3 | #print "[include |
3 | #print "[include |
4 | 4 | ||
5 | #ifndef INCLUDE_DATE_H |
5 | #ifndef INCLUDE_DATE_H |
6 | #include "../lib/date.h" |
6 | #include "../lib/date.h" |
7 | #endif |
7 | #endif |
8 | 8 | ||
9 | :struct f70{ |
9 | :struct f70{ |
10 | dword func; |
10 | dword func; |
11 | dword param1; |
11 | dword param1; |
12 | dword param2; |
12 | dword param2; |
13 | dword param3; |
13 | dword param3; |
14 | dword param4; |
14 | dword param4; |
15 | char rezerv; |
15 | char rezerv; |
16 | dword name; |
16 | dword name; |
17 | }; |
17 | }; |
18 | 18 | ||
19 | :struct BDVK { |
19 | :struct BDVK { |
20 | dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0; |
20 | dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0; |
21 | byte type_name; |
21 | byte type_name; |
22 | byte rez1, rez2, selected; |
22 | byte rez1, rez2, selected; |
23 | dword timecreate; |
23 | dword timecreate; |
24 | date datecreate; |
24 | date datecreate; |
25 | dword timelastaccess; |
25 | dword timelastaccess; |
26 | date datelastaccess; |
26 | date datelastaccess; |
27 | dword timelastedit; |
27 | dword timelastedit; |
28 | date datelastedit; |
28 | date datelastedit; |
29 | dword sizelo; |
29 | dword sizelo; |
30 | dword sizehi; |
30 | dword sizehi; |
31 | char name[518]; |
31 | char name[518]; |
32 | }; |
32 | }; |
33 | 33 | ||
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | /////////////////////////// |
38 | /////////////////////////// |
39 | // Ïàðàìåòðû ôàéëà // |
39 | // Ïàðàìåòðû ôàéëà // |
40 | /////////////////////////// |
40 | /////////////////////////// |
41 | :f70 getinfo_file_70; |
41 | :f70 getinfo_file_70; |
42 | :dword GetFileInfo(dword file_path, bdvk_struct) |
42 | :dword GetFileInfo(dword file_path, bdvk_struct) |
43 | { |
43 | { |
44 | getinfo_file_70.func = 5; |
44 | getinfo_file_70.func = 5; |
45 | getinfo_file_70.param1 = |
45 | getinfo_file_70.param1 = |
46 | getinfo_file_70.param2 = |
46 | getinfo_file_70.param2 = |
47 | getinfo_file_70.param3 = 0; |
47 | getinfo_file_70.param3 = 0; |
48 | getinfo_file_70.param4 = bdvk_struct; |
48 | getinfo_file_70.param4 = bdvk_struct; |
49 | getinfo_file_70.rezerv = 0; |
49 | getinfo_file_70.rezerv = 0; |
50 | getinfo_file_70.name = file_path; |
50 | getinfo_file_70.name = file_path; |
51 | $mov eax,70 |
51 | $mov eax,70 |
52 | $mov ebx,#getinfo_file_70.func |
52 | $mov ebx,#getinfo_file_70.func |
53 | $int 0x40 |
53 | $int 0x40 |
54 | } |
54 | } |
55 | 55 | ||
56 | ///////////////////////////////////// |
56 | ///////////////////////////////////// |
57 | // Èçìåíåíèå ïàðàìåòðîâ ôàéëà // |
57 | // Èçìåíåíèå ïàðàìåòðîâ ôàéëà // |
58 | ///////////////////////////////////// |
58 | ///////////////////////////////////// |
59 | :f70 setinfo_file_70; |
59 | :f70 setinfo_file_70; |
60 | :dword SetFileInfo(dword file_path, bdvk_struct) |
60 | :dword SetFileInfo(dword file_path, bdvk_struct) |
61 | { |
61 | { |
62 | setinfo_file_70.func = 6; |
62 | setinfo_file_70.func = 6; |
63 | setinfo_file_70.param1 = |
63 | setinfo_file_70.param1 = |
64 | setinfo_file_70.param2 = |
64 | setinfo_file_70.param2 = |
65 | setinfo_file_70.param3 = 0; |
65 | setinfo_file_70.param3 = 0; |
66 | setinfo_file_70.param4 = bdvk_struct; |
66 | setinfo_file_70.param4 = bdvk_struct; |
67 | setinfo_file_70.rezerv = 0; |
67 | setinfo_file_70.rezerv = 0; |
68 | setinfo_file_70.name = file_path; |
68 | setinfo_file_70.name = file_path; |
69 | $mov eax,70 |
69 | $mov eax,70 |
70 | $mov ebx,#setinfo_file_70.func |
70 | $mov ebx,#setinfo_file_70.func |
71 | $int 0x40 |
71 | $int 0x40 |
72 | } |
72 | } |
73 | 73 | ||
74 | /////////////////////////// |
74 | /////////////////////////// |
75 | // Çàïóñê ïðîãðàììû // |
75 | // Çàïóñê ïðîãðàììû // |
76 | /////////////////////////// |
76 | /////////////////////////// |
77 | :f70 run_file_70; |
77 | :f70 run_file_70; |
78 | :signed int RunProgram(dword run_path, run_param) |
78 | :signed int RunProgram(dword run_path, run_param) |
79 | { |
79 | { |
80 | run_file_70.func = 7; |
80 | run_file_70.func = 7; |
81 | run_file_70.param1 = |
81 | run_file_70.param1 = |
82 | run_file_70.param3 = |
82 | run_file_70.param3 = |
83 | run_file_70.param4 = |
83 | run_file_70.param4 = |
84 | run_file_70.rezerv = 0; |
84 | run_file_70.rezerv = 0; |
85 | run_file_70.param2 = run_param; |
85 | run_file_70.param2 = run_param; |
86 | run_file_70.name = run_path; |
86 | run_file_70.name = run_path; |
87 | $mov eax,70 |
87 | $mov eax,70 |
88 | $mov ebx,#run_file_70.func |
88 | $mov ebx,#run_file_70.func |
89 | $int 0x40 |
89 | $int 0x40 |
90 | } |
90 | } |
91 | 91 | ||
92 | /////////////////////////// |
92 | /////////////////////////// |
93 | // Ñîçäàíèå ïàïêè // |
93 | // Ñîçäàíèå ïàïêè // |
94 | /////////////////////////// |
94 | /////////////////////////// |
95 | :f70 create_dir_70; |
95 | :f70 create_dir_70; |
96 | :int CreateDir(dword new_folder_path) |
96 | :int CreateDir(dword new_folder_path) |
97 | { |
97 | { |
98 | create_dir_70.func = 9; |
98 | create_dir_70.func = 9; |
99 | create_dir_70.param1 = |
99 | create_dir_70.param1 = |
100 | create_dir_70.param2 = |
100 | create_dir_70.param2 = |
101 | create_dir_70.param3 = |
101 | create_dir_70.param3 = |
102 | create_dir_70.param4 = |
102 | create_dir_70.param4 = |
103 | create_dir_70.rezerv = 0; |
103 | create_dir_70.rezerv = 0; |
104 | create_dir_70.name = new_folder_path; |
104 | create_dir_70.name = new_folder_path; |
105 | $mov eax,70 |
105 | $mov eax,70 |
106 | $mov ebx,#create_dir_70.func |
106 | $mov ebx,#create_dir_70.func |
107 | $int 0x40 |
107 | $int 0x40 |
108 | } |
108 | } |
109 | 109 | ||
110 | //////////////////////////// |
110 | //////////////////////////// |
111 | // Óäàëåíèå ôàéëà/ïàïêè // |
111 | // Óäàëåíèå ôàéëà/ïàïêè // |
112 | //////////////////////////// |
112 | //////////////////////////// |
113 | :f70 del_file_70; |
113 | :f70 del_file_70; |
114 | :int DeleteFile(dword del_file_path) |
114 | :int DeleteFile(dword del_file_path) |
115 | { |
115 | { |
116 | del_file_70.func = 8; |
116 | del_file_70.func = 8; |
117 | del_file_70.param1 = |
117 | del_file_70.param1 = |
118 | del_file_70.param2 = |
118 | del_file_70.param2 = |
119 | del_file_70.param3 = |
119 | del_file_70.param3 = |
120 | del_file_70.param4 = |
120 | del_file_70.param4 = |
121 | del_file_70.rezerv = 0; |
121 | del_file_70.rezerv = 0; |
122 | del_file_70.name = del_file_path; |
122 | del_file_70.name = del_file_path; |
123 | $mov eax,70 |
123 | $mov eax,70 |
124 | $mov ebx,#del_file_70.func |
124 | $mov ebx,#del_file_70.func |
125 | $int 0x40 |
125 | $int 0x40 |
126 | } |
126 | } |
127 | 127 | ||
128 | //////////////////////////// |
128 | //////////////////////////// |
129 | // Ïðî÷èòàòü ôàéë // |
129 | // Ïðî÷èòàòü ôàéë // |
130 | //////////////////////////// |
130 | //////////////////////////// |
131 | :f70 read_file_70; |
131 | :f70 read_file_70; |
132 | :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path) |
132 | :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path) |
133 | { |
133 | { |
134 | read_file_70.func = 0; |
134 | read_file_70.func = 0; |
135 | read_file_70.param1 = read_pos; |
135 | read_file_70.param1 = read_pos; |
136 | read_file_70.param2 = 0; |
136 | read_file_70.param2 = 0; |
137 | read_file_70.param3 = read_file_size; |
137 | read_file_70.param3 = read_file_size; |
138 | read_file_70.param4 = read_buffer; |
138 | read_file_70.param4 = read_buffer; |
139 | read_file_70.rezerv = 0; |
139 | read_file_70.rezerv = 0; |
140 | read_file_70.name = read_file_path; |
140 | read_file_70.name = read_file_path; |
141 | $mov eax,70 |
141 | $mov eax,70 |
142 | $mov ebx,#read_file_70.func |
142 | $mov ebx,#read_file_70.func |
143 | $int 0x40 |
143 | $int 0x40 |
144 | } |
144 | } |
145 | 145 | ||
146 | /////////////////////////// |
146 | /////////////////////////// |
147 | // Çàïèñàòü ôàéë // |
147 | // Çàïèñàòü ôàéë // |
148 | /////////////////////////// |
148 | /////////////////////////// |
149 | :f70 write_file_70; |
149 | :f70 write_file_70; |
150 | :int WriteFile(dword write_file_size, write_buffer, write_file_path) |
150 | :int WriteFile(dword write_file_size, write_buffer, write_file_path) |
151 | { |
151 | { |
152 | write_file_70.func = 2; |
152 | write_file_70.func = 2; |
153 | write_file_70.param1 = 0; |
153 | write_file_70.param1 = 0; |
154 | write_file_70.param2 = 0; |
154 | write_file_70.param2 = 0; |
155 | write_file_70.param3 = write_file_size; |
155 | write_file_70.param3 = write_file_size; |
156 | write_file_70.param4 = write_buffer; |
156 | write_file_70.param4 = write_buffer; |
157 | write_file_70.rezerv = 0; |
157 | write_file_70.rezerv = 0; |
158 | write_file_70.name = write_file_path; |
158 | write_file_70.name = write_file_path; |
159 | $mov eax,70 |
159 | $mov eax,70 |
160 | $mov ebx,#write_file_70.func |
160 | $mov ebx,#write_file_70.func |
161 | $int 0x40 |
161 | $int 0x40 |
162 | } |
162 | } |
163 | 163 | ||
164 | //////////////////////////////////////// |
164 | //////////////////////////////////////// |
165 | // WriteInFileThatAlredyExists // |
165 | // WriteInFileThatAlredyExists // |
166 | //////////////////////////////////////// |
166 | //////////////////////////////////////// |
167 | :f70 write_file_offset_70; |
167 | :f70 write_file_offset_70; |
168 | :int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset) |
168 | :int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset) |
169 | { |
169 | { |
170 | write_file_offset_70.func = 3; |
170 | write_file_offset_70.func = 3; |
171 | write_file_offset_70.param1 = offset; |
171 | write_file_offset_70.param1 = offset; |
172 | write_file_offset_70.param2 = 0; |
172 | write_file_offset_70.param2 = 0; |
173 | write_file_offset_70.param3 = write_data_size; |
173 | write_file_offset_70.param3 = write_data_size; |
174 | write_file_offset_70.param4 = write_buffer; |
174 | write_file_offset_70.param4 = write_buffer; |
175 | write_file_offset_70.rezerv = 0; |
175 | write_file_offset_70.rezerv = 0; |
176 | write_file_offset_70.name = write_file_path; |
176 | write_file_offset_70.name = write_file_path; |
177 | $mov eax,70 |
177 | $mov eax,70 |
178 | $mov ebx,#write_file_offset_70.func |
178 | $mov ebx,#write_file_offset_70.func |
179 | $int 0x40 |
179 | $int 0x40 |
180 | } |
180 | } |
181 | 181 | ||
182 | /////////////////////////// |
182 | /////////////////////////// |
183 | // Ïðî÷èòàòü ïàïêó // |
183 | // Ïðî÷èòàòü ïàïêó // |
184 | /////////////////////////// |
184 | /////////////////////////// |
185 | :f70 read_dir_70; |
185 | :f70 read_dir_70; |
186 | :int ReadDir(dword file_count, read_buffer, dir_path) |
186 | :int ReadDir(dword file_count, read_buffer, dir_path) |
187 | { |
187 | { |
188 | read_dir_70.func = 1; |
188 | read_dir_70.func = 1; |
189 | read_dir_70.param1 = |
189 | read_dir_70.param1 = |
190 | read_dir_70.param2 = |
190 | read_dir_70.param2 = |
191 | read_dir_70.rezerv = 0; |
191 | read_dir_70.rezerv = 0; |
192 | read_dir_70.param3 = file_count; |
192 | read_dir_70.param3 = file_count; |
193 | read_dir_70.param4 = read_buffer; |
193 | read_dir_70.param4 = read_buffer; |
194 | read_dir_70.name = dir_path; |
194 | read_dir_70.name = dir_path; |
195 | $mov eax,70 |
195 | $mov eax,70 |
196 | $mov ebx,#read_dir_70.func |
196 | $mov ebx,#read_dir_70.func |
197 | $int 0x40 |
197 | $int 0x40 |
198 | } |
198 | } |
199 | 199 | ||
200 | :char dir_exists(dword fpath) |
200 | :bool dir_exists(dword fpath) |
201 | { |
201 | { |
202 | BDVK fpath_atr; |
202 | BDVK fpath_atr; |
203 | if (GetFileInfo(fpath, #fpath_atr) != 0) return false; |
203 | if (GetFileInfo(fpath, #fpath_atr) != 0) return false; |
204 | return fpath_atr.isfolder; |
204 | return fpath_atr.isfolder; |
205 | } |
205 | } |
206 | :char file_exists(dword fpath) |
206 | :bool file_exists(dword fpath) |
207 | { |
207 | { |
208 | BDVK ReadFile_atr; |
208 | BDVK ReadFile_atr; |
209 | if (! GetFileInfo(fpath, #ReadFile_atr)) return true; |
209 | if (! GetFileInfo(fpath, #ReadFile_atr)) return true; |
210 | return false; |
210 | return false; |
211 | } |
211 | } |
212 | 212 | ||
213 | 213 | ||
214 | :int GetFile(dword buf, filesize, read_path) |
214 | :int GetFile(dword buf, filesize, read_path) |
215 | { |
215 | { |
216 | int return_val = 0; |
216 | int return_val = 0; |
217 | BDVK ReadFile_atr; |
217 | BDVK ReadFile_atr; |
218 | dword rBuf; |
218 | dword rBuf; |
219 | if (! GetFileInfo(read_path, #ReadFile_atr)) |
219 | if (! GetFileInfo(read_path, #ReadFile_atr)) |
220 | { |
220 | { |
221 | rBuf = malloc(ReadFile_atr.sizelo); |
221 | rBuf = malloc(ReadFile_atr.sizelo); |
222 | if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path)) |
222 | if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path)) |
223 | { |
223 | { |
224 | ESDWORD[buf] = rBuf; |
224 | ESDWORD[buf] = rBuf; |
225 | ESDWORD[filesize] = ReadFile_atr.sizelo; |
225 | ESDWORD[filesize] = ReadFile_atr.sizelo; |
226 | return_val = 1; |
226 | return_val = 1; |
227 | } |
227 | } |
228 | } |
228 | } |
229 | free(rBuf); |
229 | free(rBuf); |
230 | return return_val; |
230 | return return_val; |
231 | } |
231 | } |
232 | 232 | ||
233 | enum |
233 | enum |
234 | { |
234 | { |
235 | DIRS_ALL, |
235 | DIRS_ALL, |
236 | DIRS_NOROOT, |
236 | DIRS_NOROOT, |
237 | DIRS_ONLYREAL |
237 | DIRS_ONLYREAL |
238 | }; |
238 | }; |
239 | :int GetDir(dword dir_buf, file_count, path, doptions) |
239 | :int GetDir(dword dir_buf, file_count, path, doptions) |
240 | { |
240 | { |
241 | dword buf, fcount, error; |
241 | dword buf, fcount, error; |
242 | buf = malloc(32); |
242 | buf = malloc(32); |
243 | error = ReadDir(0, buf, path); |
243 | error = ReadDir(0, buf, path); |
244 | if (!error) |
244 | if (!error) |
245 | { |
245 | { |
246 | fcount = ESDWORD[buf+8]; |
246 | fcount = ESDWORD[buf+8]; |
247 | buf = realloc(buf, fcount+1*304+32); |
247 | buf = realloc(buf, fcount+1*304+32); |
248 | ReadDir(fcount, buf, path); |
248 | ReadDir(fcount, buf, path); |
249 | //fcount=EBX; |
249 | //fcount=EBX; |
250 | 250 | ||
251 | if (doptions == DIRS_ONLYREAL) |
251 | if (doptions == DIRS_ONLYREAL) |
252 | { |
252 | { |
253 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
253 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
254 | if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
254 | if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
255 | } |
255 | } |
256 | if (doptions == DIRS_NOROOT) |
256 | if (doptions == DIRS_NOROOT) |
257 | { |
257 | { |
258 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
258 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
259 | } |
259 | } |
260 | 260 | ||
261 | ESDWORD[dir_buf] = buf; |
261 | ESDWORD[dir_buf] = buf; |
262 | ESDWORD[file_count] = fcount; |
262 | ESDWORD[file_count] = fcount; |
263 | } |
263 | } |
264 | else |
264 | else |
265 | { |
265 | { |
266 | ESDWORD[file_count] = 0; |
266 | ESDWORD[file_count] = 0; |
267 | ESDWORD[dir_buf] = free(buf); |
267 | ESDWORD[dir_buf] = free(buf); |
268 | } |
268 | } |
269 | return error; |
269 | return error; |
270 | } |
270 | } |
271 | 271 | ||
272 | :dword abspath(dword relative_path) //GetAbsolutePathFromRelative() |
272 | :dword abspath(dword relative_path) //GetAbsolutePathFromRelative() |
273 | { |
273 | { |
274 | char absolute_path[4096]; |
274 | char absolute_path[4096]; |
275 | if (ESBYTE[relative_path]=='/') |
275 | if (ESBYTE[relative_path]=='/') |
276 | { |
276 | { |
277 | strcpy(#absolute_path, relative_path); |
277 | strcpy(#absolute_path, relative_path); |
278 | } |
278 | } |
279 | else |
279 | else |
280 | { |
280 | { |
281 | strcpy(#absolute_path, I_Path); |
281 | strcpy(#absolute_path, I_Path); |
282 | absolute_path[strrchr(#absolute_path, '/')] = '\0'; |
282 | absolute_path[strrchr(#absolute_path, '/')] = '\0'; |
283 | strcat(#absolute_path, relative_path); |
283 | strcat(#absolute_path, relative_path); |
284 | } |
284 | } |
285 | return #absolute_path; |
285 | return #absolute_path; |
286 | } |
286 | } |
287 | 287 | ||
288 | :dword GetIni(dword ini_name) //search it on /kolibrios/ then on /sys/ |
288 | :dword GetIni(dword ini_path, ini_name) //search it on /kolibrios/ then on /sys/ |
289 | { |
- | |
290 | char absolute_path[4096]; |
289 | { |
291 | strcpy(#absolute_path, "/kolibrios/settings/"); |
290 | strcpy(ini_path, "/kolibrios/settings/"); |
292 | strcat(#absolute_path, ini_name); |
291 | strcat(ini_path, ini_name); |
293 | if (!file_exists(#absolute_path)) { |
292 | if (!file_exists(ini_path)) { |
294 | strcpy(#absolute_path, "/sys/settings/"); |
293 | strcpy(ini_path, "/sys/settings/"); |
295 | strcat(#absolute_path, ini_name); |
294 | strcat(ini_path, ini_name); |
296 | } |
295 | } |
297 | return #absolute_path; |
296 | return ini_path; |
298 | } |
297 | } |
299 | 298 | ||
300 | :byte ConvertSize_size_prefix[8]; |
299 | :byte ConvertSize_size_prefix[8]; |
301 | :dword ConvertSize(dword bytes) |
300 | :dword ConvertSize(dword bytes) |
302 | { |
301 | { |
303 | byte size_nm[4]; |
302 | byte size_nm[4]; |
304 | if (bytes>=1073741824) strlcpy(#size_nm, "Gb",2); |
303 | if (bytes>=1073741824) strlcpy(#size_nm, "Gb",2); |
305 | else if (bytes>=1048576) strlcpy(#size_nm, "Mb",2); |
304 | else if (bytes>=1048576) strlcpy(#size_nm, "Mb",2); |
306 | else if (bytes>=1024) strlcpy(#size_nm, "Kb",2); |
305 | else if (bytes>=1024) strlcpy(#size_nm, "Kb",2); |
307 | else strlcpy(#size_nm, "b ",2); |
306 | else strlcpy(#size_nm, "b ",2); |
308 | while (bytes>1023) bytes >>= 10; |
307 | while (bytes>1023) bytes >>= 10; |
309 | sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
308 | sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
310 | return #ConvertSize_size_prefix; |
309 | return #ConvertSize_size_prefix; |
311 | } |
310 | } |
312 | :dword ConvertSize64(dword bytes_lo, bytes_hi) |
311 | :dword ConvertSize64(dword bytes_lo, bytes_hi) |
313 | { |
312 | { |
314 | if (bytes_hi > 0) { |
313 | if (bytes_hi > 0) { |
315 | if (bytes_lo>=1073741824) bytes_lo >>= 30; else bytes_lo = 0; |
314 | if (bytes_lo>=1073741824) bytes_lo >>= 30; else bytes_lo = 0; |
316 | sprintf(#ConvertSize_size_prefix,"%d Gb",bytes_hi<<2 + bytes_lo); |
315 | sprintf(#ConvertSize_size_prefix,"%d Gb",bytes_hi<<2 + bytes_lo); |
317 | return #ConvertSize_size_prefix; |
316 | return #ConvertSize_size_prefix; |
318 | } |
317 | } |
319 | else return ConvertSize(bytes_lo); |
318 | else return ConvertSize(bytes_lo); |
320 | } |
319 | } |
321 | :dword notify(dword notify_param) |
320 | :dword notify(dword notify_param) |
322 | { |
321 | { |
323 | return RunProgram("/sys/@notify", notify_param); |
322 | return RunProgram("/sys/@notify", notify_param); |
324 | } |
323 | } |
325 | :void die(dword _last_msg) |
324 | :void die(dword _last_msg) |
326 | { |
325 | { |
327 | notify(_last_msg); |
326 | notify(_last_msg); |
328 | ExitProcess(); |
327 | ExitProcess(); |
329 | } |
328 | } |
330 | :unsigned char size[25]=0; |
329 | :unsigned char size[25]=0; |
331 | :dword ConvertSizeToKb(unsigned int bytes) |
330 | :dword ConvertSizeToKb(unsigned int bytes) |
332 | { |
331 | { |
333 | unsigned int kb; |
332 | unsigned int kb; |
334 | dword kb_line; |
333 | dword kb_line; |
335 | 334 | ||
336 | if (bytes >= 1024) |
335 | if (bytes >= 1024) |
337 | { |
336 | { |
338 | kb_line = itoa(bytes / 1024); |
337 | kb_line = itoa(bytes / 1024); |
339 | strcpy(#size, kb_line); |
338 | strcpy(#size, kb_line); |
340 | strcat(#size, " Kb"); |
339 | strcat(#size, " Kb"); |
341 | } |
340 | } |
342 | else { |
341 | else { |
343 | kb_line = itoa(bytes); |
342 | kb_line = itoa(bytes); |
344 | strcpy(#size, kb_line); |
343 | strcpy(#size, kb_line); |
345 | strcat(#size, " b"); |
344 | strcat(#size, " b"); |
346 | } |
345 | } |
347 | 346 | ||
348 | return #size; |
347 | return #size; |
349 | } |
348 | } |
350 | #endif2><2> |
349 | #endif2><2> |