Subversion Repositories Kolibri OS

Rev

Rev 7362 | Rev 7422 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7362 Rev 7369
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 -... Line 7...
-
 
7
#endif
-
 
8
 
-
 
9
//===================================================//
-
 
10
//                                                   //
-
 
11
//              Basic System Functions               //
-
 
12
//                                                   //
7
#endif
13
//===================================================//
8
 
14
 
9
:struct f70{
15
:struct f70{
10
	dword	func;
16
	dword	func;
11
	dword	param1;
17
	dword	param1;
Line 154... Line 160...
154
	$mov eax,70
160
	$mov eax,70
155
	$mov ebx,#write_file_offset_70.func
161
	$mov ebx,#write_file_offset_70.func
156
	$int 0x40
162
	$int 0x40
157
}
163
}
Line 158... Line -...
158
 
-
 
159
 
164
 
160
:f70 read_dir_70;
165
:f70 read_dir_70;
161
:int ReadDir(dword file_count, read_buffer, dir_path)
166
:int ReadDir(dword file_count, read_buffer, dir_path)
162
{
167
{
163
	read_dir_70.func = 1;
168
	read_dir_70.func = 1;
Line 170... Line 175...
170
	$mov eax,70
175
	$mov eax,70
171
	$mov ebx,#read_dir_70.func
176
	$mov ebx,#read_dir_70.func
172
	$int 0x40
177
	$int 0x40
173
}
178
}
Line -... Line 179...
-
 
179
 
-
 
180
//===================================================//
-
 
181
//                                                   //
-
 
182
//                        Misc                       //
-
 
183
//                                                   //
-
 
184
//===================================================//
174
 
185
 
175
:bool dir_exists(dword fpath)
186
:bool dir_exists(dword fpath)
176
{
187
{
177
	char buf[32];
188
	char buf[32];
178
	if (!ReadDir(0, #buf, fpath)) return true; 
189
	if (!ReadDir(0, #buf, fpath)) return true; 
179
	return false;
190
	return false;
Line 180... Line 191...
180
}
191
}
181
 
-
 
182
/*
192
 
183
 
193
/*
184
// This implementation of dir_exists() is faster than
194
// This implementation of dir_exists() is faster than
185
// previous but here virtual folders like
195
// previous but here virtual folders like
Line 192... Line 202...
192
	if (GetFileInfo(fpath, #fpath_atr) != 0) return false; 
202
	if (GetFileInfo(fpath, #fpath_atr) != 0) return false; 
193
	return fpath_atr.isfolder;
203
	return fpath_atr.isfolder;
194
}
204
}
195
*/
205
*/
Line 196... Line -...
196
 
-
 
197
 
206
 
198
:bool file_exists(dword fpath)
207
:bool file_exists(dword fpath)
199
{
208
{
200
	BDVK ReadFile_atr;
209
	BDVK ReadFile_atr;
201
	if (! GetFileInfo(fpath, #ReadFile_atr)) return true;
210
	if (! GetFileInfo(fpath, #ReadFile_atr)) return true;
202
	return false;
211
	return false;
Line 203... Line -...
203
}
-
 
204
 
212
}
205
 
213
 
206
enum
214
enum
207
{
215
{
208
	DIRS_ALL,
216
	DIRS_ALL,
Line 267... Line 275...
267
		strcat(ini_path, ini_name);
275
		strcat(ini_path, ini_name);
268
	}
276
	}
269
	return ini_path;
277
	return ini_path;
270
}
278
}
Line -... Line 279...
-
 
279
 
-
 
280
:dword notify(dword notify_param)
-
 
281
{
-
 
282
	return RunProgram("/sys/@notify", notify_param);
-
 
283
}
-
 
284
 
-
 
285
:void die(dword _last_msg)
-
 
286
{
-
 
287
	notify(_last_msg);
-
 
288
	ExitProcess();
-
 
289
}
-
 
290
 
-
 
291
//===================================================//
-
 
292
//                                                   //
-
 
293
//                   Convert Size                    //
-
 
294
//                                                   //
-
 
295
//===================================================//
271
 
296
 
272
:byte ConvertSize_size_prefix[8];
297
:byte ConvertSize_size_prefix[8];
273
:dword ConvertSize(dword bytes)
298
:dword ConvertSize(dword bytes)
274
{
299
{
275
  byte size_nm[4];
300
  byte size_nm[4];
Line 290... Line 315...
290
	return #ConvertSize_size_prefix;
315
	return #ConvertSize_size_prefix;
291
  }
316
  }
292
  else return ConvertSize(bytes_lo);
317
  else return ConvertSize(bytes_lo);
293
}
318
}
Line 294... Line -...
294
 
-
 
295
:dword notify(dword notify_param)
-
 
296
{
-
 
297
	return RunProgram("/sys/@notify", notify_param);
-
 
298
}
-
 
299
 
-
 
300
:void die(dword _last_msg)
-
 
301
{
-
 
302
	notify(_last_msg);
-
 
303
	ExitProcess();
-
 
304
}
-
 
305
 
319
 
306
:unsigned char size[25]=0;
320
:unsigned char size[25];
307
:dword ConvertSizeToKb(unsigned int bytes)
321
:dword ConvertSizeToKb(unsigned int bytes)
308
{
322
{
309
	unsigned int kb;
323
	unsigned int kb;
Line 322... Line 336...
322
	}
336
	}
Line 323... Line 337...
323
 
337
 
324
	return #size;
338
	return #size;
Line -... Line 339...
-
 
339
}
-
 
340
 
-
 
341
//===================================================//
-
 
342
//                                                   //
-
 
343
//                      Copy                         //
-
 
344
//                                                   //
325
}
345
//===================================================//
326
 
346
 
327
:int CopyFileAtOnce(dword size, copyFrom, copyTo)
347
:int CopyFileAtOnce(dword size, copyFrom, copyTo)
328
dword cbuf;
348
dword cbuf;
329
int error;
349
int error;
Line 377... Line 397...
377
	}
397
	}
378
	free(cbuf);
398
	free(cbuf);
379
	return error;
399
	return error;
380
}
400
}
Line -... Line 401...
-
 
401
 
-
 
402
//===================================================//
-
 
403
//                                                   //
-
 
404
//                  Directory Size                   //
-
 
405
//                                                   //
-
 
406
//===================================================//
-
 
407
 
-
 
408
:struct _dir_size
-
 
409
{
-
 
410
	BDVK dir_info;
-
 
411
	dword folders;
-
 
412
	dword files;
-
 
413
	dword bytes;
-
 
414
	void get();	
-
 
415
	void calculate_loop();	
-
 
416
} dir_size;
-
 
417
 
-
 
418
:void _dir_size::get(dword way)
-
 
419
{
-
 
420
	folders = files = bytes = 0;
-
 
421
	if (way) calculate_loop(way);
-
 
422
}
-
 
423
 
-
 
424
:void _dir_size::calculate_loop(dword way)
-
 
425
{
-
 
426
	dword dirbuf, fcount, i, filename;
-
 
427
	dword cur_file;
-
 
428
	if (dir_exists(way))
-
 
429
	{
-
 
430
		cur_file = malloc(4096);
-
 
431
		// In the process of recursive descent, memory must be allocated dynamically, 
-
 
432
		// because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
-
 
433
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
-
 
434
		for (i=0; i
-
 
435
		{
-
 
436
			filename = i*304+dirbuf+72;
-
 
437
			sprintf(cur_file,"%s/%s",way,filename);
-
 
438
			
-
 
439
			if (TestBit(ESDWORD[filename-40], 4) )
-
 
440
			{
-
 
441
				folders++;
-
 
442
				calculate_loop(cur_file);
-
 
443
			}
-
 
444
			else
-
 
445
			{
-
 
446
				GetFileInfo(cur_file, #dir_info);
-
 
447
				bytes += dir_info.sizelo;
-
 
448
				files++;
-
 
449
			}
-
 
450
		}
-
 
451
		free(cur_file);
-
 
452
		free(dirbuf);
-
 
453
	}
Line 381... Line 454...
381
 
454
}
382
 
455