Compare commits
4
Commits
unimg-cmm
...
tmpdisk-0.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba200a37b2 | ||
|
|
f338d09bb4 | ||
|
|
c64ca00185 | ||
|
|
7c25bca493 |
No files matched your search
@@ -260,7 +260,7 @@ inline fastcall void GetCurDir( ECX, EDX)
|
||||
previous but here virtual folders like
|
||||
'/' and '/tmp' are not recognised as FOLDERS
|
||||
by GetFileInfo() => BDVK.isfolder attribute :( */
|
||||
bool real_dir_exists(dword fpath)
|
||||
:bool real_dir_exists(dword fpath)
|
||||
{
|
||||
BDVK fpath_atr;
|
||||
if (GetFileInfo(fpath, #fpath_atr) != 0) return false;
|
||||
|
||||
@@ -905,8 +905,16 @@ inline signed csshexdec(dword text)
|
||||
:dword miniprintf(dword dst, format, insert_line)
|
||||
{
|
||||
dword in_pos = strchr(format, '%');
|
||||
|
||||
if (!in_pos) {
|
||||
_NO_STR:
|
||||
strcpy(dst, format);
|
||||
return dst;
|
||||
}
|
||||
|
||||
EBX = ESBYTE[EAX+1];
|
||||
if (EBX == 's') {
|
||||
if (!insert_line) goto _NO_STR;
|
||||
strncpy(dst, format, in_pos - format);
|
||||
strcat(dst, insert_line);
|
||||
strcat(dst, in_pos+2);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
if tup.getconfig("NO_CMM") ~= "" then return end
|
||||
if tup.getconfig("LANG") == "ru_RU"
|
||||
then C_LANG = "LANG_RUS"
|
||||
elseif tup.getconfig("LANG") == "es_ES"
|
||||
then C_LANG = "LANG_SPA"
|
||||
else C_LANG = "LANG_ENG" -- this includes default case without config
|
||||
end
|
||||
tup.foreach_rule("*.c", "c-- /D=AUTOBUILD /D=$(C_LANG) /OPATH=%o %f" .. tup.getconfig("KPACK_CMD"), "%B.com")
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
//
|
||||
// unimg - FAT12 (floppy) image unpacker
|
||||
// Copyright (C) 2020-2026 KolibriOS Team
|
||||
//
|
||||
// Contributor Magomed Kostoev (Boppan, mkostoevr) - initial version in C
|
||||
// Contributor Kyryl Lipatov (Leency) - rewrite to C--, support any image type
|
||||
// Contributor Burer - Russian and Spanish translations, small fixes
|
||||
//
|
||||
// Usage:
|
||||
// unimg /path/to/img ["/output/dir"]
|
||||
// If output folder is not specified, image will be unpacked at /tmp0/1/[img_name.img_ext]
|
||||
|
||||
|
||||
#define MEMSIZE 1024*30
|
||||
#define ENTRY_POINT #main
|
||||
|
||||
#include "../lib/fs.h"
|
||||
|
||||
// NB: this file is stored in CP866 (for the Russian strings below).
|
||||
// Edit it with a CP866-aware editor, not UTF-8.
|
||||
#ifdef LANG_RUS
|
||||
?define MSG_USAGE "'unimg\nРаспаковщик образов FAT12.\nИспользование: unimg /путь/к/образу [\"/папка/вывода\"]' -tI"
|
||||
?define MSG_READ "'unimg\nОшибка чтения файла\n%s' -tE"
|
||||
?define MSG_FORMAT "'unimg\nОбраз не FAT12.\n%s' -tE"
|
||||
?define MSG_MKDIR "'unimg\nОшибка создания папки\n%s' -tE"
|
||||
?define MSG_DONE "'unimg\nРаспаковано в:\n%s' -tO"
|
||||
?define MSG_NOMEM "'unimg\nНедостаточно памяти' -tE"
|
||||
?define MSG_OOB "'unimg\nКластера FAT вне границ' -tE"
|
||||
?define INFO_NAME "\nВнутреннее имя "
|
||||
?define INFO_BPS "\nБайт в секторе "
|
||||
?define INFO_SPC "\nСекторов в кластере "
|
||||
?define INFO_RSC "\nРезервных секторов "
|
||||
?define INFO_NFAT "\nКоличество FAT "
|
||||
?define INFO_MRE "\nЗаписей в корне "
|
||||
?define INFO_BPC "\nБайт в кластере "
|
||||
?define INFO_SPF "\nСекторов в FAT "
|
||||
?define INFO_FATOFF "\nПервая FAT "
|
||||
?define INFO_ROOTOFF "\nКорневой каталог "
|
||||
?define INFO_DATAOFF "\nОбласть данных "
|
||||
#else
|
||||
#ifdef LANG_SPA
|
||||
?define MSG_USAGE "'unimg\nDescompresor de imagenes FAT12.\nUso: unimg /ruta/a/imagen [\"/carpeta/salida\"]' -tI"
|
||||
?define MSG_READ "'unimg\nError al leer el archivo\n%s' -tE"
|
||||
?define MSG_FORMAT "'unimg\nNo es una imagen FAT12.\n%s' -tE"
|
||||
?define MSG_MKDIR "'unimg\nNo se pudo crear la carpeta\n%s' -tE"
|
||||
?define MSG_DONE "'unimg\nDescomprimido en\n%s' -tO"
|
||||
?define MSG_NOMEM "'unimg\nSin memoria' -tE"
|
||||
?define MSG_OOB "'unimg\nCluster FAT fuera de limites' -tE"
|
||||
?define INFO_NAME "\nNombre interno "
|
||||
?define INFO_BPS "\nBytes en sector "
|
||||
?define INFO_SPC "\nSectores en cluster "
|
||||
?define INFO_RSC "\nSectores reservados "
|
||||
?define INFO_NFAT "\nNumero de FATs "
|
||||
?define INFO_MRE "\nEntradas raiz max "
|
||||
?define INFO_BPC "\nBytes en cluster "
|
||||
?define INFO_SPF "\nSectores en FAT "
|
||||
?define INFO_FATOFF "\nPrimera FAT "
|
||||
?define INFO_ROOTOFF "\nDirectorio raiz "
|
||||
?define INFO_DATAOFF "\nRegion de datos "
|
||||
#else
|
||||
?define MSG_USAGE "'unimg\nFAT12 image unpacker.\nUsage: unimg /path/to/img [\"/output/dir\"]' -tI"
|
||||
?define MSG_READ "'unimg\nFile read error\n%s' -tE"
|
||||
?define MSG_FORMAT "'unimg\nNot a FAT12 image.\n%s' -tE"
|
||||
?define MSG_MKDIR "'unimg\nCannot create output folder\n%s' -tE"
|
||||
?define MSG_DONE "'unimg\nUnpacked to\n%s' -tO"
|
||||
?define MSG_NOMEM "'unimg\nOut of memory' -tE"
|
||||
?define MSG_OOB "'unimg\nFAT cluster out of bounds' -tE"
|
||||
?define INFO_NAME "\nInternal name "
|
||||
?define INFO_BPS "\nBytes per sector "
|
||||
?define INFO_SPC "\nSectors per cluster "
|
||||
?define INFO_RSC "\nReserved sectors "
|
||||
?define INFO_NFAT "\nNumber of FATs "
|
||||
?define INFO_MRE "\nMax root entries "
|
||||
?define INFO_BPC "\nBytes per cluster "
|
||||
?define INFO_SPF "\nSectors per FAT "
|
||||
?define INFO_FATOFF "\nFirst FAT "
|
||||
?define INFO_ROOTOFF "\nRoot directory "
|
||||
?define INFO_DATAOFF "\nData region "
|
||||
#endif
|
||||
#endif
|
||||
|
||||
dword img_ptr;
|
||||
dword img_sz;
|
||||
|
||||
int bps;
|
||||
int spc;
|
||||
int rsc;
|
||||
int nfat;
|
||||
int mre;
|
||||
int spf;
|
||||
int bpc;
|
||||
int fat_off;
|
||||
int root_off;
|
||||
int data_off;
|
||||
|
||||
char cur_path[4096];
|
||||
int cur_path_len;
|
||||
|
||||
inline int fat_u8(int offset) { return DSBYTE[img_ptr + offset] & 0xFF; }
|
||||
inline int fat_u16(int offset) { return DSWORD[img_ptr + offset] & 0xFFFF; }
|
||||
inline dword fat_u32(int offset) { return ESDWORD[img_ptr + offset]; }
|
||||
|
||||
void fat12__open()
|
||||
{
|
||||
bps = fat_u16(11);
|
||||
spc = fat_u8(13);
|
||||
rsc = fat_u16(14);
|
||||
nfat = fat_u8(16);
|
||||
mre = fat_u16(17);
|
||||
spf = fat_u16(22);
|
||||
bpc = bps * spc;
|
||||
fat_off = rsc * bps;
|
||||
root_off = nfat * spf * bps + fat_off;
|
||||
data_off = mre * 32 + root_off;
|
||||
}
|
||||
|
||||
dword GetImageInfo(dword buf)
|
||||
{
|
||||
strcpy(buf, INFO_NAME); strncpy(buf+21, img_ptr+3, 8);
|
||||
strcat(buf, INFO_BPS); strcat(buf, itoa(bps));
|
||||
strcat(buf, INFO_SPC); strcat(buf, itoa(spc));
|
||||
strcat(buf, INFO_RSC); strcat(buf, itoa(rsc));
|
||||
strcat(buf, INFO_NFAT); strcat(buf, itoa(nfat));
|
||||
strcat(buf, INFO_MRE); strcat(buf, itoa(mre));
|
||||
strcat(buf, INFO_BPC); strcat(buf, itoa(bpc));
|
||||
strcat(buf, INFO_SPF); strcat(buf, itoa(spf));
|
||||
strcat(buf, INFO_FATOFF); strcat(buf, itoa(fat_off));
|
||||
strcat(buf, INFO_ROOTOFF); strcat(buf, itoa(root_off));
|
||||
strcat(buf, INFO_DATAOFF); strcat(buf, itoa(data_off));
|
||||
}
|
||||
|
||||
int cluster_to_offset(int c)
|
||||
{
|
||||
return c - 2 * bpc + data_off;
|
||||
}
|
||||
|
||||
int next_cluster(int c)
|
||||
{
|
||||
int v;
|
||||
v = fat_u16(c / 2 + fat_off + c);
|
||||
if (c & 1) return v >> 4;
|
||||
return v & 0xFFF;
|
||||
}
|
||||
|
||||
void extract_file(dword buf, int size, int cluster)
|
||||
{
|
||||
int written, n, src;
|
||||
written = 0;
|
||||
while (cluster >= 2) && (cluster < 0xFF7) {
|
||||
src = cluster_to_offset(cluster);
|
||||
n = bpc;
|
||||
// clamp to remaining size
|
||||
if (written + n > size) n = size - written;
|
||||
if (n <= 0) break;
|
||||
// Stop on a corrupt FAT chain pointing outside the image
|
||||
if (src < 0) || (src + n > img_sz) break;
|
||||
memmov(buf + written, img_ptr + src, n);
|
||||
written += n;
|
||||
cluster = next_cluster(cluster);
|
||||
}
|
||||
}
|
||||
|
||||
void make_parent_dirs(dword initial_dir)
|
||||
{
|
||||
char path[4096];
|
||||
int i;
|
||||
strncpy(#path, initial_dir, strlen(initial_dir) + 1);
|
||||
//debugln(#path);
|
||||
for (i = 1; path[i]; i++) {
|
||||
if (path[i] == '/') {
|
||||
path[i] = '\0';
|
||||
CreateDir(#path);
|
||||
path[i] = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int entry_short_name(int off, dword out)
|
||||
{
|
||||
int attr, i, n, b;
|
||||
b = fat_u8(off);
|
||||
if (!b) return -1;
|
||||
if (b == 0xE5) return 0;
|
||||
attr = fat_u8(off + 11);
|
||||
if (attr & 0x0F == 0x0F) return 0;
|
||||
if (attr & 0x08) return 0;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
b = fat_u8(off + i);
|
||||
if (b == ' ') break;
|
||||
ESBYTE[out + n] = b;
|
||||
n++;
|
||||
}
|
||||
b = fat_u8(off + 8);
|
||||
if (b != ' ') {
|
||||
ESBYTE[out + n] = '.';
|
||||
n++;
|
||||
for (i = 8; i < 11; i++) {
|
||||
b = fat_u8(off + i);
|
||||
if (b == ' ') break;
|
||||
ESBYTE[out + n] = b;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
ESBYTE[out + n] = '\0';
|
||||
return n;
|
||||
}
|
||||
|
||||
int handle_entry(int off)
|
||||
{
|
||||
char name[13];
|
||||
int nlen, attr, cluster, size, saved_len;
|
||||
dword buf;
|
||||
|
||||
if (off < 0) || (off + 32 > img_sz) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
nlen = entry_short_name(off, #name);
|
||||
|
||||
if (nlen < 0) return -1;
|
||||
if (nlen == 0) return 0;
|
||||
if (name[0] == '.') return 0;
|
||||
|
||||
attr = fat_u8(off + 11);
|
||||
cluster = fat_u16(off + 26);
|
||||
|
||||
saved_len = cur_path_len;
|
||||
cur_path[cur_path_len] = '/';
|
||||
memmov(#cur_path + cur_path_len + 1, #name, nlen + 1);
|
||||
cur_path_len = cur_path_len + 1 + nlen;
|
||||
|
||||
if (attr & 0x10) {
|
||||
CreateDir(#cur_path);
|
||||
handle_folder(cluster);
|
||||
} else {
|
||||
size = fat_u32(off + 28);
|
||||
if (size > 0) {
|
||||
buf = malloc(size);
|
||||
if (!buf) {
|
||||
notify(MSG_NOMEM);
|
||||
} else {
|
||||
extract_file(buf, size, cluster);
|
||||
CreateFile(size, buf, #cur_path);
|
||||
free(buf);
|
||||
}
|
||||
} else {
|
||||
CreateFile(0, img_ptr, #cur_path);
|
||||
}
|
||||
}
|
||||
|
||||
cur_path_len = saved_len;
|
||||
cur_path[cur_path_len] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
void handle_folder(int cluster)
|
||||
{
|
||||
int off, entries, i;
|
||||
while (cluster >= 2) && (cluster < 0xFF7) {
|
||||
off = cluster_to_offset(cluster);
|
||||
|
||||
// Check that offset don't go negative
|
||||
// and we don't read over img size (img_sz)
|
||||
if (off < 0) || (off + bpc > img_sz) {
|
||||
notify(MSG_OOB);
|
||||
return;
|
||||
}
|
||||
|
||||
entries = bpc / 32;
|
||||
for (i = 0; i < entries; i++) {
|
||||
if (handle_entry(i * 32 + off) < 0) return;
|
||||
}
|
||||
cluster = next_cluster(cluster);
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyAndExit(dword message, opt)
|
||||
{
|
||||
miniprintf(#param, message, opt);
|
||||
notify(#param);
|
||||
ExitProcess();
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
char img_file[4096];
|
||||
char img_info[512];
|
||||
int i;
|
||||
|
||||
mem_init();
|
||||
|
||||
if (!param[0]) {
|
||||
NotifyAndExit(MSG_USAGE, NULL);
|
||||
}
|
||||
|
||||
if (i = strchr(#param, '"')) {
|
||||
ESBYTE[i-1] = '\0';
|
||||
strcpy(#cur_path, i+1);
|
||||
i = strchr(#cur_path, '"');
|
||||
if (i) ESBYTE[i] = '\0';
|
||||
}
|
||||
|
||||
strcpy(#img_file, #param);
|
||||
|
||||
if (!cur_path[0]) {
|
||||
memmov(#cur_path, "/tmp0/1", 8);
|
||||
strcat(#cur_path, #img_file + strrchr(#img_file, '/') - 1);
|
||||
}
|
||||
cur_path_len = strlen(#cur_path);
|
||||
|
||||
read_file(#img_file, #img_ptr, #img_sz);
|
||||
if (!img_ptr) || (!img_sz) {
|
||||
NotifyAndExit(MSG_READ, #img_file);
|
||||
}
|
||||
|
||||
fat12__open();
|
||||
if (root_off > img_sz) || (data_off > img_sz) {
|
||||
GetImageInfo(#img_info);
|
||||
NotifyAndExit(MSG_FORMAT, #img_info);
|
||||
}
|
||||
|
||||
make_parent_dirs(#cur_path);
|
||||
if (CreateDir(#cur_path)) {
|
||||
NotifyAndExit(MSG_MKDIR, #cur_path);
|
||||
}
|
||||
|
||||
for (i = 0; i < mre; i++) {
|
||||
if (handle_entry(i * 32 + root_off) < 0) break;
|
||||
}
|
||||
|
||||
NotifyAndExit(MSG_DONE, #cur_path);
|
||||
}
|
||||
@@ -2,4 +2,4 @@
|
||||
@del tmpdisk
|
||||
@rename tmpdisk.com tmpdisk
|
||||
@del warning.txt
|
||||
@pause
|
||||
if not exist tmpdisk ( @pause )
|
||||
@@ -2,4 +2,4 @@
|
||||
@del tmpdisk
|
||||
@rename tmpdisk.com tmpdisk
|
||||
@del warning.txt
|
||||
@pause
|
||||
if not exist tmpdisk ( @pause )
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 236 B |
@@ -1 +0,0 @@
|
||||
ЬЬЬЬЬЬЬЬЬЬЬЬЬЬД╝<┘I╝<┘I╝<┘I╝<┘I╝<┘I┘I┘IЬД┤<╝<┘I╝<ЬЬЬЬ┘I╝<┘I┘IЬД╝<┤<╝<╝<Ь№№№№№№Ь╝<┘I╝<┘IЬД┤<╝<┘I┤<Ь№№№№№№Ь╝<╝<┘I╝<ЬД┤<ЬЬЬЬ№№№№№№ЬЬЬЬ┘IЬД┤<Ь№№№№№№№№№№№№№№№№№№№№№№№№Ь╝<ЬД╝<Ь№№№№№№№№№№№№№№№№№№№№№№№№Ь┘IЬД┤<ЬЬЬЬ№№№№№№ЬЬЬЬ┘IЬД┤<┤<╝<┤<Ь№№№№№№Ь┘I╝<╝<┘IЬД┤<╝<┤<╝<Ь№№№№№№Ь┘I╝<┘I╝<ЬД╝<┤<╝<┤<ЬЬЬЬ╝<┤<╝<┘IЬДд4┤<д4┤<┤<╝<┤<┤<┤<╝<┤<╝<ЬДДДДДДДДДДДДДД,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,ФD▄SЇD▄SЇSЇSЇSЇSЇSЇSЇSЇSЇ,Ф,Ф<┌D▄SЇD▄D▄SЇD▄SЇD▄SЇSЇSЇ,Ф,ФD▄<┌D▄D▄D▄D▄SЇD▄SЇD▄SЇSЇ,Ф,Ф<┌D▄SЇ<┌D▄D▄D▄SЇD▄SЇD▄SЇ,Ф,Ф<┌4┤4┤4┤4┤4┤4┤4┤4┤4┤4┤SЇ,Ф,Ф<┌4┤№№№№№№№№№№№№№№№№№№№№№№№№4┤D▄,Ф,ФD▄4┤№№№№№№№№№№№№№№№№№№№№№№№№4┤SЇ,Ф,Ф<┌4┤4┤4┤4┤4┤4┤4┤4┤4┤4┤SЇ,Ф,Ф<┌D▄D▄D▄<┌D▄D▄<┌SЇD▄D▄SЇ,Ф,Ф9┴D▄D▄D▄D▄D▄D▄D▄SЇD▄SЇD▄,Ф,ФD▄9┴D▄9┴D▄9┴D▄9┴D▄<┌D▄SЇ,Ф,Ф9┴<┌9┴<┌9┴D▄9┴<┌9┴D▄<┌D▄,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 114 B |
@@ -1 +0,0 @@
|
||||
lddTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTlddTTTффф№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№фффTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤ммTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№
|
||||
+7
-6
@@ -16,7 +16,7 @@
|
||||
0};
|
||||
#else
|
||||
?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"
|
||||
?define NEW_DISK_TEXT "Trying to add RAM disk /tmp%i, the size of %i MB"
|
||||
char *rezult_text[]={
|
||||
"TmpDisk operation completed successfully",
|
||||
"unknown IOCTL code, wrong input/output size...",
|
||||
@@ -31,7 +31,7 @@
|
||||
char Console_Work()
|
||||
{
|
||||
unsigned int disk_size, driver_rezult;
|
||||
char size_t[256];
|
||||
char t_size[256];
|
||||
|
||||
strlwr(#param);
|
||||
|
||||
@@ -45,8 +45,8 @@ char Console_Work()
|
||||
ioctl.inp_size = sizeof(del_disk);
|
||||
ioctl.output = 0;
|
||||
ioctl.out_size = 0;
|
||||
sprintf(#size_t, DELETE_DISK_TEXT, add_disk.DiskId);
|
||||
debugln(#size_t);
|
||||
miniprintf(#t_size, DELETE_DISK_TEXT, add_disk.DiskId);
|
||||
debugln(#t_size);
|
||||
break;
|
||||
case 'a': //Add disk
|
||||
disk_size= strchr(#param, 's');
|
||||
@@ -62,8 +62,9 @@ char Console_Work()
|
||||
ioctl.inp_size = sizeof(add_disk);
|
||||
ioctl.output = 0;
|
||||
ioctl.out_size = 0;
|
||||
sprintf(#size_t, NEW_DISK_TEXT, add_disk.DiskId, add_disk.DiskSize/2048);
|
||||
debugln(#size_t);
|
||||
miniprintf(#t_size, NEW_DISK_TEXT, add_disk.DiskId);
|
||||
miniprintf(#param, #t_size, add_disk.DiskSize/2048);
|
||||
debugln(#param);
|
||||
break;
|
||||
default:
|
||||
debugln("\ntmpdisk: unknown command line parameters!");
|
||||
|
||||
+84
-69
@@ -5,33 +5,47 @@
|
||||
#include "..\lib\gui.h"
|
||||
#include "..\lib\obj\box_lib.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// TRANSLATIONS //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#ifdef LANG_RUS
|
||||
?define T_WIN_TITLE "TmpDisk 0.80: Управление дисками в ОЗУ"
|
||||
?define T_ADD_DISK " Добавить диск [Ins]"
|
||||
?define T_DELETE_DISK " Удалить диск [Del]"
|
||||
?define INTRO_TEXT_1 "Здесь будет отображаться список"
|
||||
?define INTRO_TEXT_2 "виртуальных дисков в системе."
|
||||
?define INTRO_TEXT_3 "Попробуйте добавить один..."
|
||||
?define SIZE_TEXT "Размер нового диска в МБ:"
|
||||
?define INTRO_TEXT_1 "Ни одного диска пока не добавлено."
|
||||
?define INTRO_TEXT_2 "Пожалуйста, добавьте tmp0, он необходим."
|
||||
?define NEW_DISK_SIZE "Размер нового диска"
|
||||
?define NEW_DISK_SIZE_W 19*8
|
||||
?define NOTIFY_TEXT_NO_DISK "'Для начала добавьте хотя бы один диск' -W"
|
||||
?define NOTIFY_SYSTEM_DISK0 "'Диск с номером 0 является системным и удалять его не рекомендуется.
|
||||
В случае, если вы точно знаете, что делаете, удалить его можно с зажатой клавишей SHIFT.' -W"
|
||||
?define NOTIFY_TEXT_DISK_LIMIT "'Достигнут предел количества виртуальных дисков' -W"
|
||||
?define FREE_RAM_TEXT "Размер свободной оперативной памяти: %i MБ"
|
||||
?define FREE_RAM_TEXT "MB (Доступно %i MБ)"
|
||||
|
||||
#else
|
||||
?define T_WIN_TITLE "TmpDisk 0.80: RAM Disk Manager"
|
||||
?define T_ADD_DISK " Add disk [Ins]"
|
||||
?define T_DELETE_DISK " Delete disk [Del]"
|
||||
?define INTRO_TEXT_1 " There will be list of mounted"
|
||||
?define INTRO_TEXT_2 " virtual disks."
|
||||
?define INTRO_TEXT_3 " Try to add one..."
|
||||
?define SIZE_TEXT "New Disk size in MB:"
|
||||
?define INTRO_TEXT_1 "No disks added yet."
|
||||
?define INTRO_TEXT_2 "Please add tmp0 as it is crucial."
|
||||
?define NEW_DISK_SIZE "New Disk size"
|
||||
?define NEW_DISK_SIZE_W 13*8
|
||||
?define NOTIFY_TEXT_NO_DISK "'You need to have at least one disk' -W"
|
||||
?define NOTIFY_SYSTEM_DISK0 "'Disc number 0 is a system disk. It is not recommended to delete it.
|
||||
In case when you know what you are doing you can delete it with the SHIFT key pressed.' -W"
|
||||
?define NOTIFY_TEXT_DISK_LIMIT "'Reached the limit of the number of virtual disks' -W"
|
||||
?define FREE_RAM_TEXT "Free RAM size: %i MB"
|
||||
?define FREE_RAM_TEXT "MB (Free RAM: %i MB)"
|
||||
#endif
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// DATA //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
struct path_string { unsigned char Item[10]; };
|
||||
path_string disk_list[10];
|
||||
|
||||
@@ -39,26 +53,31 @@ dword devbuf;
|
||||
char disk_num;
|
||||
char selected;
|
||||
|
||||
proc_info Form;
|
||||
#define WIN_W 400
|
||||
#define WIN_H 240
|
||||
|
||||
unsigned char icons_btn[] = FROM "img/btn.raw";
|
||||
unsigned char disk_icon[] = FROM "img/disk.raw";
|
||||
#define TOPPANELH 68
|
||||
#define BOTPANELH 26
|
||||
?define FREE_RAM_TEXT_X NEW_DISK_SIZE_W + 61
|
||||
|
||||
char new_disk_size[7];
|
||||
edit_box edit_disk_size= {50,0,7,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,
|
||||
sizeof(new_disk_size)-2,#new_disk_size,0, ed_focus+ed_figure_only};
|
||||
char new_disk_size[5];
|
||||
edit_box edit_disk_size= {40,NEW_DISK_SIZE_W+13,6,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,
|
||||
sizeof(new_disk_size)-1,#new_disk_size,0, ed_focus+ed_figure_only};
|
||||
|
||||
char tmp_path[8] = "/tmp#/1";
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// CODE //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
void Main_Window()
|
||||
{
|
||||
word id;
|
||||
int x;
|
||||
proc_info Form;
|
||||
|
||||
#define NO_DLL_INIT
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
GetNewSizeDisk();
|
||||
edit_disk_size.left = strlen(SIZE_TEXT)*8 + 13;
|
||||
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
||||
loop()
|
||||
{
|
||||
@@ -143,44 +162,49 @@ void Main_Window()
|
||||
break;
|
||||
case evReDraw:
|
||||
sc.get();
|
||||
DefineAndDrawWindow(170,150,405,290,0x74,sc.work,"Virtual Disk Manager 0.69",0);
|
||||
DefineAndDrawWindow(screen.w-WIN_W/2,screen.h-WIN_H/2,
|
||||
WIN_W+9, WIN_H+skin_h+4,0x74,sc.work,T_WIN_TITLE,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window&ROLLED_UP) break;
|
||||
|
||||
DrawBar(0,0, Form.cwidth,TOPPANELH, sc.work);
|
||||
DrawBar(0,TOPPANELH, Form.cwidth,1, sc.line);
|
||||
WriteText(6, 9, 0x90, sc.work_text, SIZE_TEXT);
|
||||
DrawRectangle(edit_disk_size.left-1, edit_disk_size.top-1, edit_disk_size.width+2, 23,sc.line);
|
||||
edit_box_draw stdcall (#edit_disk_size);
|
||||
x = 6 + DrawStandartCaptButton(6, 36, 10, T_ADD_DISK);
|
||||
DrawStandartCaptButton(x, 36, 11, T_DELETE_DISK);
|
||||
PutImage(6+6, 42, 14,14, #icons_btn);
|
||||
PutImage(x+6, 42, 14,14, 14*14*3+#icons_btn);
|
||||
GetDisks();
|
||||
DrawTmpDisks();
|
||||
DrawWindowContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWindowContent()
|
||||
{
|
||||
int x;
|
||||
char free_ram_text[60];
|
||||
DrawBar(0,0, WIN_W,TOPPANELH, sc.work);
|
||||
DrawBar(0,TOPPANELH, WIN_W,1, sc.line);
|
||||
WriteText(6, 9, 0x90, sc.work_text, NEW_DISK_SIZE);
|
||||
DrawRectangle(edit_disk_size.left-1, edit_disk_size.top-1, edit_disk_size.width+2, 23,sc.line);
|
||||
edit_box_draw stdcall (#edit_disk_size);
|
||||
#define BTN_W WIN_W - 12 / 2 - 3
|
||||
DrawCaptButton(6, 36, BTN_W, 24, 10, 0x45975E, 0xFFFfff, T_ADD_DISK);
|
||||
DrawCaptButton(6+BTN_W+6, 36, BTN_W, 24, 11, 0xC75C54, 0xFFFfff, T_DELETE_DISK);
|
||||
miniprintf(#free_ram_text, FREE_RAM_TEXT, GetFreeRAM()/1024);
|
||||
WriteText(FREE_RAM_TEXT_X, 9, 0x90, sc.work_text, #free_ram_text);
|
||||
GetDisks();
|
||||
DrawTmpDisks();
|
||||
}
|
||||
|
||||
|
||||
void GetNewSizeDisk()
|
||||
{
|
||||
int fr;
|
||||
fr = GetFreeRAM() / 5 * 2;
|
||||
fr = itoa(fr / 2048);
|
||||
strcpy(#new_disk_size, fr);
|
||||
EditBox_UpdateText(#edit_disk_size, edit_disk_size.flags);
|
||||
edit_box_draw stdcall (#edit_disk_size);
|
||||
edit_box_set_text stdcall (#edit_disk_size, fr);
|
||||
}
|
||||
|
||||
|
||||
void OpenTmpDisk()
|
||||
{
|
||||
unsigned char eol_param[10];
|
||||
if (!disk_num) return;
|
||||
strcpy(#eol_param, "/tmp#/1");
|
||||
eol_param[4] = disk_list[selected].Item[3];
|
||||
RunProgram("/sys/File managers/Eolite", #eol_param);
|
||||
if (disk_num) {
|
||||
tmp_path[4] = disk_list[selected].Item[3];
|
||||
RunProgram("/sys/File managers/Eolite", #tmp_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,16 +233,6 @@ void GetDisks()
|
||||
}
|
||||
|
||||
|
||||
dword GetDiskSize(dword disk_n)
|
||||
{
|
||||
BDVK bdvk;
|
||||
char tmp_path[8];
|
||||
strcpy(#tmp_path, "/tmp#/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};
|
||||
|
||||
@@ -227,19 +241,13 @@ void DrawTmpDisks()
|
||||
#define SELECTION_ACTIVE 0x0080FF;
|
||||
#define SELECTION_INACTIVE 0x757489;
|
||||
dword selection_color;
|
||||
char free_ram_text[60];
|
||||
byte i;
|
||||
|
||||
DrawBar(0,TOPPANELH+1, Form.cwidth,Form.cheight-TOPPANELH-BOTPANELH-2, 0xFFFFFF);
|
||||
DrawBar(0,Form.cheight-BOTPANELH-1, Form.cwidth,1, sc.line);
|
||||
DrawBar(0,Form.cheight-BOTPANELH, Form.cwidth,BOTPANELH, sc.work);
|
||||
sprintf(#free_ram_text, FREE_RAM_TEXT, GetFreeRAM()/1024);
|
||||
WriteText(10, Form.cheight-20, 0x90, sc.work_text, #free_ram_text);
|
||||
DrawBar(0,TOPPANELH+1, WIN_W,WIN_H-TOPPANELH-1, sc.light);
|
||||
if (disk_num==0)
|
||||
{
|
||||
WriteText(17,TOPPANELH+15, 0x90, 0x777777, INTRO_TEXT_1);
|
||||
WriteText(17,TOPPANELH+15+15, 0x90, 0x777777, INTRO_TEXT_2);
|
||||
WriteText(17,TOPPANELH+15+42, 0x90, 0x777777, INTRO_TEXT_3);
|
||||
WriteText(20, TOPPANELH+22, 0x90, sc.work_text, INTRO_TEXT_1);
|
||||
WriteText(20, TOPPANELH+40, 0x90, 0xFF000d, INTRO_TEXT_2);
|
||||
return;
|
||||
};
|
||||
if (selected>=disk_num) selected=disk_num-1; //restore selected
|
||||
@@ -248,21 +256,29 @@ void DrawTmpDisks()
|
||||
DeleteButton(20+i);
|
||||
if (i>=disk_num) continue;
|
||||
DefineButton(disk_pos_x[i], disk_pos_y[i], 80, 40, 20+i, 0xFFFfff);
|
||||
WriteText(disk_pos_x[i]+29,disk_pos_y[i]+6, 0x90, 0x222222, #disk_list[i].Item);
|
||||
WriteText(disk_pos_x[i]+30,disk_pos_y[i]+24, 0x80, 0x555555,
|
||||
ConvertSize(GetDiskSize(disk_list[i].Item[3] - '0')));
|
||||
PutImage(disk_pos_x[i]+9,disk_pos_y[i]+10, 15,9, #disk_icon);
|
||||
WriteText(disk_pos_x[i]+34,disk_pos_y[i]+6, 0x90, 0x222222, #disk_list[i].Item);
|
||||
WriteText(disk_pos_x[i]+36,disk_pos_y[i]+24, 0x80, 0x555555,
|
||||
GetDiskSizeInMb(disk_list[i].Item[3]));
|
||||
draw_icon_16(disk_pos_x[i]+10,disk_pos_y[i]+10, 51);
|
||||
if (selected==i) {
|
||||
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);
|
||||
PutPixel(disk_pos_x[i], disk_pos_y[i], sc.light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:dword GetDiskSizeInMb(dword disk_n)
|
||||
{
|
||||
BDVK bdvk;
|
||||
tmp_path[4] = disk_n;
|
||||
GetFileInfo(#tmp_path, #bdvk);
|
||||
miniprintf(#param, "%i MB", bdvk.sizelo / 1048576);
|
||||
return #param;
|
||||
}
|
||||
|
||||
void AddDisk()
|
||||
{
|
||||
@@ -290,9 +306,8 @@ void AddDisk()
|
||||
err = Console_Work();
|
||||
if ((err!=0) && (err<7)) notify(rezult_text[err]);
|
||||
pause(5);
|
||||
GetDisks();
|
||||
DrawTmpDisks();
|
||||
GetNewSizeDisk();
|
||||
DrawWindowContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -314,8 +329,8 @@ void DelDisk()
|
||||
err = byte Console_Work();
|
||||
if ((err!=0) && (err<7)) notify(rezult_text[err]);
|
||||
pause(15);
|
||||
GetDisks();
|
||||
DrawTmpDisks();
|
||||
GetNewSizeDisk();
|
||||
DrawWindowContent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#define MEMSIZE 0xA0000
|
||||
#define MEMSIZE 1024*30
|
||||
#include "..\lib\kolibri.h"
|
||||
#include "..\lib\mem.h"
|
||||
#include "..\lib\strings.h"
|
||||
|
||||
Reference in new issue
Block a user