Eolite: show disk sizes

TmpDisk: get disk size by 70.5 instead of ini storage, impove board loging

git-svn-id: svn://kolibrios.org@7515 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-31 16:50:25 +00:00
parent c6ceff795e
commit 6260ae112b
5 changed files with 59 additions and 78 deletions

View File

@ -709,6 +709,7 @@ void Line_ReDraw(dword bgcol, filenum){
ext1, attr,
file_offet,
file_name_off,
file_size=0,
y=filenum*files.item_h+files.y,
icon_y = files.item_h-icon_size/2+1+y;
BDVK file;
@ -727,18 +728,13 @@ void Line_ReDraw(dword bgcol, filenum){
file.sizelo = ESDWORD[file_offet+32];
file.sizehi = ESDWORD[file_offet+36];
file_name_off = file_offet+40;
sprintf(#temp_path,"%s/%s",#path,file_name_off);
if (! TestBit(attr, 4) ) //file or folder?
{
ext1 = strrchr(file_name_off,'.') + file_name_off;
if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
WriteText(
7-strlen(ConvertSize64(file.sizelo, file.sizehi))*6+files.x+files.w - 58,
files.text_y+y+1,
files.font_type,
0,
ConvertSize64(file.sizelo, file.sizehi)
);
if (ext1==file_name_off) ext1 = NULL; //if no extension then show nothing
file_size = ConvertSize64(file.sizelo, file.sizehi);
if (ext1) && (strlen(ext1)<9) WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
}
else
@ -747,8 +743,10 @@ void Line_ReDraw(dword bgcol, filenum){
ext1="<DIR>";
WriteTextCenter(files.x+files.w-140, files.text_y+y+1, 72, 0, ext1);
}
if (chrnum(#path, '/')==1) file_size = GetDeviceSizeLabel(#temp_path);
}
sprintf(#temp_path,"%s/%s",#path,file_name_off);
if (file_size) WriteText(7-strlen(file_size)*6+files.x+files.w-58,
files.text_y+y+1, files.font_type, 0, file_size);
DrawIconByExtension(#temp_path, ext1, files.x+4, icon_y, bgcol);
if (TestBit(attr, 1)) || (TestBit(attr, 2)) text_col=0xA6A6B7; //system or hiden?
@ -1167,6 +1165,22 @@ void EventSelectFileByKeyPress()
}
}
dword GetDeviceSizeLabel(dword path)
{
BDVK bdvk;
char cdname[8];
if (ESBYTE[path+1] == '/') path++;
if (ESBYTE[path+1] == 'c') && (ESBYTE[path+2] == 'd')
&& (ESBYTE[path+4] == 0) {
//hack for http://board.kolibrios.org/viewtopic.php?p=72293#p72279
strcpy(#cdname, path);
strcat(#cdname, "/1");
path = #cdname;
}
GetFileInfo(path, #bdvk);
return ConvertSize64(bdvk.sizelo, bdvk.sizehi);
}
int GetRealFileCountInFolder(dword folder_path)
{
int fcount;

View File

@ -1,5 +1,5 @@
#define TITLE "Eolite File Manager 4.03"
#define ABOUT_TITLE "EOLITE 4.03"
#define TITLE "Eolite File Manager 4.04"
#define ABOUT_TITLE "EOLITE 4.04"
#ifdef LANG_RUS
?define T_FILE "” ©«"

View File

@ -3,12 +3,10 @@
/////////////////////////////////////////////////////////////////////////////////////////
#ifdef LANG_RUS
?define ADD_DISK_TEXT "¯à®¡ãî ¤®¡ ¢¨âì ¢¨àâã «ì­ë© ¤¨áª"
?define DELETE_DISK_TEXT "¯à®¡ãî 㤠«¨âì ¢¨àâã «ì­ë© ¤¨áª"
?define DONT_KNOW_DISK_SIZE_TEXT "¥£® à §¬¥à ­¥ 㪠§ ­, 20% ᢮¡®¤­®© Ž‡“ ¡ã¤¥â ¨á¯®«ì§®¢ ­®"
?define NEW_DISK_TEXT "à §¬¥à ¤¨áª  ¡ã¤¥â: "
?define DELETE_DISK_TEXT "<EFBFBD>஡ãî 㤠«¨âì /tmp%i"
?define NEW_DISK_TEXT "<EFBFBD>஡ãî ¤®¡ ¢¨âì ¢¨àâã «ì­ë© ¤¨áª /tmp%i à §¬¥à®¬ %i MB"
char *rezult_text[]={
"®¯¥à æ¨ï ãᯥ譮 § ¢¥à襭 ",
"TmpDisk ®¯¥à æ¨ï ãᯥ譮 § ¢¥à襭 ",
"­¥¨§¢¥áâ­ë© IOCTL, ­¥¢¥à­ë© à §¬¥à ¯à¥¤®áâ ¢«ï¥¬ëå ¤ ­­ëå...",
"­®¬¥à ¤¨áª  ¤®«¦¥­ ¡ëâì ®â 0 ¤® 9",
"à §¬¥à ᮧ¤ ¢ ¥¬®£® ¤¨áª  ᫨誮¬ ¢¥«¨ª",
@ -17,12 +15,10 @@
"­¥¨§¢¥áâ­ ï ®è¨¡ª  O_o",
0};
#else
?define ADD_DISK_TEXT "trying to add disk"
?define DELETE_DISK_TEXT "trying to delete virtual disk"
?define DONT_KNOW_DISK_SIZE_TEXT "its size is not specified, 20% from free RAM will be used"
?define NEW_DISK_TEXT "new DiskSize: "
?define DELETE_DISK_TEXT "Trying to delete /tmp%i"
?define NEW_DISK_TEXT "Trying to add virtual disk /tmp%i, the size of %i MB"
char *rezult_text[]={
"operation completed successfully",
"TmpDisk operation completed successfully",
"unknown IOCTL code, wrong input/output size...",
"DiskId must be from 0 to 9",
"DiskSize is too large",
@ -48,8 +44,7 @@ char Console_Work()
debugln("d[number] - delete RAM disk");
ExitProcess();
break;
case 'd':
debugln(DELETE_DISK_TEXT);
case 'd': //Delete disk
del_disk.DiskId = param[1]-'0';
ioctl.handle = driver_handle;
ioctl.io_code = DEV_DEL_DISK;
@ -57,24 +52,19 @@ char Console_Work()
ioctl.inp_size = sizeof(del_disk);
ioctl.output = 0;
ioctl.out_size = 0;
disk_sizes[del_disk.DiskId] = 0;
sprintf(#size_t, DELETE_DISK_TEXT, add_disk.DiskId);
debugln(#size_t);
break;
case 'a':
debugln(ADD_DISK_TEXT);
case 'a': //Add disk
disk_size= strchr(#param, 's');
if (!disk_size)
{
add_disk.DiskSize = GetFreeRAM() / 5 * 2;
debugln(DONT_KNOW_DISK_SIZE_TEXT);
}
else
{
add_disk.DiskSize = atoi(disk_size+1)*2048;
}
strcpy(#size_t, NEW_DISK_TEXT);
strcat(#size_t, itoa(add_disk.DiskSize/2048));
strcat(#size_t, " MB");
debugln(#size_t);
add_disk.DiskId = param[1]-'0';
ioctl.handle = driver_handle;
ioctl.io_code = DEV_ADD_DISK;
@ -82,7 +72,8 @@ char Console_Work()
ioctl.inp_size = sizeof(add_disk);
ioctl.output = 0;
ioctl.out_size = 0;
disk_sizes[add_disk.DiskId] = add_disk.DiskSize * 512;
sprintf(#size_t, NEW_DISK_TEXT, add_disk.DiskId, add_disk.DiskSize/2048);
debugln(#size_t);
break;
default:
debugln("unknown command line parameters");

View File

@ -55,9 +55,9 @@ void Main_Window()
int x;
load_dll(boxlib, #box_lib_init,0);
GetSizeDisk();
GetNewSizeDisk();
edit_disk_size.left = strlen(SIZE_TEXT)*9 + 10;
SetEventMask(0x27);
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop()
{
switch(WaitEvent())
@ -142,7 +142,7 @@ void Main_Window()
break;
case evReDraw:
system.color.get();
DefineAndDrawWindow(170,150,405,290,0x74,system.color.work,"Virtual Disk Manager 0.67a",0);
DefineAndDrawWindow(170,150,405,290,0x74,system.color.work,"Virtual Disk Manager 0.68",0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break;
@ -151,7 +151,6 @@ void Main_Window()
WriteText(6, 9, 0x90, system.color.work_text, SIZE_TEXT);
WriteText(edit_disk_size.left + edit_disk_size.width + 12, 9, 0x90, system.color.work_text, "MB.");
DrawEditBox(#edit_disk_size);
x = 6;
x = 6 + DrawStandartCaptButton(6, 36, 10, T_ADD_DISK);
DrawStandartCaptButton(x, 36, 11, T_DELETE_DISK);
_PutImage(6+6, 42, 14,14, #icons);
@ -163,7 +162,7 @@ void Main_Window()
}
void GetSizeDisk()
void GetNewSizeDisk()
{
int fr;
fr = GetFreeRAM() / 5 * 2;
@ -209,14 +208,24 @@ void GetDisks()
}
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp0/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
unsigned int disk_pos_x[]={13,13,13,102,102,102,191,191,191,279,279,279};
unsigned int disk_pos_y[]={79,127,175, 79,127,175, 79,127,175, 79,127,175};
void DrawTmpDisks()
{
#define SELECTION_ACTIVE 0x0080FF;
#define SELECTION_INACTIVE 0x757489;
dword selection_color;
dword selection_active = 0x0080FF;
dword selection_inactive = 0x757489;
char free_ram_text[60];
byte i, real_id;
int FreeRAM=GetFreeRAM()/1024;
@ -240,10 +249,13 @@ void DrawTmpDisks()
DefineButton(disk_pos_x[i], disk_pos_y[i], 80, 40, 20+i, 0xFFFfff);
WriteText(disk_pos_x[i]+26,disk_pos_y[i]+6, 10110000b, 0x222222, #disk_list[i].Item);
real_id = disk_list[i].Item[3] - '0';
WriteText(disk_pos_x[i]+27,disk_pos_y[i]+24, 0x80, 0x555555, ConvertSize(disk_sizes[real_id]));
WriteText(disk_pos_x[i]+27,disk_pos_y[i]+24, 0x80, 0x555555, ConvertSize(GetDiskSize(real_id)));
_PutImage(disk_pos_x[i]+6,disk_pos_y[i]+6, 14,14, 2*14*14*3+#icons);
if (selected==i) {
if ( edit_disk_size.flags & ed_focus) selection_color = selection_inactive; else selection_color = selection_active;
if ( edit_disk_size.flags & ed_focus)
selection_color = SELECTION_INACTIVE;
else
selection_color = SELECTION_ACTIVE;
DrawWideRectangle(disk_pos_x[i], disk_pos_y[i], 80, 40, 2, selection_color);
PutPixel(disk_pos_x[i], disk_pos_y[i], 0xFFFfff);
}
@ -279,7 +291,7 @@ void AddDisk()
pause(5);
GetDisks();
DrawTmpDisks();
GetSizeDisk();
GetNewSizeDisk();
}

View File

@ -4,10 +4,6 @@
#include "..\lib\strings.h"
#include "..\lib\fs.h"
#include "..\lib\dll.h"
#include "..\lib\obj\libio.h"
#include "..\lib\obj\libini.h"
#ifndef AUTOBUILD
#include "lang.h--"
#endif
@ -47,10 +43,6 @@ del_disk_struc del_disk;
int driver_handle;
dword disk_sizes[10];
_ini ini = { "/sys/settings/system.ini", "DiskSizes" };
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// Code ////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
@ -67,40 +59,12 @@ void main()
ExitProcess();
}
GetDiskSizesFromIni();
if (param)
Console_Work();
else
Main_Window();
SaveDiskSizesToIni();
ExitProcess();
}
void GetDiskSizesFromIni()
{
char i, key[2];
load_dll(libini, #lib_init, 1);
key[1]=0;
for (i=0; i<=9; i++)
{
key[0]=i+'0';
disk_sizes[i] = ini.GetInt(#key, 0);
}
}
void SaveDiskSizesToIni()
{
char i, key[2];
key[1]=0;
for (i=0; i<=9; i++)
{
key[0]=i+'0';
if (disk_sizes[i]) ini.SetInt(#key, disk_sizes[i]);
}
}
stop: