1,90 → 1,96 |
// универсальность добавления / |
// относительный путь относительно программы |
|
void copyf(dword params) |
:void copyf(dword from1, in1) |
{ |
//copyf: /sys/lib|/sys/lib2 |
char from[4096], to[4096]; |
BDVK from_atr; |
int border; |
dword error; |
BDVK CopyFile_atr1; |
if (!from1) || (!in1) { notify("Error: too less copyf params!"); notify(from1); notify(in1); return; } |
error = GetFileInfo(from1, #CopyFile_atr1); |
if (error) |
debug("Error: copyf->GetFileInfo"); |
else |
if (isdir(from1)) CopyFolder(from1, in1); else CopyFile(from1, in1); |
} |
|
if (!params) { notify("Error: no copyf params!"); return; } |
//ищем разделитель |
border = strchr(params, '|'); |
if (!border) border = strchr(params, ' '); |
|
if (ESBYTE[params]<>'/') //абсолютный путь? |
:int CopyFile(dword copy_from3, copy_in3) |
{ |
strcpy(#from, #program_path); |
strcat(#from, params); |
from[border+strlen(#program_path)-1]=NULL; |
} |
BDVK CopyFile_atr; |
dword error, cbuf; |
debug(copy_from3); |
error = GetFileInfo(copy_from3, #CopyFile_atr); |
if (error) |
{debug("Error: CopyFile->GetFileInfo"); debug(copy_from3);} |
else |
{ |
strcat(#from, params); |
from[border-1]=NULL; |
} |
strcpy(#to, params+border); |
|
GetFileInfo(#from, #from_atr); |
if (TestBit(from_atr.attr, 4)==1) |
CopyFolder(#from, #to); |
cbuf = malloc(CopyFile_atr.sizelo); |
error = ReadFile(0, CopyFile_atr.sizelo, cbuf, copy_from3); |
if (error) |
debug("Error: CopyFile->ReadFile"); |
else |
CopyFile(#from, #to); |
{ |
error = WriteFile(CopyFile_atr.sizelo, cbuf, copy_in3); |
if (error) debug("Error: CopyFile->WriteFile"); |
} |
} |
free(cbuf); |
if (error) debug(copy_from3); |
return error; |
} |
|
|
void CopyFolder(dword from, to) |
:void CopyFolder(dword from2, in2) |
{ |
dword dirbuf, fcount, filename; |
int i, error, isdir; |
char copy_from[4096], copy_in[4096]; |
char from2[4096], to2[4096]; |
char copy_from2[4096], copy_in2[4096]; |
|
error = GetDir(#dirbuf, #fcount, from); |
if (error) { debug_error(from, error); return; } |
error = GetDir(#dirbuf, #fcount, from2); |
if (error) |
{ |
debug("Error: CopyFolder->GetDir"); |
debug_error(from2, error); |
debug_error(in2, error); |
free(dirbuf); |
return; |
} |
|
if ((strcmp(to, "/sys")!=0) && (strcmp(to, "/tmp9/1")!=0)) |
if ((strcmp(in2, "/sys")!=0) && (strcmp(in2, "/tmp9/1")!=0)) |
{ |
error = CreateDir(to); |
if (error) debug_error(to, error); |
error = CreateDir(in2); |
if (error) debug_error(in2, error); |
} |
chrcat(to, '/'); |
chrcat(from, '/'); |
chrcat(in2, '/'); |
chrcat(from2, '/'); |
|
for (i=0; i<fcount; i++) |
{ |
filename = i*304+dirbuf+72; |
|
isdir = TestBit(ESDWORD[filename-40], 4); |
if (isdir) |
{ |
if ( (!strcmp(filename, ".")) || (!strcmp(filename, "..")) ) continue; |
strcpy(#from2, from); |
strcpy(#to2, to); |
strcpy(#copy_from2, from2); |
strcpy(#copy_in2, in2); |
strcat(#copy_from2, filename); |
strcat(#copy_in2, filename); |
|
strcat(#from2, filename); |
strcat(#to2, filename); |
|
CopyFolder(#from2, #to2); |
CopyFolder(#copy_from2, #copy_in2); |
} |
else |
{ |
strcpy(#copy_from, from); |
strcat(#copy_from, filename); |
strcpy(#copy_in, to); |
strcat(#copy_in, filename); |
strcpy(#copy_from2, from2); |
strcat(#copy_from2, filename); |
strcpy(#copy_in2, in2); |
strcat(#copy_in2, filename); |
|
copyf_Action(filename); |
|
error = CopyFile(#copy_from, #copy_in); |
if (error) error = CopyFile(#copy_from, #copy_in); // #2 :) |
if (error) debug_error(#copy_in, error); |
if (CopyFile(#copy_from2, #copy_in2)!=0) CopyFile(#copy_from2, #copy_in2); // #2 :) |
} |
} |
free(dirbuf); |
} |
|
|
unsigned char *ERROR_TEXT[]={ |
"Code #0 - No error", |
"Error #1 - Base or partition of a hard disk is not defined", |
105,11 → 111,11 |
"Error #32 - Too many processes", |
0}; |
|
dword get_error(int N) |
:dword get_error(int N) |
{ |
char error[256]; |
if (N<0) N*=-1; |
if (N<33) |
N = fabs(N); |
if (N<=33) |
{ |
strcpy(#error, ERROR_TEXT[N]); |
} |
121,7 → 127,7 |
return #error; |
} |
|
void debug_error(dword path, error_number) |
:void debug_error(dword path, error_number) |
{ |
if (path) debug(path); |
debug(get_error(error_number)); |