Rev 5582 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5487 | leency | 1 | :struct f70{ |
3067 | leency | 2 | dword func; |
3 | dword param1; |
||
4 | dword param2; |
||
5 | dword param3; |
||
6 | dword param4; |
||
7 | char rezerv; |
||
8 | dword name; |
||
9 | }; |
||
10 | |||
5487 | leency | 11 | :struct date |
12 | { |
||
13 | byte day; |
||
14 | byte month; |
||
15 | word year; |
||
16 | }; |
||
17 | |||
18 | :struct BDVK { |
||
19 | dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0; |
||
3067 | leency | 20 | byte type_name; |
4898 | leency | 21 | byte rez1, rez2, selected; |
5487 | leency | 22 | dword timecreate; |
23 | date datecreate; |
||
3067 | leency | 24 | dword timelastaccess; |
5487 | leency | 25 | date datelastaccess; |
3067 | leency | 26 | dword timelastedit; |
5487 | leency | 27 | date datelastedit; |
3067 | leency | 28 | dword sizelo; |
29 | dword sizehi; |
||
30 | char name[518]; |
||
31 | }; |
||
32 | |||
33 | |||
5576 | pavelyakov | 34 | :void DrawDate(dword x, y, color, in_date) |
5487 | leency | 35 | { |
5591 | pavelyakov | 36 | //char text[15]; |
37 | EDI = in_date; |
||
5487 | leency | 38 | EAX = 47; |
39 | EBX = 2<<16; |
||
40 | EDX = x<<16+y; |
||
41 | ESI = 0x80<<24+color; |
||
42 | ECX = EDI.date.day; |
||
43 | $int 0x40; |
||
44 | EDX += 18<<16; |
||
45 | ECX = EDI.date.month; |
||
46 | $int 0x40; |
||
47 | EDX += 18<<16; |
||
48 | EBX = 4<<16; |
||
49 | ECX = EDI.date.year; |
||
5591 | pavelyakov | 50 | $int 0x40; |
51 | PutPixel(x+14,y+6,color); |
||
52 | PutPixel(x+32,y+6,color); |
||
53 | //sprintf(#text,"%d",EDI.date.year); |
||
54 | //WriteText(x, y, 0x80, 0x000000, #text); |
||
5487 | leency | 55 | } |
56 | |||
57 | |||
3067 | leency | 58 | /////////////////////////// |
3440 | leency | 59 | // Параметры файла // |
60 | /////////////////////////// |
||
5472 | leency | 61 | :f70 getinfo_file_70; |
3440 | leency | 62 | :dword GetFileInfo(dword file_path, bdvk_struct) |
63 | { |
||
64 | getinfo_file_70.func = 5; |
||
65 | getinfo_file_70.param1 = |
||
66 | getinfo_file_70.param2 = |
||
67 | getinfo_file_70.param3 = 0; |
||
68 | getinfo_file_70.param4 = bdvk_struct; |
||
69 | getinfo_file_70.rezerv = 0; |
||
70 | getinfo_file_70.name = file_path; |
||
71 | $mov eax,70 |
||
72 | $mov ebx,#getinfo_file_70.func |
||
3444 | leency | 73 | $int 0x40 |
3440 | leency | 74 | } |
75 | |||
76 | /////////////////////////// |
||
5554 | punk_joker | 77 | // Изменение параметров файла // |
78 | /////////////////////////// |
||
79 | :f70 setinfo_file_70; |
||
80 | :dword SetFileInfo(dword file_path, bdvk_struct) |
||
81 | { |
||
82 | setinfo_file_70.func = 6; |
||
83 | setinfo_file_70.param1 = |
||
84 | setinfo_file_70.param2 = |
||
85 | setinfo_file_70.param3 = 0; |
||
86 | setinfo_file_70.param4 = bdvk_struct; |
||
87 | setinfo_file_70.rezerv = 0; |
||
88 | setinfo_file_70.name = file_path; |
||
89 | $mov eax,70 |
||
90 | $mov ebx,#setinfo_file_70.func |
||
91 | $int 0x40 |
||
92 | } |
||
93 | |||
94 | /////////////////////////// |
||
3067 | leency | 95 | // Запуск программы // |
96 | /////////////////////////// |
||
5472 | leency | 97 | :f70 run_file_70; |
98 | :signed int RunProgram(dword run_path, run_param) |
||
3067 | leency | 99 | { |
100 | run_file_70.func = 7; |
||
101 | run_file_70.param1 = |
||
102 | run_file_70.param3 = |
||
103 | run_file_70.param4 = |
||
104 | run_file_70.rezerv = 0; |
||
105 | run_file_70.param2 = run_param; |
||
106 | run_file_70.name = run_path; |
||
107 | $mov eax,70 |
||
108 | $mov ebx,#run_file_70.func |
||
109 | $int 0x40 |
||
110 | } |
||
111 | |||
112 | /////////////////////////// |
||
113 | // Создание папки // |
||
114 | /////////////////////////// |
||
5472 | leency | 115 | :f70 create_dir_70; |
3067 | leency | 116 | :int CreateDir(dword new_folder_path) |
117 | { |
||
118 | create_dir_70.func = 9; |
||
119 | create_dir_70.param1 = |
||
120 | create_dir_70.param2 = |
||
121 | create_dir_70.param3 = |
||
122 | create_dir_70.param4 = |
||
123 | create_dir_70.rezerv = 0; |
||
124 | create_dir_70.name = new_folder_path; |
||
125 | $mov eax,70 |
||
126 | $mov ebx,#create_dir_70.func |
||
127 | $int 0x40 |
||
128 | } |
||
129 | |||
130 | //////////////////////////// |
||
131 | // Удаление файла/папки // |
||
132 | //////////////////////////// |
||
5472 | leency | 133 | :f70 del_file_70; |
3067 | leency | 134 | :int DeleteFile(dword del_file_path) |
135 | { |
||
136 | del_file_70.func = 8; |
||
137 | del_file_70.param1 = |
||
138 | del_file_70.param2 = |
||
139 | del_file_70.param3 = |
||
140 | del_file_70.param4 = |
||
141 | del_file_70.rezerv = 0; |
||
142 | del_file_70.name = del_file_path; |
||
143 | $mov eax,70 |
||
144 | $mov ebx,#del_file_70.func |
||
145 | $int 0x40 |
||
146 | } |
||
147 | |||
148 | //////////////////////////// |
||
149 | // Прочитать файл // |
||
150 | //////////////////////////// |
||
5472 | leency | 151 | :f70 read_file_70; |
3067 | leency | 152 | :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path) |
153 | { |
||
154 | read_file_70.func = 0; |
||
155 | read_file_70.param1 = read_pos; |
||
156 | read_file_70.param2 = 0; |
||
157 | read_file_70.param3 = read_file_size; |
||
158 | read_file_70.param4 = read_buffer; |
||
159 | read_file_70.rezerv = 0; |
||
160 | read_file_70.name = read_file_path; |
||
161 | $mov eax,70 |
||
162 | $mov ebx,#read_file_70.func |
||
163 | $int 0x40 |
||
164 | } |
||
165 | |||
166 | //////////////////////////// |
||
167 | // Записать файл // |
||
168 | //////////////////////////// |
||
5472 | leency | 169 | :f70 write_file_70; |
3067 | leency | 170 | :int WriteFile(dword write_file_size, write_buffer, write_file_path) |
171 | { |
||
172 | write_file_70.func = 2; |
||
173 | write_file_70.param1 = 0; |
||
174 | write_file_70.param2 = 0; |
||
175 | write_file_70.param3 = write_file_size; |
||
176 | write_file_70.param4 = write_buffer; |
||
177 | write_file_70.rezerv = 0; |
||
178 | write_file_70.name = write_file_path; |
||
179 | $mov eax,70 |
||
180 | $mov ebx,#write_file_70.func |
||
181 | $int 0x40 |
||
5542 | leency | 182 | } |
3067 | leency | 183 | |
5542 | leency | 184 | ////////////////////////////////////////// |
185 | // WriteInFileThatAlredyExists // |
||
186 | ////////////////////////////////////////// |
||
187 | :f70 write_file_offset_70; |
||
188 | :int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset) |
||
189 | { |
||
190 | write_file_offset_70.func = 3; |
||
191 | write_file_offset_70.param1 = offset; |
||
192 | write_file_offset_70.param2 = 0; |
||
193 | write_file_offset_70.param3 = write_data_size; |
||
194 | write_file_offset_70.param4 = write_buffer; |
||
195 | write_file_offset_70.rezerv = 0; |
||
196 | write_file_offset_70.name = write_file_path; |
||
197 | $mov eax,70 |
||
198 | $mov ebx,#write_file_offset_70.func |
||
199 | $int 0x40 |
||
200 | } |
||
201 | |||
3067 | leency | 202 | /////////////////////////// |
203 | // Прочитать папку // |
||
204 | /////////////////////////// |
||
5472 | leency | 205 | :f70 read_dir_70; |
3067 | leency | 206 | :int ReadDir(dword file_count, read_buffer, dir_path) |
3363 | leency | 207 | { |
3067 | leency | 208 | read_dir_70.func = 1; |
209 | read_dir_70.param1 = |
||
210 | read_dir_70.param2 = |
||
211 | read_dir_70.rezerv = 0; |
||
212 | read_dir_70.param3 = file_count; |
||
213 | read_dir_70.param4 = read_buffer; |
||
214 | read_dir_70.name = dir_path; |
||
215 | $mov eax,70 |
||
216 | $mov ebx,#read_dir_70.func |
||
217 | $int 0x40 |
||
218 | } |
||
219 | |||
5472 | leency | 220 | :char isdir(dword fpath) |
3440 | leency | 221 | { |
222 | BDVK fpath_atr; |
||
223 | GetFileInfo(fpath, #fpath_atr); |
||
5487 | leency | 224 | return fpath_atr.isfolder; |
3440 | leency | 225 | } |
3877 | leency | 226 | |
3440 | leency | 227 | :int GetFile(dword buf, filesize, read_path) |
228 | { |
||
229 | BDVK ReadFile_atr; |
||
230 | dword rBuf; |
||
231 | if (! GetFileInfo(read_path, #ReadFile_atr)) |
||
232 | { |
||
233 | rBuf = malloc(ReadFile_atr.sizelo); |
||
234 | if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path)) |
||
235 | { |
||
236 | ESDWORD[buf] = rBuf; |
||
237 | ESDWORD[filesize] = ReadFile_atr.sizelo; |
||
238 | return 1; |
||
239 | } |
||
240 | } |
||
241 | free(rBuf); |
||
242 | return 0; |
||
243 | } |
||
3067 | leency | 244 | |
3444 | leency | 245 | enum |
3363 | leency | 246 | { |
3444 | leency | 247 | DIRS_ALL, |
248 | DIRS_NOROOT, |
||
249 | DIRS_ONLYREAL |
||
250 | }; |
||
251 | :int GetDir(dword dir_buf, file_count, path, doptions) |
||
252 | { |
||
3363 | leency | 253 | dword buf, fcount, error; |
254 | buf = malloc(32); |
||
255 | error = ReadDir(0, buf, path); |
||
256 | if (!error) |
||
257 | { |
||
258 | fcount = ESDWORD[buf+8]; |
||
259 | buf = realloc(buf, fcount+1*304+32); |
||
260 | ReadDir(fcount, buf, path); |
||
3440 | leency | 261 | //fcount=EBX; |
3444 | leency | 262 | |
263 | if (doptions == DIRS_ONLYREAL) |
||
264 | { |
||
265 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
266 | if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
267 | } |
||
268 | if (doptions == DIRS_NOROOT) |
||
269 | { |
||
270 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
271 | } |
||
272 | |||
3363 | leency | 273 | ESDWORD[dir_buf] = buf; |
274 | ESDWORD[file_count] = fcount; |
||
275 | } |
||
3440 | leency | 276 | else |
3067 | leency | 277 | { |
3440 | leency | 278 | ESDWORD[file_count] = 0; |
279 | ESDWORD[dir_buf] = free(buf); |
||
3067 | leency | 280 | } |
3440 | leency | 281 | return error; |
3067 | leency | 282 | } |
283 | |||
5421 | leency | 284 | :dword notify(dword notify_param) |
3067 | leency | 285 | { |
5421 | leency | 286 | return RunProgram("@notify", notify_param); |
3081 | leency | 287 | } |
3432 | leency | 288 | |
289 | :dword abspath(dword relative_path) //GetAbsolutePathFromRelative() |
||
290 | { |
||
291 | char absolute_path[4096]; |
||
4137 | leency | 292 | if (ESBYTE[relative_path]=='/') |
293 | { |
||
294 | strcpy(#absolute_path, relative_path); |
||
295 | } |
||
296 | else |
||
297 | { |
||
298 | strcpy(#absolute_path, #program_path); |
||
299 | absolute_path[strrchr(#absolute_path, '/')] = '\0'; |
||
300 | strcat(#absolute_path, relative_path); |
||
301 | } |
||
3432 | leency | 302 | return #absolute_path; |
303 | } |
||
5483 | leency | 304 | |
5591 | pavelyakov | 305 | :byte ConvertSize_size_prefix[8]; |
5576 | pavelyakov | 306 | :dword ConvertSize(dword bytes) |
5483 | leency | 307 | { |
5591 | pavelyakov | 308 | byte size_nm[4]; |
309 | if (bytes>=1073741824) strncpy(#size_nm, "Gb",2); |
||
310 | else if (bytes>=1048576) strncpy(#size_nm, "Mb",2); |
||
311 | else if (bytes>=1024) strncpy(#size_nm, "Kb",2); |
||
312 | else strncpy(#size_nm, "b ",2); |
||
5483 | leency | 313 | while (bytes>1023) bytes/=1024; |
5591 | pavelyakov | 314 | sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
315 | return #ConvertSize_size_prefix; |
||
5493 | leency | 316 | } |
317 | |||
318 | :dword ConvertSizeToKb(unsigned int bytes) |
||
319 | { |
||
320 | unsigned char size[25]=0; |
||
321 | unsigned int kb; |
||
322 | dword kb_line; |
||
323 | |||
324 | kb_line = itoa(bytes / 1024); |
||
325 | strcpy(#size, kb_line); |
||
326 | strcat(#size, " Kb"); |
||
327 | |||
328 | return #size; |
||
5483 | leency | 329 | }16; |