Subversion Repositories Kolibri OS

Rev

Rev 5576 | 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
{
5582 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;
5582 pavelyakov 50
	$int 0x40;*/
51
 
52
	//sprintf(#text,"%s","ddf");
53
	WriteText(x, y, 0x80, color, "adas\0");
5487 leency 54
}
55
 
56
 
3067 leency 57
///////////////////////////
3440 leency 58
//   Параметры файла    //
59
///////////////////////////
5472 leency 60
:f70 getinfo_file_70;
3440 leency 61
:dword GetFileInfo(dword file_path, bdvk_struct)
62
{
63
    getinfo_file_70.func = 5;
64
    getinfo_file_70.param1 =
65
    getinfo_file_70.param2 =
66
    getinfo_file_70.param3 = 0;
67
    getinfo_file_70.param4 = bdvk_struct;
68
    getinfo_file_70.rezerv = 0;
69
    getinfo_file_70.name = file_path;
70
    $mov eax,70
71
    $mov ebx,#getinfo_file_70.func
3444 leency 72
    $int 0x40
3440 leency 73
}
74
 
75
///////////////////////////
5554 punk_joker 76
//   Изменение параметров файла    //
77
///////////////////////////
78
:f70 setinfo_file_70;
79
:dword SetFileInfo(dword file_path, bdvk_struct)
80
{
81
    setinfo_file_70.func = 6;
82
    setinfo_file_70.param1 =
83
    setinfo_file_70.param2 =
84
    setinfo_file_70.param3 = 0;
85
    setinfo_file_70.param4 = bdvk_struct;
86
    setinfo_file_70.rezerv = 0;
87
    setinfo_file_70.name = file_path;
88
    $mov eax,70
89
    $mov ebx,#setinfo_file_70.func
90
    $int 0x40
91
}
92
 
93
///////////////////////////
3067 leency 94
//   Запуск программы    //
95
///////////////////////////
5472 leency 96
:f70 run_file_70;
97
:signed int RunProgram(dword run_path, run_param)
3067 leency 98
{
99
    run_file_70.func = 7;
100
    run_file_70.param1 =
101
    run_file_70.param3 =
102
    run_file_70.param4 =
103
    run_file_70.rezerv = 0;
104
    run_file_70.param2 = run_param;
105
    run_file_70.name = run_path;
106
    $mov eax,70
107
    $mov ebx,#run_file_70.func
108
    $int 0x40
109
}
110
 
111
///////////////////////////
112
//    Создание папки     //
113
///////////////////////////
5472 leency 114
:f70 create_dir_70;
3067 leency 115
:int CreateDir(dword new_folder_path)
116
{
117
	create_dir_70.func = 9;
118
	create_dir_70.param1 =
119
	create_dir_70.param2 =
120
	create_dir_70.param3 =
121
	create_dir_70.param4 =
122
	create_dir_70.rezerv = 0;
123
	create_dir_70.name = new_folder_path;
124
	$mov eax,70
125
	$mov ebx,#create_dir_70.func
126
	$int 0x40
127
}
128
 
129
////////////////////////////
130
//  Удаление файла/папки  //
131
////////////////////////////
5472 leency 132
:f70 del_file_70;
3067 leency 133
:int DeleteFile(dword del_file_path)
134
{
135
	del_file_70.func = 8;
136
	del_file_70.param1 =
137
	del_file_70.param2 =
138
	del_file_70.param3 =
139
	del_file_70.param4 =
140
	del_file_70.rezerv = 0;
141
	del_file_70.name = del_file_path;
142
	$mov eax,70
143
	$mov ebx,#del_file_70.func
144
	$int 0x40
145
}
146
 
147
////////////////////////////
148
//     Прочитать файл     //
149
////////////////////////////
5472 leency 150
:f70 read_file_70;
3067 leency 151
:int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
152
{
153
	read_file_70.func = 0;
154
	read_file_70.param1 = read_pos;
155
	read_file_70.param2 = 0;
156
	read_file_70.param3 = read_file_size;
157
	read_file_70.param4 = read_buffer;
158
	read_file_70.rezerv = 0;
159
	read_file_70.name = read_file_path;
160
	$mov eax,70
161
	$mov ebx,#read_file_70.func
162
	$int 0x40
163
}
164
 
165
////////////////////////////
166
//     Записать файл      //
167
////////////////////////////
5472 leency 168
:f70 write_file_70;
3067 leency 169
:int WriteFile(dword write_file_size, write_buffer, write_file_path)
170
{
171
	write_file_70.func = 2;
172
	write_file_70.param1 = 0;
173
	write_file_70.param2 = 0;
174
	write_file_70.param3 = write_file_size;
175
	write_file_70.param4 = write_buffer;
176
	write_file_70.rezerv = 0;
177
	write_file_70.name = write_file_path;
178
	$mov eax,70
179
	$mov ebx,#write_file_70.func
180
	$int 0x40
5542 leency 181
}
3067 leency 182
 
5542 leency 183
//////////////////////////////////////////
184
//     WriteInFileThatAlredyExists      //
185
//////////////////////////////////////////
186
:f70 write_file_offset_70;
187
:int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset)
188
{
189
	write_file_offset_70.func = 3;
190
	write_file_offset_70.param1 = offset;
191
	write_file_offset_70.param2 = 0;
192
	write_file_offset_70.param3 = write_data_size;
193
	write_file_offset_70.param4 = write_buffer;
194
	write_file_offset_70.rezerv = 0;
195
	write_file_offset_70.name = write_file_path;
196
	$mov eax,70
197
	$mov ebx,#write_file_offset_70.func
198
	$int 0x40
199
}
200
 
3067 leency 201
///////////////////////////
202
//    Прочитать папку    //
203
///////////////////////////
5472 leency 204
:f70 read_dir_70;
3067 leency 205
:int ReadDir(dword file_count, read_buffer, dir_path)
3363 leency 206
{
3067 leency 207
	read_dir_70.func = 1;
208
	read_dir_70.param1 =
209
	read_dir_70.param2 =
210
	read_dir_70.rezerv = 0;
211
	read_dir_70.param3 = file_count;
212
	read_dir_70.param4 = read_buffer;
213
	read_dir_70.name = dir_path;
214
	$mov eax,70
215
	$mov ebx,#read_dir_70.func
216
	$int 0x40
217
}
218
 
5472 leency 219
:char isdir(dword fpath)
3440 leency 220
{
221
	BDVK fpath_atr;
222
	GetFileInfo(fpath, #fpath_atr);
5487 leency 223
	return fpath_atr.isfolder;
3440 leency 224
}
3877 leency 225
 
3440 leency 226
:int GetFile(dword buf, filesize, read_path)
227
{
228
	BDVK ReadFile_atr;
229
	dword rBuf;
230
	if (! GetFileInfo(read_path, #ReadFile_atr))
231
	{
232
		rBuf = malloc(ReadFile_atr.sizelo);
233
		if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
234
		{
235
			ESDWORD[buf] = rBuf;
236
			ESDWORD[filesize] = ReadFile_atr.sizelo;
237
			return 1;
238
		}
239
	}
240
	free(rBuf);
241
	return 0;
242
}
3067 leency 243
 
3444 leency 244
enum
3363 leency 245
{
3444 leency 246
	DIRS_ALL,
247
	DIRS_NOROOT,
248
	DIRS_ONLYREAL
249
};
250
:int GetDir(dword dir_buf, file_count, path, doptions)
251
{
3363 leency 252
	dword buf, fcount, error;
253
	buf = malloc(32);
254
	error = ReadDir(0, buf, path);
255
	if (!error)
256
	{
257
		fcount = ESDWORD[buf+8];
258
		buf = realloc(buf, fcount+1*304+32);
259
		ReadDir(fcount, buf, path);
3440 leency 260
		//fcount=EBX;
3444 leency 261
 
262
		if (doptions == DIRS_ONLYREAL)
263
		{
264
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
265
			if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
266
		}
267
		if (doptions == DIRS_NOROOT)
268
		{
269
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
270
		}
271
 
3363 leency 272
		ESDWORD[dir_buf] = buf;
273
		ESDWORD[file_count] = fcount;
274
	}
3440 leency 275
	else
3067 leency 276
	{
3440 leency 277
		ESDWORD[file_count] = 0;
278
		ESDWORD[dir_buf] = free(buf);
3067 leency 279
	}
3440 leency 280
	return error;
3067 leency 281
}
282
 
5421 leency 283
:dword notify(dword notify_param)
3067 leency 284
{
5421 leency 285
	return RunProgram("@notify", notify_param);
3081 leency 286
}
3432 leency 287
 
288
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
289
{
290
	char absolute_path[4096];
4137 leency 291
	if (ESBYTE[relative_path]=='/')
292
	{
293
		strcpy(#absolute_path, relative_path);
294
	}
295
	else
296
	{
297
		strcpy(#absolute_path, #program_path);
298
		absolute_path[strrchr(#absolute_path, '/')] = '\0';
299
		strcat(#absolute_path, relative_path);
300
	}
3432 leency 301
	return #absolute_path;
302
}
5483 leency 303
 
5576 pavelyakov 304
:dword ConvertSize(dword bytes)
5483 leency 305
{
5576 pavelyakov 306
  byte size_prefix[8], size_nm[4];
307
  if (bytes>=1073741824) strcpy(#size_nm, "Gb");
308
  else if (bytes>=1048576) strcpy(#size_nm, "Mb");
309
  else if (bytes>=1024) strcpy(#size_nm, "Kb");
310
  else strcpy(#size_nm, "b");
5483 leency 311
  while (bytes>1023) bytes/=1024;
312
  itoa_(#size_prefix, bytes);
313
  strcat(#size_prefix, #size_nm);
5576 pavelyakov 314
  //sprintf(#size_prefix,"%s","123");
5483 leency 315
  return #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
}