Subversion Repositories Kolibri OS

Rev

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

Rev 7202 Rev 7210
Line 127... Line 127...
127
 
127
 
128
  ////////////////////////////
128
  ////////////////////////////
129
 //     Ïðî÷èòàòü ôàéë     //
129
 //     Ïðî÷èòàòü ôàéë     //
130
////////////////////////////
130
////////////////////////////
131
:f70 read_file_70; 
131
:f70 read_file_70; 
132
:int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
132
:int ReadFile(dword offset, data_size, buffer, file_path)
133
{
133
{
134
	read_file_70.func = 0;
134
	read_file_70.func = 0;
135
	read_file_70.param1 = read_pos;
135
	read_file_70.param1 = offset;
136
	read_file_70.param2 = 0;
136
	read_file_70.param2 = 0;
137
	read_file_70.param3 = read_file_size;
137
	read_file_70.param3 = data_size;
138
	read_file_70.param4 = read_buffer;
138
	read_file_70.param4 = buffer;
139
	read_file_70.rezerv = 0;
139
	read_file_70.rezerv = 0;
140
	read_file_70.name = read_file_path;
140
	read_file_70.name = file_path;
141
	$mov eax,70
141
	$mov eax,70
142
	$mov ebx,#read_file_70.func
142
	$mov ebx,#read_file_70.func
143
	$int 0x40
143
	$int 0x40
Line 144... Line -...
144
}
-
 
145
 
-
 
146
  ///////////////////////////
-
 
147
 //     Çàïèñàòü ôàéë     //
144
}
148
///////////////////////////
145
 
149
:f70 write_file_70; 
146
:f70 write_file_70; 
150
:int WriteFile(dword write_file_size, write_buffer, write_file_path)
147
:int WriteFile(dword data_size, buffer, file_path)
151
{
148
{
152
	write_file_70.func = 2;
149
	write_file_70.func = 2;
153
	write_file_70.param1 = 0;
150
	write_file_70.param1 = 0;
154
	write_file_70.param2 = 0;
151
	write_file_70.param2 = 0;
155
	write_file_70.param3 = write_file_size;
152
	write_file_70.param3 = data_size;
156
	write_file_70.param4 = write_buffer;
153
	write_file_70.param4 = buffer;
157
	write_file_70.rezerv = 0;
154
	write_file_70.rezerv = 0;
158
	write_file_70.name = write_file_path;
155
	write_file_70.name = file_path;
159
	$mov eax,70
156
	$mov eax,70
160
	$mov ebx,#write_file_70.func
157
	$mov ebx,#write_file_70.func
Line 161... Line 158...
161
	$int 0x40
158
	$int 0x40
162
}
159
}
163
 
160
 
164
  ////////////////////////////////////////
161
  ////////////////////////////////////////
165
 //     WriteInFileThatAlredyExists    //
162
 //     WriteInFileThatAlredyExists    //
166
////////////////////////////////////////
163
////////////////////////////////////////
167
:f70 write_file_offset_70; 
164
:f70 write_file_offset_70; 
168
:int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset)
165
:int WriteFileWithOffset(dword offset, data_size, buffer, file_path)
169
{
166
{
170
	write_file_offset_70.func = 3;
167
	write_file_offset_70.func = 3;
171
	write_file_offset_70.param1 = offset;
168
	write_file_offset_70.param1 = offset;
172
	write_file_offset_70.param2 = 0;
169
	write_file_offset_70.param2 = 0;
173
	write_file_offset_70.param3 = write_data_size;
170
	write_file_offset_70.param3 = data_size;
174
	write_file_offset_70.param4 = write_buffer;
171
	write_file_offset_70.param4 = buffer;
175
	write_file_offset_70.rezerv = 0;
172
	write_file_offset_70.rezerv = 0;
176
	write_file_offset_70.name = write_file_path;
173
	write_file_offset_70.name = file_path;
177
	$mov eax,70
174
	$mov eax,70
Line -... Line 175...
-
 
175
	$mov ebx,#write_file_offset_70.func
178
	$mov ebx,#write_file_offset_70.func
176
	$int 0x40
179
	$int 0x40
177
}
180
}   
178
 
181
 
179
 
182
  ///////////////////////////
180
  ///////////////////////////
Line 344... Line 342...
344
		strcat(#size, " b");
342
		strcat(#size, " b");
345
	}
343
	}
Line 346... Line 344...
346
 
344
 
347
	return #size;
345
	return #size;
-
 
346
}
-
 
347
 
-
 
348
:int CopyFileAtOnce(dword size, copyFrom, copyTo)
-
 
349
dword cbuf;
-
 
350
int error;
-
 
351
{
-
 
352
	cbuf = malloc(size);
-
 
353
	if (error = ReadFile(0, size, cbuf, copyFrom))
-
 
354
	{
-
 
355
		debugln("Error: CopyFileAtOnce->ReadFile");
-
 
356
	}
-
 
357
	else
-
 
358
	{
-
 
359
		if (error = WriteFile(size, cbuf, copyTo)) debugln("Error: CopyFileAtOnce->WriteFile");
-
 
360
	}
-
 
361
	free(cbuf);
-
 
362
	return error;
-
 
363
}
-
 
364
 
-
 
365
:int CopyFileByBlocks(dword size, copyFrom, copyTo)
-
 
366
dword cbuf;
-
 
367
int error=-1;
-
 
368
dword offpos=0;
-
 
369
int block_size=1024*4024; //copy by 4 MiBs
-
 
370
{
-
 
371
	cbuf = malloc(block_size);
-
 
372
	WriteFile(0, 0, copyTo); //create file
-
 
373
	while(offpos < size)
-
 
374
	{
-
 
375
		error = ReadFile(offpos, block_size, cbuf, copyFrom);
-
 
376
		if (error = 6) { //File ended before last byte was readed
-
 
377
			block_size = EBX; 
-
 
378
			error=0; 
-
 
379
		} 
-
 
380
		else
-
 
381
			if (error!=0) break;
-
 
382
		if (error = WriteFileWithOffset(offpos, block_size, cbuf, copyTo)) break;
-
 
383
		offpos += block_size;
-
 
384
	}
-
 
385
	free(cbuf);
-
 
386
	return error;
-
 
387
}
-
 
388
 
348
}
389
 
349
#endif
390
#endif