Rev 7213 | Rev 7225 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7213 | Rev 7219 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #ifndef INCLUDE_DATE_H |
5 | #ifndef INCLUDE_DATE_H |
6 | #include "../lib/date.h" |
6 | #include "../lib/date.h" |
Line 31... | Line 31... | ||
31 | char name[518]; |
31 | char name[518]; |
32 | }; |
32 | }; |
Line 33... | Line -... | ||
33 | - | ||
34 | - | ||
35 | - | ||
36 | - | ||
37 | - | ||
38 | /////////////////////////// |
33 | |
39 | // Ïàðàìåòðû ôàéëà // |
34 | |
40 | /////////////////////////// |
35 | |
41 | :f70 getinfo_file_70; |
36 | :f70 getinfo_file_70; |
42 | :dword GetFileInfo(dword file_path, bdvk_struct) |
37 | :dword GetFileInfo(dword file_path, bdvk_struct) |
Line 51... | Line 46... | ||
51 | $mov eax,70 |
46 | $mov eax,70 |
52 | $mov ebx,#getinfo_file_70.func |
47 | $mov ebx,#getinfo_file_70.func |
53 | $int 0x40 |
48 | $int 0x40 |
54 | } |
49 | } |
Line 55... | Line -... | ||
55 | - | ||
56 | ///////////////////////////////////// |
- | |
57 | // Èçìåíåíèå ïàðàìåòðîâ ôàéëà // |
- | |
58 | ///////////////////////////////////// |
50 | |
59 | :f70 setinfo_file_70; |
51 | :f70 setinfo_file_70; |
60 | :dword SetFileInfo(dword file_path, bdvk_struct) |
52 | :dword SetFileInfo(dword file_path, bdvk_struct) |
61 | { |
53 | { |
62 | setinfo_file_70.func = 6; |
54 | setinfo_file_70.func = 6; |
Line 69... | Line 61... | ||
69 | $mov eax,70 |
61 | $mov eax,70 |
70 | $mov ebx,#setinfo_file_70.func |
62 | $mov ebx,#setinfo_file_70.func |
71 | $int 0x40 |
63 | $int 0x40 |
72 | } |
64 | } |
Line 73... | Line -... | ||
73 | - | ||
74 | /////////////////////////// |
- | |
75 | // Çàïóñê ïðîãðàììû // |
- | |
76 | /////////////////////////// |
65 | |
77 | :f70 run_file_70; |
66 | :f70 run_file_70; |
78 | :signed int RunProgram(dword run_path, run_param) |
67 | :signed int RunProgram(dword run_path, run_param) |
79 | { |
68 | { |
80 | run_file_70.func = 7; |
69 | run_file_70.func = 7; |
Line 87... | Line 76... | ||
87 | $mov eax,70 |
76 | $mov eax,70 |
88 | $mov ebx,#run_file_70.func |
77 | $mov ebx,#run_file_70.func |
89 | $int 0x40 |
78 | $int 0x40 |
90 | } |
79 | } |
Line 91... | Line -... | ||
91 | - | ||
92 | /////////////////////////// |
- | |
93 | // Ñîçäàíèå ïàïêè // |
- | |
94 | /////////////////////////// |
80 | |
95 | :f70 create_dir_70; |
81 | :f70 create_dir_70; |
96 | :int CreateDir(dword new_folder_path) |
82 | :int CreateDir(dword new_folder_path) |
97 | { |
83 | { |
98 | create_dir_70.func = 9; |
84 | create_dir_70.func = 9; |
Line 105... | Line 91... | ||
105 | $mov eax,70 |
91 | $mov eax,70 |
106 | $mov ebx,#create_dir_70.func |
92 | $mov ebx,#create_dir_70.func |
107 | $int 0x40 |
93 | $int 0x40 |
108 | } |
94 | } |
Line 109... | Line -... | ||
109 | - | ||
110 | //////////////////////////// |
- | |
111 | // Óäàëåíèå ôàéëà/ïàïêè // |
- | |
112 | //////////////////////////// |
95 | |
113 | :f70 del_file_70; |
96 | :f70 del_file_70; |
114 | :int DeleteFile(dword del_file_path) |
97 | :int DeleteFile(dword del_file_path) |
115 | { |
98 | { |
116 | del_file_70.func = 8; |
99 | del_file_70.func = 8; |
Line 123... | Line 106... | ||
123 | $mov eax,70 |
106 | $mov eax,70 |
124 | $mov ebx,#del_file_70.func |
107 | $mov ebx,#del_file_70.func |
125 | $int 0x40 |
108 | $int 0x40 |
126 | } |
109 | } |
Line 127... | Line -... | ||
127 | - | ||
128 | //////////////////////////// |
- | |
129 | // Ïðî÷èòàòü ôàéë // |
- | |
130 | //////////////////////////// |
110 | |
131 | :f70 read_file_70; |
111 | :f70 read_file_70; |
132 | :int ReadFile(dword offset, data_size, buffer, file_path) |
112 | :int ReadFile(dword offset, data_size, buffer, file_path) |
133 | { |
113 | { |
134 | read_file_70.func = 0; |
114 | read_file_70.func = 0; |
Line 175... | Line 155... | ||
175 | $mov ebx,#write_file_offset_70.func |
155 | $mov ebx,#write_file_offset_70.func |
176 | $int 0x40 |
156 | $int 0x40 |
177 | } |
157 | } |
Line 178... | Line -... | ||
178 | - | ||
179 | - | ||
180 | /////////////////////////// |
- | |
181 | // Ïðî÷èòàòü ïàïêó // |
158 | |
182 | /////////////////////////// |
159 | |
183 | :f70 read_dir_70; |
160 | :f70 read_dir_70; |
184 | :int ReadDir(dword file_count, read_buffer, dir_path) |
161 | :int ReadDir(dword file_count, read_buffer, dir_path) |
185 | { |
162 | { |
Line 195... | Line 172... | ||
195 | $int 0x40 |
172 | $int 0x40 |
196 | } |
173 | } |
Line 197... | Line 174... | ||
197 | 174 | ||
198 | :bool dir_exists(dword fpath) |
175 | :bool dir_exists(dword fpath) |
- | 176 | { |
|
- | 177 | char buf[32]; |
|
- | 178 | if (!ReadDir(0, #buf, fpath)) return true; |
|
- | 179 | return false; |
|
- | 180 | } |
|
- | 181 | ||
- | 182 | /* |
|
- | 183 | ||
- | 184 | // This implementation of dir_exists() is faster than |
|
- | 185 | // previous but here virtual folders like |
|
- | 186 | // '/' and '/tmp' are not recognised as FOLDERS |
|
- | 187 | // by GetFileInfo() => BDVK.isfolder attribute :( |
|
- | 188 | ||
- | 189 | :bool dir_exists(dword fpath) |
|
199 | { |
190 | { |
200 | BDVK fpath_atr; |
191 | BDVK fpath_atr; |
201 | if (GetFileInfo(fpath, #fpath_atr) != 0) return false; |
192 | if (GetFileInfo(fpath, #fpath_atr) != 0) return false; |
202 | return fpath_atr.isfolder; |
193 | return fpath_atr.isfolder; |
- | 194 | } |
|
- | 195 | */ |
|
- | 196 | ||
203 | } |
197 | |
204 | :bool file_exists(dword fpath) |
198 | :bool file_exists(dword fpath) |
205 | { |
199 | { |
206 | BDVK ReadFile_atr; |
200 | BDVK ReadFile_atr; |
207 | if (! GetFileInfo(fpath, #ReadFile_atr)) return true; |
201 | if (! GetFileInfo(fpath, #ReadFile_atr)) return true; |
Line 304... | Line 298... | ||
304 | else strlcpy(#size_nm, "b ",2); |
298 | else strlcpy(#size_nm, "b ",2); |
305 | while (bytes>1023) bytes >>= 10; |
299 | while (bytes>1023) bytes >>= 10; |
306 | sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
300 | sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); |
307 | return #ConvertSize_size_prefix; |
301 | return #ConvertSize_size_prefix; |
308 | } |
302 | } |
- | 303 | ||
309 | :dword ConvertSize64(dword bytes_lo, bytes_hi) |
304 | :dword ConvertSize64(dword bytes_lo, bytes_hi) |
310 | { |
305 | { |
311 | if (bytes_hi > 0) { |
306 | if (bytes_hi > 0) { |
312 | if (bytes_lo>=1073741824) bytes_lo >>= 30; else bytes_lo = 0; |
307 | if (bytes_lo>=1073741824) bytes_lo >>= 30; else bytes_lo = 0; |
313 | sprintf(#ConvertSize_size_prefix,"%d Gb",bytes_hi<<2 + bytes_lo); |
308 | sprintf(#ConvertSize_size_prefix,"%d Gb",bytes_hi<<2 + bytes_lo); |
314 | return #ConvertSize_size_prefix; |
309 | return #ConvertSize_size_prefix; |
315 | } |
310 | } |
316 | else return ConvertSize(bytes_lo); |
311 | else return ConvertSize(bytes_lo); |
317 | } |
312 | } |
- | 313 | ||
318 | :dword notify(dword notify_param) |
314 | :dword notify(dword notify_param) |
319 | { |
315 | { |
320 | return RunProgram("/sys/@notify", notify_param); |
316 | return RunProgram("/sys/@notify", notify_param); |
321 | } |
317 | } |
- | 318 | ||
322 | :void die(dword _last_msg) |
319 | :void die(dword _last_msg) |
323 | { |
320 | { |
324 | notify(_last_msg); |
321 | notify(_last_msg); |
325 | ExitProcess(); |
322 | ExitProcess(); |
326 | } |
323 | } |
- | 324 | ||
327 | :unsigned char size[25]=0; |
325 | :unsigned char size[25]=0; |
328 | :dword ConvertSizeToKb(unsigned int bytes) |
326 | :dword ConvertSizeToKb(unsigned int bytes) |
329 | { |
327 | { |
330 | unsigned int kb; |
328 | unsigned int kb; |
331 | dword kb_line; |
329 | dword kb_line; |