Eolite: better menu selection, F5 / Tmpdisk: small fix, less debug / Installer: fixes, copyf() unification

git-svn-id: svn://kolibrios.org@3440 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-04-02 13:33:32 +00:00
parent 8effd409af
commit 2e36ea6cf7
8 changed files with 146 additions and 160 deletions

View File

@ -24,8 +24,8 @@
#define WITH_REDRAW 1
#define ONLY_OPEN 2
#define TITLE "Eolite File Manager v1.8"
#define ABOUT_TITLE "Eolite v1.80"
#define TITLE "Eolite File Manager v1.81"
#define ABOUT_TITLE "Eolite v1.81"
dword col_work = 0xE4DFE1;
dword col_border = 0x819FC5;
dword col_padding = 0xC8C9C9;
@ -221,14 +221,6 @@ void main()
sort_num=id-30;
Open_Dir(#path,WITH_REDRAW);
break;
case 78: //rescan devices
Tip(56, "Devices", 78, "-");
pause(10);
GetIni(1);
SystemDiscsGet();
Open_Dir(#path,WITH_REDRAW);
DrawLeftPanel();
break;
case 50...60: //Actions
ActionsProcess(id-50);
break;
@ -770,8 +762,14 @@ void ActionsProcess(char N)
case 4:
IF (!isdir) RunProgram("/sys/develop/heed", #file_path);
break;
case 5:
case 5: //refresh cur dir & devs
Tip(56, "Devices", 55, "-");
Open_Dir(#path,WITH_REDRAW);
pause(10);
GetIni(1);
SystemDiscsGet();
Open_Dir(#path,1);
DrawLeftPanel();
break;
case 6:
strcpy(#temp, #path);

View File

@ -7,6 +7,7 @@ char *captions[] = {
"View as HEX", "F4",
"Rename", "F2",
"Delete", "Del",
//"Refresh", "F5",
0};
void FileMenu()
@ -32,7 +33,7 @@ void FileMenu()
if (slot != GetActiveProcess()) ExitProcess();
mm.get();
newi = mm.y - 1 / lineh;
//if (m.y<0) || (newi+1>items_num) || (m.x<0) || (m.x>ITEM_WIDTH) break;
if (mm.y<=0) || (mm.y>ccount*lineh+5) || (mm.x<0) || (mm.x>linew) newi=-1;
if (cur<>newi)
{
cur=newi;
@ -48,6 +49,7 @@ void FileMenu()
if (id==103) ActionsProcess(4);
if (id==104) ActionsProcess(2);
if (id==105) Del_Form();
if (id==106) ActionsProcess(5);
ExitProcess();
break;

View File

@ -51,7 +51,7 @@ void SystemDiscsDraw()
char dev_name[10], disc_name[100];
int i, dev_icon;
Tip(56, "Devices", 78, "=");
Tip(56, "Devices", 55, "=");
for (i=0; i<20; i++) DeleteButton(100+i);
for (i=0;i<disc_num;i++)
{

View File

@ -39,13 +39,6 @@ void ShowProgress(dword text1)
}
dword *copyfiles[] = {
"sys /sys",
"tmp /tmp9/1",
0
};
void Install()
{
int i;
@ -59,12 +52,14 @@ void Install()
if (i==Form.ID) || (strchr(#Process.name, '/')) || (strchr(#Process.name, 'Z')) continue;
KillProcess(i);
}
//RunProgram("/sys/develop/board", NULL); //temp============
RunProgram("/sys/REFRSCRN", NULL);
pause(100);
ShowProgress("Copying files...");
copyf("/sys/docpack /tmp9/1/docpack");
copyf("/sys/docpack", "/tmp9/1/docpack");
DeleteFile("/sys/docpack");
for (i = 0; copyfiles[i]!=0; i++) copyf(copyfiles[i]);
copyf(abspath("sys"), "/sys");
copyf(abspath("tmp"), "/tmp9/1");
ShowProgress("Post install actions...");
RunProgram("/sys/launcher", NULL);
SetSystemSkin("/tmp9/1/skins/latte.skn");

View File

@ -55,7 +55,6 @@ int DefineWindow(dword wtitle, wbutton)
void main()
{
mem_Init();
program_path[strrchr(#program_path, '/')] = '\0';
HalloLoop();
}

View File

@ -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;
if (!params) { notify("Error: no copyf params!"); return; }
//ищем разделитель
border = strchr(params, '|');
if (!border) border = strchr(params, ' ');
if (ESBYTE[params]<>'/') //абсолютный путь?
{
strcpy(#from, #program_path);
strcat(#from, params);
from[border+strlen(#program_path)-1]=NULL;
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);
}
:int CopyFile(dword copy_from3, copy_in3)
{
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; }
if ((strcmp(to, "/sys")!=0) && (strcmp(to, "/tmp9/1")!=0))
error = GetDir(#dirbuf, #fcount, from2);
if (error)
{
error = CreateDir(to);
if (error) debug_error(to, error);
debug("Error: CopyFolder->GetDir");
debug_error(from2, error);
debug_error(in2, error);
free(dirbuf);
return;
}
chrcat(to, '/');
chrcat(from, '/');
if ((strcmp(in2, "/sys")!=0) && (strcmp(in2, "/tmp9/1")!=0))
{
error = CreateDir(in2);
if (error) debug_error(in2, error);
}
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 @@ unsigned char *ERROR_TEXT[]={
"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 @@ dword get_error(int N)
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));

View File

@ -23,6 +23,37 @@ struct BDVK{
char name[518];
};
inline fastcall void SetCurDir( ECX)
{
$mov eax,30
$mov ebx,1
$int 0x40
}
inline fastcall void GetCurDir( ECX, EDX)
{
$mov eax,30
$mov ebx,2
$int 0x40
}
///////////////////////////
// Ïàğàìåòğû ôàéëà //
///////////////////////////
f70 getinfo_file_70;
:dword GetFileInfo(dword file_path, bdvk_struct)
{
getinfo_file_70.func = 5;
getinfo_file_70.param1 =
getinfo_file_70.param2 =
getinfo_file_70.param3 = 0;
getinfo_file_70.param4 = bdvk_struct;
getinfo_file_70.rezerv = 0;
getinfo_file_70.name = file_path;
$mov eax,70
$mov ebx,#getinfo_file_70.func
$int 0x40
}
///////////////////////////
// Çàïóñê ïðîãðàììû //
@ -96,25 +127,6 @@ f70 read_file_70;
$int 0x40
}
:int GetFile(dword buf, filesize, read_path)
{
BDVK ReadFile_atr;
dword rBuf;
if (! GetFileInfo(read_path, #ReadFile_atr))
{
rBuf = malloc(ReadFile_atr.sizelo);
if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
{
ESDWORD[buf] = rBuf;
ESDWORD[filesize] = ReadFile_atr.sizelo;
return 1;
}
}
free(rBuf);
return 0;
}
////////////////////////////
// Çàïèñàòü ôàéë //
////////////////////////////
@ -151,11 +163,33 @@ f70 read_dir_70;
$int 0x40
}
char isdir(dword fpath)
{
BDVK fpath_atr;
GetFileInfo(fpath, #fpath_atr);
if (TestBit(fpath_atr.attr, 4)==1) return 1; else return 0;
}
:int GetFile(dword buf, filesize, read_path)
{
BDVK ReadFile_atr;
dword rBuf;
if (! GetFileInfo(read_path, #ReadFile_atr))
{
rBuf = malloc(ReadFile_atr.sizelo);
if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
{
ESDWORD[buf] = rBuf;
ESDWORD[filesize] = ReadFile_atr.sizelo;
return 1;
}
}
free(rBuf);
return 0;
}
:int GetDir(dword dir_buf, file_count, path)
{
dword buf, fcount, error;
ESDWORD[file_count] = 0;
buf = malloc(32);
error = ReadDir(0, buf, path);
if (!error)
@ -163,69 +197,21 @@ f70 read_dir_70;
fcount = ESDWORD[buf+8];
buf = realloc(buf, fcount+1*304+32);
ReadDir(fcount, buf, path);
//fcount=EBX;
if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
ESDWORD[dir_buf] = buf;
ESDWORD[file_count] = fcount;
}
else
{
ESDWORD[file_count] = 0;
ESDWORD[dir_buf] = free(buf);
}
return error;
}
///////////////////////////
// Ïàğàìåòğû ôàéëà //
///////////////////////////
f70 getinfo_file_70;
:dword GetFileInfo(dword file_path, bdvk_struct)
{
getinfo_file_70.func = 5;
getinfo_file_70.param1 =
getinfo_file_70.param2 =
getinfo_file_70.param3 = 0;
getinfo_file_70.param4 = bdvk_struct;
getinfo_file_70.rezerv = 0;
getinfo_file_70.name = file_path;
$mov eax,70
$mov ebx,#getinfo_file_70.func
$int 0x40
}
///////////////////////////
// Ñêîïèğîâàòü ôàéë //
///////////////////////////
:int CopyFile(dword copy_from, copy_in)
{
BDVK CopyFile_atr;
dword cBufer=0;
char rezult = -1;
if (! GetFileInfo(copy_from, #CopyFile_atr))
{
cBufer = malloc(CopyFile_atr.sizelo);
if (! ReadFile(0, CopyFile_atr.sizelo, cBufer, copy_from))
{
rezult = WriteFile(CopyFile_atr.sizelo, cBufer, copy_in);
}
}
free(cBufer);
return rezult;
}
inline fastcall void SetCurDir( ECX)
{
$mov eax,30
$mov ebx,1
$int 0x40
}
inline fastcall void GetCurDir( ECX, EDX)
{
$mov eax,30
$mov ebx,2
$int 0x40
}
void notify(dword notify_param)
:void notify(dword notify_param)
{
RunProgram("@notify", notify_param);
}
@ -233,6 +219,7 @@ void notify(dword notify_param)
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
{
char absolute_path[4096];
if (ESBYTE[relative_path]=='/') return relative_path;
strcpy(#absolute_path, #program_path);
absolute_path[strrchr(#absolute_path, '/')] = '\0';
strcat(#absolute_path, relative_path);

View File

@ -55,12 +55,11 @@ void main()
driver_handle = LoadDriver("tmpdisk");
if (driver_handle==0)
{
notify("error: /rd1/1/lib/tmpdisk.obj driver loading failed");
notify("error: /rd1/1/drivers/tmpdisk.obj driver loading failed");
notify("program terminated");
ExitProcess();
}
else
debug("tmpdisk.obj driver loaded successfully");
if (param)
Console_Work();