Rev 5472 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | struct f70{ |
2 | dword func; |
||
3 | dword param1; |
||
4 | dword param2; |
||
5 | dword param3; |
||
6 | dword param4; |
||
7 | char rezerv; |
||
8 | dword name; |
||
9 | }; |
||
10 | |||
11 | struct BDVK{ |
||
12 | dword attr; |
||
13 | byte type_name; |
||
4898 | leency | 14 | byte rez1, rez2, selected; |
3067 | leency | 15 | dword timecreate; |
16 | dword datecreate; |
||
17 | dword timelastaccess; |
||
18 | dword datelastaccess; |
||
19 | dword timelastedit; |
||
20 | dword datelastedit; |
||
21 | dword sizelo; |
||
22 | dword sizehi; |
||
23 | char name[518]; |
||
24 | }; |
||
25 | |||
26 | |||
27 | /////////////////////////// |
||
3440 | leency | 28 | // Параметры файла // |
29 | /////////////////////////// |
||
5472 | leency | 30 | :f70 getinfo_file_70; |
3440 | leency | 31 | :dword GetFileInfo(dword file_path, bdvk_struct) |
32 | { |
||
33 | getinfo_file_70.func = 5; |
||
34 | getinfo_file_70.param1 = |
||
35 | getinfo_file_70.param2 = |
||
36 | getinfo_file_70.param3 = 0; |
||
37 | getinfo_file_70.param4 = bdvk_struct; |
||
38 | getinfo_file_70.rezerv = 0; |
||
39 | getinfo_file_70.name = file_path; |
||
40 | $mov eax,70 |
||
41 | $mov ebx,#getinfo_file_70.func |
||
3444 | leency | 42 | $int 0x40 |
3440 | leency | 43 | } |
44 | |||
45 | /////////////////////////// |
||
3067 | leency | 46 | // Запуск программы // |
47 | /////////////////////////// |
||
5472 | leency | 48 | :f70 run_file_70; |
49 | :signed int RunProgram(dword run_path, run_param) |
||
3067 | leency | 50 | { |
51 | run_file_70.func = 7; |
||
52 | run_file_70.param1 = |
||
53 | run_file_70.param3 = |
||
54 | run_file_70.param4 = |
||
55 | run_file_70.rezerv = 0; |
||
56 | run_file_70.param2 = run_param; |
||
57 | run_file_70.name = run_path; |
||
58 | $mov eax,70 |
||
59 | $mov ebx,#run_file_70.func |
||
60 | $int 0x40 |
||
61 | } |
||
62 | |||
63 | /////////////////////////// |
||
64 | // Создание папки // |
||
65 | /////////////////////////// |
||
5472 | leency | 66 | :f70 create_dir_70; |
3067 | leency | 67 | :int CreateDir(dword new_folder_path) |
68 | { |
||
69 | create_dir_70.func = 9; |
||
70 | create_dir_70.param1 = |
||
71 | create_dir_70.param2 = |
||
72 | create_dir_70.param3 = |
||
73 | create_dir_70.param4 = |
||
74 | create_dir_70.rezerv = 0; |
||
75 | create_dir_70.name = new_folder_path; |
||
76 | $mov eax,70 |
||
77 | $mov ebx,#create_dir_70.func |
||
78 | $int 0x40 |
||
79 | } |
||
80 | |||
81 | //////////////////////////// |
||
82 | // Удаление файла/папки // |
||
83 | //////////////////////////// |
||
5472 | leency | 84 | :f70 del_file_70; |
3067 | leency | 85 | :int DeleteFile(dword del_file_path) |
86 | { |
||
87 | del_file_70.func = 8; |
||
88 | del_file_70.param1 = |
||
89 | del_file_70.param2 = |
||
90 | del_file_70.param3 = |
||
91 | del_file_70.param4 = |
||
92 | del_file_70.rezerv = 0; |
||
93 | del_file_70.name = del_file_path; |
||
94 | $mov eax,70 |
||
95 | $mov ebx,#del_file_70.func |
||
96 | $int 0x40 |
||
97 | } |
||
98 | |||
99 | //////////////////////////// |
||
100 | // Прочитать файл // |
||
101 | //////////////////////////// |
||
5472 | leency | 102 | :f70 read_file_70; |
3067 | leency | 103 | :int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path) |
104 | { |
||
105 | read_file_70.func = 0; |
||
106 | read_file_70.param1 = read_pos; |
||
107 | read_file_70.param2 = 0; |
||
108 | read_file_70.param3 = read_file_size; |
||
109 | read_file_70.param4 = read_buffer; |
||
110 | read_file_70.rezerv = 0; |
||
111 | read_file_70.name = read_file_path; |
||
112 | $mov eax,70 |
||
113 | $mov ebx,#read_file_70.func |
||
114 | $int 0x40 |
||
115 | } |
||
116 | |||
117 | //////////////////////////// |
||
118 | // Записать файл // |
||
119 | //////////////////////////// |
||
5472 | leency | 120 | :f70 write_file_70; |
3067 | leency | 121 | :int WriteFile(dword write_file_size, write_buffer, write_file_path) |
122 | { |
||
123 | write_file_70.func = 2; |
||
124 | write_file_70.param1 = 0; |
||
125 | write_file_70.param2 = 0; |
||
126 | write_file_70.param3 = write_file_size; |
||
127 | write_file_70.param4 = write_buffer; |
||
128 | write_file_70.rezerv = 0; |
||
129 | write_file_70.name = write_file_path; |
||
130 | $mov eax,70 |
||
131 | $mov ebx,#write_file_70.func |
||
132 | $int 0x40 |
||
133 | } |
||
134 | |||
135 | /////////////////////////// |
||
136 | // Прочитать папку // |
||
137 | /////////////////////////// |
||
5472 | leency | 138 | :f70 read_dir_70; |
3067 | leency | 139 | :int ReadDir(dword file_count, read_buffer, dir_path) |
3363 | leency | 140 | { |
3067 | leency | 141 | read_dir_70.func = 1; |
142 | read_dir_70.param1 = |
||
143 | read_dir_70.param2 = |
||
144 | read_dir_70.rezerv = 0; |
||
145 | read_dir_70.param3 = file_count; |
||
146 | read_dir_70.param4 = read_buffer; |
||
147 | read_dir_70.name = dir_path; |
||
148 | $mov eax,70 |
||
149 | $mov ebx,#read_dir_70.func |
||
150 | $int 0x40 |
||
151 | } |
||
152 | |||
5472 | leency | 153 | :char isdir(dword fpath) |
3440 | leency | 154 | { |
155 | BDVK fpath_atr; |
||
156 | GetFileInfo(fpath, #fpath_atr); |
||
3877 | leency | 157 | if (TestBit( fpath_atr.attr, 4)) return 1; else return 0; |
3440 | leency | 158 | } |
3877 | leency | 159 | |
3440 | leency | 160 | :int GetFile(dword buf, filesize, read_path) |
161 | { |
||
162 | BDVK ReadFile_atr; |
||
163 | dword rBuf; |
||
164 | if (! GetFileInfo(read_path, #ReadFile_atr)) |
||
165 | { |
||
166 | rBuf = malloc(ReadFile_atr.sizelo); |
||
167 | if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path)) |
||
168 | { |
||
169 | ESDWORD[buf] = rBuf; |
||
170 | ESDWORD[filesize] = ReadFile_atr.sizelo; |
||
171 | return 1; |
||
172 | } |
||
173 | } |
||
174 | free(rBuf); |
||
175 | return 0; |
||
176 | } |
||
3067 | leency | 177 | |
3444 | leency | 178 | enum |
3363 | leency | 179 | { |
3444 | leency | 180 | DIRS_ALL, |
181 | DIRS_NOROOT, |
||
182 | DIRS_ONLYREAL |
||
183 | }; |
||
184 | :int GetDir(dword dir_buf, file_count, path, doptions) |
||
185 | { |
||
3363 | leency | 186 | dword buf, fcount, error; |
187 | buf = malloc(32); |
||
188 | error = ReadDir(0, buf, path); |
||
189 | if (!error) |
||
190 | { |
||
191 | fcount = ESDWORD[buf+8]; |
||
192 | buf = realloc(buf, fcount+1*304+32); |
||
193 | ReadDir(fcount, buf, path); |
||
3440 | leency | 194 | //fcount=EBX; |
3444 | leency | 195 | |
196 | if (doptions == DIRS_ONLYREAL) |
||
197 | { |
||
198 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
199 | if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
200 | } |
||
201 | if (doptions == DIRS_NOROOT) |
||
202 | { |
||
203 | if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);} |
||
204 | } |
||
205 | |||
3363 | leency | 206 | ESDWORD[dir_buf] = buf; |
207 | ESDWORD[file_count] = fcount; |
||
208 | } |
||
3440 | leency | 209 | else |
3067 | leency | 210 | { |
3440 | leency | 211 | ESDWORD[file_count] = 0; |
212 | ESDWORD[dir_buf] = free(buf); |
||
3067 | leency | 213 | } |
3440 | leency | 214 | return error; |
3067 | leency | 215 | } |
216 | |||
5421 | leency | 217 | :dword notify(dword notify_param) |
3067 | leency | 218 | { |
5421 | leency | 219 | return RunProgram("@notify", notify_param); |
3081 | leency | 220 | } |
3432 | leency | 221 | |
222 | :dword abspath(dword relative_path) //GetAbsolutePathFromRelative() |
||
223 | { |
||
224 | char absolute_path[4096]; |
||
4137 | leency | 225 | if (ESBYTE[relative_path]=='/') |
226 | { |
||
227 | strcpy(#absolute_path, relative_path); |
||
228 | } |
||
229 | else |
||
230 | { |
||
231 | strcpy(#absolute_path, #program_path); |
||
232 | absolute_path[strrchr(#absolute_path, '/')] = '\0'; |
||
233 | strcat(#absolute_path, relative_path); |
||
234 | } |
||
3432 | leency | 235 | return #absolute_path; |
236 | } |
||
5483 | leency | 237 | |
238 | :dword ConvertSize(unsigned int bytes) |
||
239 | { |
||
240 | unsigned char size_prefix[8], size_nm[4]; |
||
241 | if (bytes>=1073741824) strcpy(#size_nm, " Gb"); |
||
242 | else if (bytes>=1048576) strcpy(#size_nm, " Mb"); |
||
243 | else if (bytes>=1024) strcpy(#size_nm, " Kb"); |
||
244 | else strcpy(#size_nm, " b "); |
||
245 | while (bytes>1023) bytes/=1024; |
||
246 | itoa_(#size_prefix, bytes); |
||
247 | strcat(#size_prefix, #size_nm); |
||
248 | return #size_prefix; |
||
249 | } |