add tmpdisk 0.35 to fs folder

git-svn-id: svn://kolibrios.org@3042 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-11-15 21:43:25 +00:00
parent 6aaee92088
commit 5012225aed
5 changed files with 412 additions and 0 deletions

View File

@ -0,0 +1,9 @@
del lang.h
echo #define LANG_RUS 1 >lang.h
..\C--\C-- tmpdisk.c
del tmpdisk
rename tmpdisk.com tmpdisk
rem ..\C--\kpack tmpdisk
pause
del warning.txt

View File

@ -0,0 +1 @@
<01><01><01><01><01><01><01><01><01><01><01><01><01><01>Ί;ΤCΊ;ΤCΤCΤC)ζWΤC)ζW)ζW)ζW)ζW<01>µ9Ί;ΤCΊ;<01><01><01><01>ΤCΤC)ζW)ζW<01>Ί;µ9Ί;Ί;<01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01>Ί;)ζWΤC)ζW<01>µ9Ί;ΤCµ9<01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01>Ί;Ί;Ί;ΤC<01>µ9<01><01><01><01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01><01><01><01>ΤC<01>µ9<01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01>Ί;<01>Ί;<01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01>ΤC<01>µ9<01><01><01><01><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><01><01><01><01>ΤC<01>µ9Ί;Ί;Ί;<01><12><><EFBFBD><EFB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/Βλ±α/Βλ/Βλ/ΒλOΣτ/ΒλOΣτOΣτOΣτOΣτ ] ] δ±α/Βλ±α‹Όp<>p<>‹Ό/Βλ/ΒλOΣτOΣτ ] ]±α δ±α±αc<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<>/ΒλOΣτ/ΒλOΣτ ] ] δ±α/Βλ δc<>c<>±α±α±α/Βλ ] ] δ±α±α±α±α±α/Βλ±α±α±α±α/Βλ ] ] δ±α±α±α‹Όp<>p<>‹Ό±α±α/Βλ±α ] ]±α δ±α δc<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<>±α±α±α/Βλ ] ] δ±α±α±αc<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<>OΣτ±α±α/Βλ ] ] δ±α±α±αc<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<>/Βλ±α±α/Βλ ] ] δ±α±α±αc<><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<>/Βλ±α/Βλ±α ] ]±α δ±α±αc<>c<>c<>c<>±α δ±α/Βλ ] ]•Ω¨δ<01>ί δ δ±α δ δ δ±α δ±α ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]<><E2809A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lggWPPWPPWPPWPPWPPWPPWPPWPPWPPWPPWPPlgg<67><67><EFBFBD>WPP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WPP<50><50><EFBFBD>WPPεββεββεββεββεββεββεββεββεββεββεββWPP<50><50><EFBFBD>WPPεββεββεββεββεββεββεββεββεββεββεββWPP<50><50><EFBFBD>WPP«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£«Ά£WPP<50><50><EFBFBD>WPPWPPWPPWPPWPPWPPWPPWPPWPPWPPWPPWPPWPP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD>WPP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

View File

@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// êîíñîëü ////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/*#ifdef LANG_RUS
char *rezult_text[]={
"îïåðàöèÿ óñïåøíî çàâåðøåíà"w,
"íåèçâåñòíûé IOCTL, íåâåðíûé ðàçìåð ïðåäîñòàâëÿåìûõ äàííûõ..."w,
"íîìåð äèñêà äîëæåí áûòü îò 0 äî 9"w,
"ðàçìåð ñîçäàâàåìîãî äèñêà ñëèøêîì âåëèê"w,
"ðàçìåð ñîçäàâàåìîãî äèñêà ñëèøêîì ìàë"w,
"îøèáêà âûäåëåíèÿ ïàìÿòè"w,
"íåèçâåñòíàÿ îøèáêà O_o"w,
0};
#else*/
char *rezult_text[]={
"operation compleated successfully",
"unknown IOCTL code, wrong input/output size...",
"DiskId must be from 0 to 9",
"DiskSize is too large",
"DiskSize is too small",
"memory allocation failed",
"unknown error O_o",
0};
//#endif
void Console_Work()
{
unsigned int disk_size, driver_rezult;
char size_t[256];
strlwr(#param);
switch (param[0])
{
case '?': //ïîìîùü ïî êîììàíäàì
case 'h':
debug("tmpdisk command line parameters:");
debug("a[number]s[size in MB] - add RAM disk");
debug("d[number] - delete RAM disk");
ExitProcess();
break;
case 'd': //óäàëèòü äèñê
debug("trying to delete disk");
del_disk.DiskId = param[1]-'0';
ioctl.handle = driver_handle;
ioctl.io_code = DEV_DEL_DISK;
ioctl.input = #del_disk;
ioctl.inp_size = sizeof(del_disk);
ioctl.output = 0;
ioctl.out_size = 0;
break;
case 'a': //äîáàâèòü äèñê
debug("trying to add disk");
disk_size= strchr(#param, 's');
if (!disk_size)
{
add_disk.DiskSize = GetFreeRAM() / 5;
debug("disk size is not specified");
strcpy(#size_t, "10% from free RAM will be used, new DiskSize: ");
driver_rezult=itoa(add_disk.DiskSize/2048);
strcat(#size_t, driver_rezult);
//strcat(#size_t, itoa(add_disk.DiskSize/2048));
strcat(#size_t, " MB");
debug(#size_t);
}
else
add_disk.DiskSize = atoi(#param+disk_size)*2048;
add_disk.DiskId = param[1]-'0';
ioctl.handle = driver_handle;
ioctl.io_code = DEV_ADD_DISK;
ioctl.input = #add_disk;
ioctl.inp_size = sizeof(add_disk);
ioctl.output = 0;
ioctl.out_size = 0;
break;
default:
debug("unknown command line parameters");
debug("use 'h' or '?' for help");
ExitProcess();
}
driver_rezult = RuleDriver(#ioctl);
if (driver_rezult<7) debug(rezult_text[driver_rezult]);
}

View File

@ -0,0 +1,244 @@
#include "..\lib\mem.h"
#include "..\lib\dll.h"
#include "..\lib\edit_box_lib.h"
#ifdef LANG_RUS
char *but_text[]={
"Äîáàâèòü äèñê"w,
"Óäàëèòü äèñê"w,
"Ïîìîùü"w,
0};
#else
char *but_text[]={
"Add disk",
"Delete disk",
"Help",
0};
#endif
dword icons[14*56] = FROM "icons.raw";
struct path_string {
unsigned char Item[256];
};
path_string disk_list[40];
dword devbuf;
int disk_num;
int selected;
system_colors sc;
proc_info Form;
int mouse_dd;
unsigned char dsize[30];
edit_box edit1= {200,20,16,0xffffff,0x94AECE,0x94AECE,0x94AECE,0,248,#dsize,#mouse_dd,100000000000010b};
void Main_Window()
{
unsigned int id;
unsigned char key;
unsigned int i, j, bbreak;
mem_Init();
if (load_dll2(boxlib, #edit_box_draw,0)!=0)
{
notify("error: library doesn't exists /rd/1/lib/box_lib.obj");
ExitProcess();
}
SetEventMask(0x27);
loop()
{
switch(WaitEvent())
{
case evMouse:
//edit_box_mouse stdcall (#edit1);
break;
case evButton:
id=GetButtonID();
if (id==1) ExitProcess();
if (id==10) //add
{
_ADD_DISK:
if (disk_num>=10)
{
notify("Äîñòèãíóò ïðåäåë êîëè÷åñòâà âèðòóàëüíûõ äèñêîâ"w);
break;
}
param[0]='a';
//
for (i=0; i<9; i++)
{
bbreak = true;
for (j=0; j<=disk_num; j++)
{
if (i+48==disk_list[j].Item[3]) bbreak=false;
}
if (bbreak) break;
}
param[1]=i+48;
Console_Work();
Pause(5);
GetDisks();
DrawTmpDisks();
}
if (id==11) //del
{
_DEL_DISK:
if (disk_num==0)
{
notify("Äëÿ íà÷àëà äîáàâüòå õîòÿ áû îäèí äèñê"w);
break;
}
param[0]='d';
param[1]=disk_list[selected].Item[3];
Console_Work();
Pause(15);
GetDisks();
DrawTmpDisks();
}
if (id==12) //help
{
notify("Ðàçäåë â ðàçðàáîòêå"w);
}
if (id>=20)
{
if (selected==id-20) OpenTmpDisk();
selected=id-20;
DrawTmpDisks();
}
break;
case evKey:
key = GetKey();
if (key==182) if (disk_num<>0) goto _DEL_DISK;
if (key==14) goto _ADD_DISK;
if (key==178)
{
if (selected==0) break;
selected--;
DrawTmpDisks();
}
if (key==177)
{
if (selected+2>disk_num) break;
selected++;
DrawTmpDisks();
}
if (key==176)
{
if (selected<3) break;
selected-=3;
DrawTmpDisks();
}
if (key==179)
{
if (selected+4>disk_num) break;
selected+=3;
DrawTmpDisks();
}
if (key==013)
{
OpenTmpDisk();
}
break;
case evReDraw:
Draw_Window();
}
}
}
void OpenTmpDisk()
{
unsigned char eol_param[256];
if (!disk_num) return;
strcpy(#eol_param, "/tmp#/1/");
eol_param[4]=disk_list[selected].Item[3];
RunProgram("/sys/File managers/Eolite", #eol_param);
}
void GetDisks()
{
unsigned int j, fcount=30;
unsigned char disk_name[256];
mem_Free(devbuf);
devbuf= mem_Alloc(32);
ReadDir(0, devbuf, "/");
fcount=ESDWORD[devbuf+8];
mem_Free(devbuf);
devbuf = mem_Alloc(fcount+1*304+32);
ReadDir(fcount, devbuf, "/");
disk_num=0;
for (j=0; j<fcount; j++;)
{
strcpy(#disk_name, j*304+devbuf+72);
if (disk_name[0]!='t') continue;
strcpy(#disk_list[disk_num].Item, #disk_name);
disk_num++;
}
if (disk_num>12) disk_num=12;
}
unsigned int disk_pos_x[]={13,13,13,83,83,83,153,153,153,223,223,223};
unsigned int disk_pos_y[]={40,65,90,40,65,90,40,65,90,40,65,90};
void DrawTmpDisks()
{
int i;
DrawBar(0,31, Form.width-9,Form.height-GetSkinHeight()-5-30, 0xFFFFFF);
if (disk_num==0)
{
WriteText(17,45, 0x90, 0x777777, "Çäåñü áóäåò îòîáðàæàòüñÿ ñïèñîê"w, 0);
WriteText(17,45+15, 0x90, 0x777777, "âèðòóàëüíûõ äèñêîâ â ñèñòåìå."w, 0);
WriteText(17,45+42, 0x90, 0x777777, "Ïîïðîáóéòå äîáàâèòü îäèí..."w, 0);
return;
};
if (selected>=disk_num) selected=disk_num-1; //âîññòàíàâëèâàåò âûäåëåíèå - õîðîøàÿ ôè÷à
for (i=0; i<disk_num; i++)
{
DefineButton(disk_pos_x[i], disk_pos_y[i], 60, 20, 20+i, 0xFFFfff);
WriteText(disk_pos_x[i]+25,disk_pos_y[i]+6, 0x90, 0, #disk_list[i].Item, 0);
_PutImage(disk_pos_x[i]+5,disk_pos_y[i]+4, 14,14, 3*14*14*3+#icons);
if (selected==i) DrawRegion(disk_pos_x[i], disk_pos_y[i], 60-1, 20-1, 0x00459A);
}
}
void Draw_Window()
{
int i, x;
sc.get();
DefineAndDrawWindow(170,150,314,250,0x74,sc.work,"Virtual Disk Manager 0.35");
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) return; //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
//ðèñóåì ïàíåëü
DrawBar(0,0, Form.width-9,30, sc.work);
DrawBar(0,30, Form.width-9,1, sc.work_graph);
x=6;
for (i=0; i<3; i++)
{
DefineButton(x,5, strlen(but_text[i])*6+28,19, 10+i, sc.work_button);
_PutImage(x+3,8, 14,14, i*14*14*3+#icons);
WriteText(x+22,11, 0x80, sc.work_button_text, but_text[i], 0);
x+=strlen(but_text[i])*6+37;
}
//ïîëó÷àåì ñïèñîê äîñòóïíûõ äèñêîâ
GetDisks();
//âûâîäèì äîñòóïíûå äèñêè
DrawTmpDisks();
//äîïîëíèòåëüíàÿ ïàíåëü
}

View File

@ -0,0 +1,71 @@
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\file_system.h"
#include "lang.h"
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// îáëàñòü äàííûõ ////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
struct ioctl_struct
{
dword handle;
dword io_code;
dword input;
dword inp_size;
dword output;
dword out_size;
};
#define DEV_ADD_DISK 1 //input = structure add_disk_struc
#define DEV_DEL_DISK 2 //input = structure del_disk_struc
struct add_disk_struc
{
dword DiskSize; // in sectors, 1 sector = 512 bytes. Include FAT service data
unsigned char DiskId; // from 0 to 9
};
struct del_disk_struc
{
unsigned char DiskId; //from 0 to 9
};
ioctl_struct ioctl;
add_disk_struc add_disk;
del_disk_struc del_disk;
int driver_handle;
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////// êîä ////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
#include "t_console.c"
#include "t_window.c"
void main()
{
debug("========= tmpdisk 0.35 =========");
driver_handle = LoadDriver("tmpdisk");
if (driver_handle==0)
{
notify("error: /rd1/1/lib/tmpdisk.obj driver loading failed");
notify("program terminated");
ExitProcess();
}
else
debug("tmpdisk.obj driver loaded successfully");
if (param)
Console_Work();
else
Main_Window();
ExitProcess();
}
stop: