2022-02-06 17:41:02 +01:00
|
|
|
bool KolibriosMounted()
|
|
|
|
{
|
|
|
|
static bool kolibrios_mounted;
|
|
|
|
if (kolibrios_mounted) return true;
|
|
|
|
kolibrios_mounted = real_dir_exists("/kolibrios");
|
|
|
|
return kolibrios_mounted;
|
|
|
|
}
|
2013-03-20 23:35:57 +01:00
|
|
|
|
2016-01-06 21:50:19 +01:00
|
|
|
struct _SystemDiscs
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
2016-01-06 21:50:19 +01:00
|
|
|
collection list;
|
2018-10-01 18:41:14 +02:00
|
|
|
int dev_num;
|
|
|
|
void Get();
|
2016-01-06 21:50:19 +01:00
|
|
|
void Draw();
|
2021-06-15 01:33:54 +02:00
|
|
|
void DrawSelect();
|
|
|
|
void DrawOptions();
|
2020-05-23 13:26:58 +02:00
|
|
|
} SystemDiscs=0;
|
2013-03-11 19:16:24 +01:00
|
|
|
|
2018-10-01 18:41:14 +02:00
|
|
|
void _SystemDiscs::Get()
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
2014-10-31 00:20:36 +01:00
|
|
|
char dev_name[10], sys_discs[10];
|
2021-06-29 22:31:23 +02:00
|
|
|
int i1, j1, dev_disc_num, real_dev_num;
|
2021-06-17 23:29:58 +02:00
|
|
|
dword devbuf, diskbuf;
|
2015-08-17 15:45:24 +02:00
|
|
|
|
2016-01-06 21:50:19 +01:00
|
|
|
list.drop();
|
2015-12-13 14:52:19 +01:00
|
|
|
devbuf = malloc(10000);
|
2013-03-11 19:16:24 +01:00
|
|
|
ReadDir(19, devbuf, "/");
|
2021-06-29 22:31:23 +02:00
|
|
|
dev_num = real_dev_num = EBX;
|
|
|
|
|
|
|
|
list.add("/sys");
|
|
|
|
dev_num++;
|
|
|
|
|
2022-02-06 17:41:02 +01:00
|
|
|
if (KolibriosMounted()) {
|
2021-06-29 22:31:23 +02:00
|
|
|
//need to check that /sys != /kolibrios
|
|
|
|
list.add("/kolibrios");
|
|
|
|
dev_num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i1=0; i1<real_dev_num; i1++)
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
2016-10-30 20:17:46 +01:00
|
|
|
sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
|
2021-06-17 23:29:58 +02:00
|
|
|
GetDir(#diskbuf, #dev_disc_num, #dev_name, DIRS_NOROOT);
|
2021-07-09 10:03:31 +02:00
|
|
|
if (!EAX) for (j1=0; j1<dev_disc_num; j1++;)
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
2021-06-17 23:29:58 +02:00
|
|
|
sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ diskbuf+72);
|
2021-06-29 22:31:23 +02:00
|
|
|
if (sys_discs[1]=='r') {
|
|
|
|
dev_num--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sys_discs[1]=='c') || (sys_discs[1]=='f') || (dir_exists(#sys_discs)) {
|
|
|
|
list.add(#sys_discs);
|
2018-10-01 18:41:14 +02:00
|
|
|
}
|
2013-11-14 01:22:55 +01:00
|
|
|
}
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
2015-12-13 14:52:19 +01:00
|
|
|
free(devbuf);
|
2021-06-17 23:29:58 +02:00
|
|
|
free(diskbuf);
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
|
|
|
|
2021-12-01 14:48:58 +01:00
|
|
|
void GetDiskIconAndName(dword dev_name, icon, disc_name)
|
2021-06-27 11:28:59 +02:00
|
|
|
{
|
|
|
|
int i;
|
2021-12-01 14:48:58 +01:00
|
|
|
dword volume_label;
|
2021-06-27 11:28:59 +02:00
|
|
|
for (i=0; devinfo[i]!=0; i+=3) {
|
2021-06-29 22:31:23 +02:00
|
|
|
if (!strncmp(dev_name+1, devinfo[i], 2)) {
|
2021-12-01 14:48:58 +01:00
|
|
|
ESBYTE[icon] = devinfo[i+1];
|
2021-12-02 20:28:12 +01:00
|
|
|
if (ESBYTE[icon]==4)
|
2021-12-01 14:48:58 +01:00
|
|
|
{
|
|
|
|
//show label only for hard disk drives
|
2021-12-30 02:57:38 +01:00
|
|
|
volume_label = GetVolumeLabel(dev_name);
|
|
|
|
if (ESBYTE[volume_label]) {
|
2021-12-01 14:48:58 +01:00
|
|
|
strncpy(disc_name, volume_label, 15);
|
|
|
|
chrcat(disc_name, ' ');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-06-27 11:28:59 +02:00
|
|
|
strcpy(disc_name, devinfo[i+2]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-01 14:48:58 +01:00
|
|
|
ESBYTE[icon]=4;
|
2021-06-27 11:28:59 +02:00
|
|
|
strcpy(disc_name, T_UNC);
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:50:19 +01:00
|
|
|
void _SystemDiscs::Draw()
|
2013-03-11 19:16:24 +01:00
|
|
|
{
|
2021-06-27 11:28:59 +02:00
|
|
|
char dev_name[15], disc_name[100], i, dev_icon;
|
|
|
|
bool is_active=0;
|
2020-05-26 17:07:13 +02:00
|
|
|
int draw_y, draw_x;
|
2013-03-11 19:16:24 +01:00
|
|
|
|
2021-06-15 01:33:54 +02:00
|
|
|
if (efm) {
|
2021-06-28 00:16:37 +02:00
|
|
|
DrawSelect(2, KFM_DEV_DROPDOWN_1, location[0]);
|
|
|
|
DrawSelect(Form.cwidth/2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]);
|
2021-06-15 01:33:54 +02:00
|
|
|
files.y = 40 + 17;
|
|
|
|
} else {
|
2021-06-27 14:32:00 +02:00
|
|
|
Tip(56, T_DEVICES, 55, "=");
|
|
|
|
for (i=0; i<30; i++) DeleteButton(100+i);
|
|
|
|
|
2021-06-15 01:33:54 +02:00
|
|
|
draw_y = 74;
|
|
|
|
draw_x = 17;
|
|
|
|
for (i=0;i<list.count;i++) {
|
|
|
|
strcpy(#dev_name, list.get(i));
|
2021-06-29 22:31:23 +02:00
|
|
|
GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
|
2021-06-27 11:28:59 +02:00
|
|
|
if (strstr(path, #dev_name)==path) is_active=true; else is_active=false;
|
2021-06-15 01:33:54 +02:00
|
|
|
|
2020-05-26 17:07:13 +02:00
|
|
|
DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
|
|
|
|
DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
|
2021-06-27 11:28:59 +02:00
|
|
|
DefineHiddenButton(draw_x,draw_y,159,16,100+i);
|
2018-04-19 22:12:07 +02:00
|
|
|
if (show_dev_name.checked)
|
2015-08-09 21:08:57 +02:00
|
|
|
{
|
2021-12-03 00:37:22 +01:00
|
|
|
strcat(#disc_name, #dev_name);
|
2016-01-06 21:50:19 +01:00
|
|
|
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
|
2020-04-18 01:52:24 +02:00
|
|
|
WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
|
2021-06-15 01:33:54 +02:00
|
|
|
//if (is_active) kfont.bold = true;
|
|
|
|
//kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
|
|
|
|
//kfont.bold = false;
|
2020-04-18 01:52:24 +02:00
|
|
|
} else {
|
2016-01-06 21:50:19 +01:00
|
|
|
if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
|
|
|
|
WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
|
2015-08-09 21:08:57 +02:00
|
|
|
}
|
2022-01-09 07:36:16 +01:00
|
|
|
PutImage(draw_x+6,draw_y, 18,17, is_active*7+dev_icon*17*18*3+#devices);
|
2021-06-15 01:33:54 +02:00
|
|
|
draw_y += DEV_H;
|
2015-07-31 01:11:23 +02:00
|
|
|
}
|
2020-05-26 17:07:13 +02:00
|
|
|
DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
|
2021-06-28 00:16:37 +02:00
|
|
|
ActionsDraw(list.count*DEV_H+108);
|
|
|
|
DrawLeftPanelBg(list.count*DEV_H);
|
2015-08-10 00:26:14 +02:00
|
|
|
}
|
2013-03-11 19:16:24 +01:00
|
|
|
}
|
|
|
|
|
2021-06-27 11:28:59 +02:00
|
|
|
void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path)
|
2021-06-15 01:33:54 +02:00
|
|
|
{
|
2021-06-27 11:28:59 +02:00
|
|
|
char dev_name[15], disc_name[100], i, dev_icon;
|
|
|
|
|
|
|
|
if (ESBYTE[_path+1]=='\0') {
|
2021-06-15 01:33:54 +02:00
|
|
|
strcpy(#dev_name, "/root");
|
|
|
|
dev_icon = 0;
|
2021-06-27 11:28:59 +02:00
|
|
|
} else if (chrnum(_path, '/')==1) {
|
|
|
|
strcpy(#dev_name, _path);
|
2021-06-29 22:31:23 +02:00
|
|
|
GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
|
2021-06-15 01:33:54 +02:00
|
|
|
} else for (i=0;i<list.count;i++) {
|
|
|
|
strcpy(#dev_name, list.get(i));
|
2021-06-29 22:31:23 +02:00
|
|
|
GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
|
2021-06-27 11:28:59 +02:00
|
|
|
if (strstr(_path, #dev_name)-_path==0) break;
|
2021-06-15 01:33:54 +02:00
|
|
|
}
|
2022-01-09 07:36:16 +01:00
|
|
|
DrawRectangle(draw_x-1, SELECTY-1, DDW+2-KFM2_DEVH, KFM2_DEVH+1, sc.line);
|
2021-06-27 11:28:59 +02:00
|
|
|
DrawBar(draw_x, SELECTY, DDW+1-KFM2_DEVH, KFM2_DEVH, 0xFFFFFF);
|
2022-01-09 07:36:16 +01:00
|
|
|
PutImage(draw_x + 5, SELECTY+2, 18,17, dev_icon*17*18*3+#devices);
|
2021-06-27 11:28:59 +02:00
|
|
|
kfont.WriteIntoWindow(draw_x + 24, math.max(KFM2_DEVH-kfont.height/2+SELECTY,0), 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
|
2021-06-28 12:55:08 +02:00
|
|
|
DefineHiddenButton(draw_x, SELECTY, DDW-1, KFM2_DEVH-1, btid);
|
|
|
|
DrawFlatButtonSmall(draw_x+DDW-KFM2_DEVH+1, SELECTY-1, KFM2_DEVH-1, KFM2_DEVH+1, NULL, "\x19");
|
2021-06-15 01:33:54 +02:00
|
|
|
}
|
|
|
|
|
2021-06-27 11:28:59 +02:00
|
|
|
void _SystemDiscs::DrawOptions(int draw_x)
|
2021-06-15 01:33:54 +02:00
|
|
|
{
|
2021-06-27 11:28:59 +02:00
|
|
|
int optionsy = SELECTY+KFM2_DEVH+1;
|
2021-11-16 03:05:12 +01:00
|
|
|
char dev_name[15], disc_name[100], volume_label[64], label_file_name[100];
|
|
|
|
char i, dev_icon, is_active=0;
|
2021-06-15 01:33:54 +02:00
|
|
|
|
2021-07-04 19:27:35 +02:00
|
|
|
SystemDiscs.Get();
|
2021-06-15 01:33:54 +02:00
|
|
|
|
2022-01-09 07:36:16 +01:00
|
|
|
DrawPopup(draw_x, optionsy, DDW, list.count*KFM2_DEVH, 1, -1, sc.line);
|
2021-06-15 01:33:54 +02:00
|
|
|
|
|
|
|
for (i=0;i<list.count;i++) {
|
|
|
|
strcpy(#dev_name, list.get(i));
|
2021-06-29 22:31:23 +02:00
|
|
|
GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
|
2021-06-27 11:28:59 +02:00
|
|
|
if (strstr(path, #dev_name)!=0) is_active=true; else is_active=false;
|
2021-06-15 01:33:54 +02:00
|
|
|
|
2021-06-27 11:28:59 +02:00
|
|
|
DrawBar(draw_x, optionsy, DDW, KFM2_DEVH, 0xFFFFFF);
|
|
|
|
DefineButton(draw_x, optionsy, DDW, KFM2_DEVH-1, 100+i+BT_HIDE,0xFFFFFF);
|
2022-01-09 07:36:16 +01:00
|
|
|
PutImage(draw_x + 5, optionsy+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
|
2021-06-15 01:33:54 +02:00
|
|
|
if (is_active) kfont.bold = true;
|
2021-11-16 03:05:12 +01:00
|
|
|
//strncpy(#volume_label, GetVolumeLabel(#dev_name), sizeof(volume_label));
|
|
|
|
strcpy(#label_file_name, #dev_name);
|
|
|
|
//if (dev_name[1]!='k') && (dev_name[2]!='y') {
|
|
|
|
// if (volume_label) sprintf(#label_file_name, "%s [%s]", #dev_name, #volume_label);
|
|
|
|
//}
|
|
|
|
kfont.WriteIntoWindow(draw_x + 24, optionsy+2, 0xFFFfff, 0x000000, kfont.size.pt, #label_file_name+1);
|
2021-06-15 01:33:54 +02:00
|
|
|
kfont.bold = false;
|
2021-06-27 11:28:59 +02:00
|
|
|
optionsy += KFM2_DEVH;
|
2021-06-15 01:33:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 21:50:19 +01:00
|
|
|
|