From e52ed5b883da192dcc0254914a77666660e4e0f4 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 13 Dec 2020 12:31:53 +0000 Subject: [PATCH] c-- apps: never use libio Eolite: fixed bug that file or folder was not selected in case when it had to git-svn-id: svn://kolibrios.org@8392 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/WebView.c | 20 +++----------------- programs/cmm/eolite/Eolite.c | 14 ++++++-------- programs/cmm/lib/fs.h | 7 +++++++ programs/cmm/misc/calypte.c | 18 +++++------------- programs/cmm/misc/osupdate.c | 6 +----- programs/cmm/sysmon/sysmon.c | 12 ++++-------- 6 files changed, 26 insertions(+), 51 deletions(-) diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 04ee038a6b..369b0b2d76 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -21,7 +21,6 @@ #include "..\lib\clipboard.h" #include "..\lib\obj\box_lib.h" -#include "..\lib\obj\libio.h" #include "..\lib\obj\libimg.h" #include "..\lib\obj\http.h" #include "..\lib\obj\iconv.h" @@ -97,7 +96,6 @@ edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, void LoadLibraries() { load_dll(boxlib, #box_lib_init,0); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(libHTTP, #http_lib_init,1); load_dll(iconv_lib, #iconv_open,0); @@ -488,12 +486,7 @@ bool HandleUrlFiles(dword _path, _data) bool GetLocalFileData(dword _path) { dword data, size; - file_size stdcall (_path); - if (!EBX) return false; - - size = EBX; - data = malloc(size); - ReadFile(0, size, data, _path); + read_file(_path, #data, #size); if (!HandleUrlFiles(_path, data)) { LoadInternalPage(data, size); } @@ -812,13 +805,6 @@ void EventRefreshPage() } } -dword GetFileSize(dword _path) -{ - BDVK bdvk; - if (GetFileInfo(_path, #bdvk)!=0) return 0; - else return bdvk.sizelo; -} - void EventUpdateBrowser() { dword downloader_id, slot_n; @@ -833,8 +819,8 @@ void EventUpdateBrowser() pause(10); } while (slot_n!=0); - current_size = GetFileSize(#program_path); - new_size = GetFileSize("/tmp0/1/Downloads/WebView.com"); + current_size = get_file_size(#program_path); + new_size = get_file_size("/tmp0/1/Downloads/WebView.com"); if (!new_size) || (new_size<5000) { notify(#update_download_error); diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index e9d7f7ae49..8c3fc94e1f 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -3,8 +3,8 @@ // 70.5 - get volume info and label -#define TITLE "Eolite File Manager 4.47a" -#define ABOUT_TITLE "EOLITE 4.47a" +#define TITLE "Eolite File Manager 4.48" +#define ABOUT_TITLE "EOLITE 4.48" #ifndef AUTOBUILD #include "lang.h--" @@ -23,7 +23,6 @@ #include "../lib/collection.h" #include "../lib/copyf.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libini.h" #include "../lib/obj/box_lib.h" #include "../lib/obj/libimg.h" @@ -156,7 +155,6 @@ void load_libraries() { load_dll(boxlib, #box_lib_init,0); load_dll(libini, #lib_init,1); - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); } @@ -216,12 +214,12 @@ void main() if (dir_exists(#param)) { strcpy(#path, #param); } else { - file_size stdcall (#param); - if (EAX==-1) notify(T_NOTIFY_APP_PARAM_WRONG); - else { + if (file_exists(#param)) { param[strrchr(#param, '/')-1] = '\0'; strcpy(#path, #param); SelectFileByName(#param+strlen(#param)+1); + } else { + notify(T_NOTIFY_APP_PARAM_WRONG); } } } @@ -942,7 +940,7 @@ void SelectFileByName(dword that_file) files.KeyHome(); Open_Dir(#path,ONLY_OPEN); if (dir_at_fat16) && (file_name_is_8_3(that_file)) strttl(that_file); - for (ind=files.count-1; ind>=0; ind--;) { if (streq(items.get(ind)*304+buf+72,that_file)) break; } + for (ind=files.count-1; ind>=0; ind--;) { if (!strcmpi(items.get(ind)*304+buf+72,that_file)) break; } files.cur_y = ind - 1; files.KeyDown(); DrawStatusBar(); diff --git a/programs/cmm/lib/fs.h b/programs/cmm/lib/fs.h index 2c8bcef28f..f5f6d4d38e 100644 --- a/programs/cmm/lib/fs.h +++ b/programs/cmm/lib/fs.h @@ -221,6 +221,13 @@ void read_file(dword path1, buf, size) return false; } +:dword get_file_size(dword _path) +{ + BDVK bdvk; + if (GetFileInfo(_path, #bdvk)!=0) return 0; + else return bdvk.sizelo; +} + /* // This implementation of dir_exists() is faster than // previous but here virtual folders like diff --git a/programs/cmm/misc/calypte.c b/programs/cmm/misc/calypte.c index 9b9c681e4b..5487182015 100644 --- a/programs/cmm/misc/calypte.c +++ b/programs/cmm/misc/calypte.c @@ -28,7 +28,6 @@ TODO #include "../lib/obj/iconv.h" #include "../lib/obj/box_lib.h" -#include "../lib/obj/libio.h" #include "../lib/obj/proc_lib.h" #include "../lib/obj/librasterworks.h" @@ -129,7 +128,6 @@ void main() int id; load_dll(boxlib, #box_lib_init, 0); - load_dll(libio, #libio_init, 1); //load_dll(libini, #lib_init, 1); load_dll(iconv_lib, #iconv_open, 0); load_dll(Proc_lib, #OpenDialog_init,0); @@ -250,18 +248,12 @@ void OpenFile(dword _path) strcpy(#param, _path); sprintf(#win_title, "%s - %s", TITLE, #param); rows.KeyHome(); - file_size stdcall (#param); - bufsize = EBX; - if (bufsize) + read_file(#param, #bufpointer, #bufsize); + if (!EAX) { - bufpointer = mem_Free(bufpointer); - bufpointer = mem_Alloc(bufsize); - if (ReadFile(0, bufsize, bufpointer, #param) != 0) - { - bufpointer = 0; - notify("'Error opening file'-E"); - return; - } + bufpointer = 0; + notify("'Error opening file'-E"); + return; } if (encoding!=CH_CP866) { diff --git a/programs/cmm/misc/osupdate.c b/programs/cmm/misc/osupdate.c index 1d12651131..1acfe46885 100644 --- a/programs/cmm/misc/osupdate.c +++ b/programs/cmm/misc/osupdate.c @@ -1,11 +1,9 @@ #define MEMSIZE 1024*50 -#include "../lib/io.h" #include "../lib/gui.h" #include "../lib/copyf.h" #include "../lib/obj/libini.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/http.h" #include "../lib/obj/network.h" @@ -58,7 +56,6 @@ void main() { int btn; sensor progress; - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(libHTTP, #http_lib_init,1); @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_STACK); @@ -127,8 +124,7 @@ dword GetFreeSpaceOfRamdisk() dword rdempty = malloc(1440*1024); CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty"); free(rdempty); - file_size stdcall ("/rd/1/rdempty"); - rdempty = EBX; + rdempty = get_file_size("/rd/1/rdempty"); DeleteFile("/rd/1/rdempty"); return rdempty; } diff --git a/programs/cmm/sysmon/sysmon.c b/programs/cmm/sysmon/sysmon.c index 86748ce585..eabdb703eb 100644 --- a/programs/cmm/sysmon/sysmon.c +++ b/programs/cmm/sysmon/sysmon.c @@ -20,7 +20,6 @@ #include "../lib/fs.h" #include "../lib/list_box.h" -#include "../lib/obj/libio.h" #include "../lib/obj/libimg.h" #include "../lib/obj/box_lib.h" @@ -100,7 +99,6 @@ int right_w; void load_lib() { - load_dll(libio, #libio_init,1); load_dll(libimg, #libimg_init,1); load_dll(boxlib, #box_lib_init,0); } @@ -260,8 +258,7 @@ void MonitorRd() dword rdempty = malloc(1440*1024); CreateFile(0, 1440*1024, rdempty, "/rd/1/rdempty"); free(rdempty); - file_size stdcall ("/rd/1/rdempty"); - rdempty = EBX / 1024; + rdempty = get_file_size("/rd/1/rdempty") / 1024; DeleteFile("/rd/1/rdempty"); sprintf(#param, T_RD_USAGE, rdempty); @@ -288,10 +285,9 @@ void MonitorTmp() dword free_space; for (i=0; i<=9; i++) { - file_size stdcall ( sprintf(#param, "/tmp%i/1", i) ); - tmp_size[i] = EBX / 1024 / 1024; - - if (EBX) { + get_file_size( sprintf(#param, "/tmp%i/1", i) ); + if (EAX) { + tmp_size[i] = EAX / 1024 / 1024; free_space = tmp_size[i] - GetTmpDiskFreeSpace(i); sprintf(#text_status, T_TMP_USAGE, i, free_space, tmp_size[i]); tmp.set_size(RIGHT_X, yy, right_w, 23);